documentation.d.ts 3.2 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402534035340453405534065340753408534095341053411534125341353414534155341653417534185341953420534215342253423534245342553426534275342853429534305343153432534335343453435534365343753438534395344053441534425344353444534455344653447534485344953450534515345253453534545345553456534575345853459534605346153462534635346453465534665346753468534695347053471534725347353474534755347653477534785347953480534815348253483534845348553486534875348853489534905349153492534935349453495534965349753498534995350053501535025350353504535055350653507535085350953510535115351253513535145351553516535175351853519535205352153522535235352453525535265352753528535295353053531535325353353534535355353653537535385353953540535415354253543535445354553546535475354853549535505355153552535535355453555535565355753558535595356053561535625356353564535655356653567535685356953570535715357253573535745357553576535775357853579535805358153582535835358453585535865358753588535895359053591535925359353594535955359653597535985359953600536015360253603536045360553606536075360853609536105361153612536135361453615536165361753618536195362053621536225362353624536255362653627536285362953630536315363253633536345363553636536375363853639536405364153642536435364453645536465364753648536495365053651536525365353654536555365653657536585365953660536615366253663536645366553666536675366853669536705367153672536735367453675536765367753678536795368053681536825368353684536855368653687536885368953690536915369253693536945369553696536975369853699537005370153702537035370453705537065370753708537095371053711537125371353714537155371653717537185371953720537215372253723537245372553726537275372853729537305373153732537335373453735537365373753738537395374053741537425374353744537455374653747537485374953750537515375253753537545375553756537575375853759537605376153762537635376453765537665376753768537695377053771537725377353774537755377653777537785377953780537815378253783537845378553786537875378853789537905379153792537935379453795537965379753798537995380053801538025380353804538055380653807538085380953810538115381253813538145381553816538175381853819538205382153822538235382453825538265382753828538295383053831538325383353834538355383653837538385383953840538415384253843538445384553846538475384853849538505385153852538535385453855538565385753858538595386053861538625386353864538655386653867538685386953870538715387253873538745387553876538775387853879538805388153882538835388453885538865388753888538895389053891538925389353894538955389653897538985389953900539015390253903539045390553906539075390853909539105391153912539135391453915539165391753918539195392053921539225392353924539255392653927539285392953930539315393253933539345393553936539375393853939539405394153942539435394453945539465394753948539495395053951539525395353954539555395653957539585395953960539615396253963539645396553966539675396853969539705397153972539735397453975539765397753978539795398053981539825398353984539855398653987539885398953990539915399253993539945399553996539975399853999540005400154002540035400454005540065400754008540095401054011540125401354014540155401654017540185401954020540215402254023540245402554026540275402854029540305403154032540335403454035540365403754038540395404054041540425404354044540455404654047540485404954050540515405254053540545405554056540575405854059540605406154062540635406454065540665406754068540695407054071540725407354074540755407654077540785407954080540815408254083540845408554086540875408854089540905409154092540935409454095540965409754098540995410054101541025410354104541055410654107541085410954110541115411254113541145411554116541175411854119541205412154122541235412454125541265412754128541295413054131541325413354134541355413654137541385413954140541415414254143541445414554146541475414854149541505415154152541535415454155541565415754158541595416054161541625416354164541655416654167541685416954170541715417254173541745417554176541775417854179541805418154182541835418454185541865418754188541895419054191541925419354194541955419654197541985419954200542015420254203542045420554206542075420854209542105421154212542135421454215542165421754218542195422054221542225422354224542255422654227542285422954230542315423254233542345423554236542375423854239542405424154242542435424454245542465424754248542495425054251542525425354254542555425654257542585425954260542615426254263542645426554266542675426854269542705427154272542735427454275542765427754278542795428054281542825428354284542855428654287542885428954290542915429254293542945429554296542975429854299543005430154302543035430454305543065430754308543095431054311543125431354314543155431654317543185431954320543215432254323543245432554326543275432854329543305433154332543335433454335543365433754338543395434054341543425434354344543455434654347543485434954350543515435254353543545435554356543575435854359543605436154362543635436454365543665436754368543695437054371543725437354374543755437654377543785437954380543815438254383543845438554386543875438854389543905439154392543935439454395543965439754398543995440054401544025440354404544055440654407544085440954410544115441254413544145441554416544175441854419544205442154422544235442454425544265442754428544295443054431544325443354434544355443654437544385443954440544415444254443544445444554446544475444854449544505445154452544535445454455544565445754458544595446054461544625446354464544655446654467544685446954470544715447254473544745447554476544775447854479544805448154482544835448454485544865448754488544895449054491544925449354494544955449654497544985449954500545015450254503545045450554506545075450854509545105451154512545135451454515545165451754518545195452054521545225452354524545255452654527545285452954530545315453254533545345453554536545375453854539545405454154542545435454454545545465454754548545495455054551545525455354554545555455654557545585455954560545615456254563545645456554566545675456854569545705457154572545735457454575545765457754578545795458054581545825458354584545855458654587545885458954590545915459254593545945459554596545975459854599546005460154602546035460454605546065460754608546095461054611546125461354614546155461654617546185461954620546215462254623546245462554626546275462854629546305463154632546335463454635546365463754638546395464054641546425464354644546455464654647546485464954650546515465254653546545465554656546575465854659546605466154662546635466454665546665466754668546695467054671546725467354674546755467654677546785467954680546815468254683546845468554686546875468854689546905469154692546935469454695546965469754698546995470054701547025470354704547055470654707547085470954710547115471254713547145471554716547175471854719547205472154722547235472454725547265472754728547295473054731547325473354734547355473654737547385473954740547415474254743547445474554746547475474854749547505475154752547535475454755547565475754758547595476054761547625476354764547655476654767547685476954770547715477254773547745477554776547775477854779547805478154782547835478454785547865478754788547895479054791547925479354794547955479654797547985479954800548015480254803548045480554806548075480854809548105481154812548135481454815548165481754818548195482054821548225482354824548255482654827548285482954830548315483254833548345483554836548375483854839548405484154842548435484454845548465484754848548495485054851548525485354854548555485654857548585485954860548615486254863548645486554866548675486854869548705487154872548735487454875548765487754878548795488054881548825488354884548855488654887548885488954890548915489254893548945489554896548975489854899549005490154902549035490454905549065490754908549095491054911549125491354914549155491654917549185491954920549215492254923549245492554926549275492854929549305493154932549335493454935549365493754938549395494054941549425494354944549455494654947549485494954950549515495254953549545495554956549575495854959549605496154962549635496454965549665496754968549695497054971549725497354974549755497654977549785497954980549815498254983549845498554986549875498854989549905499154992549935499454995549965499754998549995500055001550025500355004550055500655007550085500955010550115501255013550145501555016550175501855019550205502155022550235502455025550265502755028550295503055031550325503355034550355503655037550385503955040550415504255043550445504555046550475504855049550505505155052550535505455055550565505755058550595506055061550625506355064550655506655067550685506955070550715507255073550745507555076550775507855079550805508155082550835508455085550865508755088550895509055091550925509355094550955509655097550985509955100551015510255103551045510555106551075510855109551105511155112551135511455115551165511755118551195512055121551225512355124551255512655127551285512955130551315513255133551345513555136551375513855139551405514155142551435514455145551465514755148551495515055151551525515355154551555515655157551585515955160551615516255163551645516555166551675516855169551705517155172551735517455175551765517755178551795518055181551825518355184551855518655187551885518955190551915519255193551945519555196551975519855199552005520155202552035520455205552065520755208552095521055211552125521355214552155521655217552185521955220552215522255223552245522555226552275522855229552305523155232552335523455235552365523755238552395524055241552425524355244552455524655247552485524955250552515525255253552545525555256552575525855259552605526155262552635526455265552665526755268552695527055271552725527355274552755527655277552785527955280552815528255283552845528555286552875528855289552905529155292552935529455295552965529755298552995530055301553025530355304553055530655307553085530955310553115531255313553145531555316553175531855319553205532155322553235532455325553265532755328553295533055331553325533355334553355533655337553385533955340553415534255343553445534555346553475534855349553505535155352553535535455355553565535755358553595536055361553625536355364553655536655367553685536955370553715537255373553745537555376553775537855379553805538155382553835538455385553865538755388553895539055391553925539355394553955539655397553985539955400554015540255403554045540555406554075540855409554105541155412554135541455415554165541755418554195542055421554225542355424554255542655427554285542955430554315543255433554345543555436554375543855439554405544155442554435544455445554465544755448554495545055451554525545355454554555545655457554585545955460554615546255463554645546555466554675546855469554705547155472554735547455475554765547755478554795548055481554825548355484554855548655487554885548955490554915549255493554945549555496554975549855499555005550155502555035550455505555065550755508555095551055511555125551355514555155551655517555185551955520555215552255523555245552555526555275552855529555305553155532555335553455535555365553755538555395554055541555425554355544555455554655547555485554955550555515555255553555545555555556555575555855559555605556155562555635556455565555665556755568555695557055571555725557355574555755557655577555785557955580555815558255583555845558555586555875558855589555905559155592555935559455595555965559755598555995560055601556025560355604556055560655607556085560955610556115561255613556145561555616556175561855619556205562155622556235562455625556265562755628556295563055631556325563355634556355563655637556385563955640556415564255643556445564555646556475564855649556505565155652556535565455655556565565755658556595566055661556625566355664556655566655667556685566955670556715567255673556745567555676556775567855679556805568155682556835568455685556865568755688556895569055691556925569355694556955569655697556985569955700557015570255703557045570555706557075570855709557105571155712557135571455715557165571755718557195572055721557225572355724557255572655727557285572955730557315573255733557345573555736557375573855739557405574155742557435574455745557465574755748557495575055751557525575355754557555575655757557585575955760557615576255763557645576555766557675576855769557705577155772557735577455775557765577755778557795578055781557825578355784557855578655787557885578955790557915579255793557945579555796557975579855799558005580155802558035580455805558065580755808558095581055811558125581355814558155581655817558185581955820558215582255823558245582555826558275582855829558305583155832558335583455835558365583755838558395584055841558425584355844558455584655847558485584955850558515585255853558545585555856558575585855859558605586155862558635586455865558665586755868558695587055871558725587355874558755587655877558785587955880558815588255883558845588555886558875588855889558905589155892558935589455895558965589755898558995590055901559025590355904559055590655907559085590955910559115591255913559145591555916559175591855919559205592155922559235592455925559265592755928559295593055931559325593355934559355593655937559385593955940559415594255943559445594555946559475594855949559505595155952559535595455955559565595755958559595596055961559625596355964559655596655967559685596955970559715597255973559745597555976559775597855979559805598155982559835598455985559865598755988559895599055991559925599355994559955599655997559985599956000560015600256003560045600556006560075600856009560105601156012560135601456015560165601756018560195602056021560225602356024560255602656027560285602956030560315603256033560345603556036560375603856039560405604156042560435604456045560465604756048560495605056051560525605356054560555605656057560585605956060560615606256063560645606556066560675606856069560705607156072560735607456075560765607756078560795608056081560825608356084560855608656087560885608956090560915609256093560945609556096560975609856099561005610156102561035610456105561065610756108561095611056111561125611356114561155611656117561185611956120561215612256123561245612556126561275612856129561305613156132561335613456135561365613756138561395614056141561425614356144561455614656147561485614956150561515615256153561545615556156561575615856159561605616156162561635616456165561665616756168561695617056171561725617356174561755617656177561785617956180561815618256183561845618556186561875618856189561905619156192561935619456195561965619756198561995620056201562025620356204562055620656207562085620956210562115621256213562145621556216562175621856219562205622156222562235622456225562265622756228562295623056231562325623356234562355623656237562385623956240562415624256243562445624556246562475624856249562505625156252562535625456255562565625756258562595626056261562625626356264562655626656267562685626956270562715627256273562745627556276562775627856279562805628156282562835628456285562865628756288562895629056291562925629356294562955629656297562985629956300563015630256303563045630556306563075630856309563105631156312563135631456315563165631756318563195632056321563225632356324563255632656327563285632956330563315633256333563345633556336563375633856339563405634156342563435634456345563465634756348563495635056351563525635356354563555635656357563585635956360563615636256363563645636556366563675636856369563705637156372563735637456375563765637756378563795638056381563825638356384563855638656387563885638956390563915639256393563945639556396563975639856399564005640156402564035640456405564065640756408564095641056411564125641356414564155641656417564185641956420564215642256423564245642556426564275642856429564305643156432564335643456435564365643756438564395644056441564425644356444564455644656447564485644956450564515645256453564545645556456564575645856459564605646156462564635646456465564665646756468564695647056471564725647356474564755647656477564785647956480564815648256483564845648556486564875648856489564905649156492564935649456495564965649756498564995650056501565025650356504565055650656507565085650956510565115651256513565145651556516565175651856519565205652156522565235652456525565265652756528565295653056531565325653356534565355653656537565385653956540565415654256543565445654556546565475654856549565505655156552565535655456555565565655756558565595656056561565625656356564565655656656567565685656956570565715657256573565745657556576565775657856579565805658156582565835658456585565865658756588565895659056591565925659356594565955659656597565985659956600566015660256603566045660556606566075660856609566105661156612566135661456615566165661756618566195662056621566225662356624566255662656627566285662956630566315663256633566345663556636566375663856639566405664156642566435664456645566465664756648566495665056651566525665356654566555665656657566585665956660566615666256663566645666556666566675666856669566705667156672566735667456675566765667756678566795668056681566825668356684566855668656687566885668956690566915669256693566945669556696566975669856699567005670156702567035670456705567065670756708567095671056711567125671356714567155671656717567185671956720567215672256723567245672556726567275672856729567305673156732567335673456735567365673756738567395674056741567425674356744567455674656747567485674956750567515675256753567545675556756567575675856759567605676156762567635676456765567665676756768567695677056771567725677356774567755677656777567785677956780567815678256783567845678556786567875678856789567905679156792567935679456795567965679756798567995680056801568025680356804568055680656807568085680956810568115681256813568145681556816568175681856819568205682156822568235682456825568265682756828568295683056831568325683356834568355683656837568385683956840568415684256843568445684556846568475684856849568505685156852568535685456855568565685756858568595686056861568625686356864568655686656867568685686956870568715687256873568745687556876568775687856879568805688156882568835688456885568865688756888568895689056891568925689356894568955689656897568985689956900569015690256903569045690556906569075690856909569105691156912569135691456915569165691756918569195692056921569225692356924569255692656927569285692956930569315693256933569345693556936569375693856939569405694156942569435694456945569465694756948569495695056951569525695356954569555695656957569585695956960569615696256963569645696556966569675696856969569705697156972569735697456975569765697756978569795698056981569825698356984569855698656987569885698956990569915699256993569945699556996569975699856999570005700157002570035700457005570065700757008570095701057011570125701357014570155701657017570185701957020570215702257023570245702557026570275702857029570305703157032570335703457035570365703757038570395704057041570425704357044570455704657047570485704957050570515705257053570545705557056570575705857059570605706157062570635706457065570665706757068570695707057071570725707357074570755707657077570785707957080570815708257083570845708557086570875708857089570905709157092570935709457095570965709757098570995710057101571025710357104571055710657107571085710957110571115711257113571145711557116571175711857119571205712157122571235712457125571265712757128571295713057131571325713357134571355713657137571385713957140571415714257143571445714557146571475714857149571505715157152571535715457155571565715757158571595716057161571625716357164571655716657167571685716957170571715717257173571745717557176571775717857179571805718157182571835718457185571865718757188571895719057191571925719357194571955719657197571985719957200572015720257203572045720557206572075720857209572105721157212572135721457215572165721757218572195722057221572225722357224572255722657227572285722957230572315723257233572345723557236572375723857239572405724157242572435724457245572465724757248572495725057251572525725357254572555725657257572585725957260572615726257263572645726557266572675726857269572705727157272572735727457275572765727757278572795728057281572825728357284572855728657287572885728957290572915729257293572945729557296572975729857299573005730157302573035730457305573065730757308573095731057311573125731357314573155731657317573185731957320573215732257323573245732557326573275732857329573305733157332573335733457335573365733757338573395734057341573425734357344573455734657347573485734957350573515735257353573545735557356573575735857359573605736157362573635736457365573665736757368573695737057371573725737357374573755737657377573785737957380573815738257383573845738557386573875738857389573905739157392573935739457395573965739757398573995740057401574025740357404574055740657407574085740957410574115741257413574145741557416574175741857419574205742157422574235742457425574265742757428574295743057431574325743357434574355743657437574385743957440574415744257443574445744557446574475744857449574505745157452574535745457455574565745757458574595746057461574625746357464574655746657467574685746957470574715747257473574745747557476574775747857479574805748157482574835748457485574865748757488574895749057491574925749357494574955749657497574985749957500575015750257503575045750557506575075750857509575105751157512575135751457515575165751757518575195752057521575225752357524575255752657527575285752957530575315753257533575345753557536575375753857539575405754157542575435754457545575465754757548575495755057551575525755357554575555755657557575585755957560575615756257563575645756557566575675756857569575705757157572575735757457575575765757757578575795758057581575825758357584575855758657587575885758957590575915759257593575945759557596575975759857599576005760157602576035760457605576065760757608576095761057611576125761357614576155761657617576185761957620576215762257623576245762557626576275762857629576305763157632576335763457635576365763757638576395764057641576425764357644576455764657647576485764957650576515765257653576545765557656576575765857659576605766157662576635766457665576665766757668576695767057671576725767357674576755767657677576785767957680576815768257683576845768557686576875768857689576905769157692576935769457695576965769757698576995770057701577025770357704577055770657707577085770957710577115771257713577145771557716577175771857719577205772157722577235772457725577265772757728577295773057731577325773357734577355773657737577385773957740577415774257743577445774557746577475774857749577505775157752577535775457755577565775757758577595776057761577625776357764577655776657767577685776957770577715777257773577745777557776577775777857779577805778157782577835778457785577865778757788577895779057791577925779357794577955779657797577985779957800578015780257803578045780557806578075780857809578105781157812578135781457815578165781757818578195782057821578225782357824578255782657827578285782957830578315783257833578345783557836578375783857839578405784157842578435784457845578465784757848578495785057851578525785357854578555785657857578585785957860578615786257863578645786557866578675786857869578705787157872578735787457875578765787757878578795788057881578825788357884578855788657887578885788957890578915789257893578945789557896578975789857899579005790157902579035790457905579065790757908579095791057911579125791357914579155791657917579185791957920579215792257923579245792557926579275792857929579305793157932579335793457935579365793757938579395794057941579425794357944579455794657947579485794957950579515795257953579545795557956579575795857959579605796157962579635796457965579665796757968579695797057971579725797357974579755797657977579785797957980579815798257983579845798557986579875798857989579905799157992579935799457995579965799757998579995800058001580025800358004580055800658007580085800958010580115801258013580145801558016580175801858019580205802158022580235802458025580265802758028580295803058031580325803358034580355803658037580385803958040580415804258043580445804558046580475804858049580505805158052580535805458055580565805758058580595806058061580625806358064580655806658067580685806958070580715807258073580745807558076580775807858079580805808158082580835808458085580865808758088580895809058091580925809358094580955809658097580985809958100581015810258103581045810558106581075810858109581105811158112581135811458115581165811758118581195812058121581225812358124581255812658127581285812958130581315813258133581345813558136581375813858139581405814158142581435814458145581465814758148581495815058151581525815358154581555815658157581585815958160581615816258163581645816558166581675816858169581705817158172581735817458175581765817758178581795818058181581825818358184581855818658187581885818958190581915819258193581945819558196581975819858199582005820158202582035820458205582065820758208582095821058211582125821358214582155821658217582185821958220582215822258223582245822558226582275822858229582305823158232582335823458235582365823758238582395824058241582425824358244582455824658247582485824958250582515825258253582545825558256582575825858259582605826158262582635826458265582665826758268582695827058271582725827358274582755827658277582785827958280582815828258283582845828558286582875828858289582905829158292582935829458295582965829758298582995830058301583025830358304583055830658307583085830958310583115831258313583145831558316583175831858319583205832158322583235832458325583265832758328583295833058331583325833358334583355833658337583385833958340583415834258343583445834558346583475834858349583505835158352583535835458355583565835758358583595836058361583625836358364583655836658367583685836958370583715837258373583745837558376583775837858379583805838158382583835838458385583865838758388583895839058391583925839358394583955839658397583985839958400584015840258403584045840558406584075840858409584105841158412584135841458415584165841758418584195842058421584225842358424584255842658427584285842958430584315843258433584345843558436584375843858439584405844158442584435844458445584465844758448584495845058451584525845358454584555845658457584585845958460584615846258463584645846558466584675846858469584705847158472584735847458475584765847758478584795848058481584825848358484584855848658487584885848958490584915849258493584945849558496584975849858499585005850158502585035850458505585065850758508585095851058511585125851358514585155851658517585185851958520585215852258523585245852558526585275852858529585305853158532585335853458535585365853758538585395854058541585425854358544585455854658547585485854958550585515855258553585545855558556585575855858559585605856158562585635856458565585665856758568585695857058571585725857358574585755857658577585785857958580585815858258583585845858558586585875858858589585905859158592585935859458595585965859758598585995860058601586025860358604586055860658607586085860958610586115861258613586145861558616586175861858619586205862158622586235862458625586265862758628586295863058631586325863358634586355863658637586385863958640586415864258643586445864558646586475864858649586505865158652586535865458655586565865758658586595866058661586625866358664586655866658667586685866958670586715867258673586745867558676586775867858679586805868158682586835868458685586865868758688586895869058691586925869358694586955869658697586985869958700587015870258703587045870558706587075870858709587105871158712587135871458715587165871758718587195872058721587225872358724587255872658727587285872958730587315873258733587345873558736587375873858739587405874158742587435874458745587465874758748587495875058751587525875358754587555875658757587585875958760587615876258763587645876558766587675876858769587705877158772587735877458775587765877758778587795878058781587825878358784587855878658787587885878958790587915879258793587945879558796587975879858799588005880158802588035880458805588065880758808588095881058811588125881358814588155881658817588185881958820588215882258823588245882558826588275882858829588305883158832588335883458835588365883758838588395884058841588425884358844588455884658847588485884958850588515885258853588545885558856588575885858859588605886158862588635886458865588665886758868588695887058871588725887358874588755887658877588785887958880588815888258883588845888558886588875888858889588905889158892588935889458895588965889758898588995890058901589025890358904589055890658907589085890958910589115891258913589145891558916589175891858919589205892158922589235892458925589265892758928589295893058931589325893358934589355893658937589385893958940589415894258943589445894558946589475894858949589505895158952589535895458955589565895758958589595896058961589625896358964589655896658967589685896958970589715897258973589745897558976589775897858979589805898158982589835898458985589865898758988589895899058991589925899358994589955899658997589985899959000590015900259003590045900559006590075900859009590105901159012590135901459015590165901759018590195902059021590225902359024590255902659027590285902959030590315903259033590345903559036590375903859039590405904159042590435904459045590465904759048590495905059051590525905359054590555905659057590585905959060590615906259063590645906559066590675906859069590705907159072590735907459075590765907759078590795908059081590825908359084590855908659087590885908959090590915909259093590945909559096590975909859099591005910159102591035910459105591065910759108591095911059111591125911359114591155911659117591185911959120591215912259123591245912559126591275912859129591305913159132591335913459135591365913759138591395914059141591425914359144591455914659147591485914959150591515915259153591545915559156591575915859159591605916159162591635916459165591665916759168591695917059171591725917359174591755917659177591785917959180591815918259183591845918559186591875918859189591905919159192591935919459195591965919759198591995920059201592025920359204592055920659207592085920959210592115921259213592145921559216592175921859219592205922159222592235922459225592265922759228592295923059231592325923359234592355923659237592385923959240592415924259243592445924559246592475924859249592505925159252592535925459255592565925759258592595926059261592625926359264592655926659267592685926959270592715927259273592745927559276592775927859279592805928159282592835928459285592865928759288592895929059291592925929359294592955929659297592985929959300593015930259303593045930559306593075930859309593105931159312593135931459315593165931759318593195932059321593225932359324593255932659327593285932959330593315933259333593345933559336593375933859339593405934159342593435934459345593465934759348593495935059351593525935359354593555935659357593585935959360593615936259363593645936559366593675936859369593705937159372593735937459375593765937759378593795938059381593825938359384593855938659387593885938959390593915939259393593945939559396593975939859399594005940159402594035940459405594065940759408594095941059411594125941359414594155941659417594185941959420594215942259423594245942559426594275942859429594305943159432594335943459435594365943759438594395944059441594425944359444594455944659447594485944959450594515945259453594545945559456594575945859459594605946159462594635946459465594665946759468594695947059471594725947359474594755947659477594785947959480594815948259483594845948559486594875948859489594905949159492594935949459495594965949759498594995950059501595025950359504595055950659507595085950959510595115951259513595145951559516595175951859519595205952159522595235952459525595265952759528595295953059531595325953359534595355953659537595385953959540595415954259543595445954559546595475954859549595505955159552595535955459555595565955759558595595956059561595625956359564595655956659567595685956959570595715957259573595745957559576595775957859579595805958159582595835958459585595865958759588595895959059591595925959359594595955959659597595985959959600596015960259603596045960559606596075960859609596105961159612596135961459615596165961759618596195962059621596225962359624596255962659627596285962959630596315963259633596345963559636596375963859639596405964159642596435964459645596465964759648596495965059651596525965359654596555965659657596585965959660596615966259663596645966559666596675966859669596705967159672596735967459675596765967759678596795968059681596825968359684596855968659687596885968959690596915969259693596945969559696596975969859699597005970159702597035970459705597065970759708597095971059711597125971359714597155971659717597185971959720597215972259723597245972559726597275972859729597305973159732597335973459735597365973759738597395974059741597425974359744597455974659747597485974959750597515975259753597545975559756597575975859759597605976159762597635976459765597665976759768597695977059771597725977359774597755977659777597785977959780597815978259783597845978559786597875978859789597905979159792597935979459795597965979759798597995980059801598025980359804598055980659807598085980959810598115981259813598145981559816598175981859819598205982159822598235982459825598265982759828598295983059831598325983359834598355983659837598385983959840598415984259843598445984559846598475984859849598505985159852598535985459855598565985759858598595986059861598625986359864598655986659867598685986959870598715987259873598745987559876598775987859879598805988159882598835988459885598865988759888598895989059891598925989359894598955989659897598985989959900599015990259903599045990559906599075990859909599105991159912599135991459915599165991759918599195992059921599225992359924599255992659927599285992959930599315993259933599345993559936599375993859939599405994159942599435994459945599465994759948599495995059951599525995359954599555995659957599585995959960599615996259963599645996559966599675996859969599705997159972599735997459975599765997759978599795998059981599825998359984599855998659987599885998959990599915999259993599945999559996599975999859999600006000160002600036000460005600066000760008600096001060011600126001360014600156001660017600186001960020600216002260023600246002560026600276002860029600306003160032600336003460035600366003760038600396004060041600426004360044600456004660047600486004960050600516005260053600546005560056600576005860059600606006160062600636006460065600666006760068600696007060071600726007360074600756007660077600786007960080600816008260083600846008560086600876008860089600906009160092600936009460095600966009760098600996010060101601026010360104601056010660107601086010960110601116011260113601146011560116601176011860119601206012160122601236012460125601266012760128601296013060131601326013360134601356013660137601386013960140601416014260143601446014560146601476014860149601506015160152601536015460155601566015760158601596016060161601626016360164601656016660167601686016960170601716017260173601746017560176601776017860179601806018160182601836018460185601866018760188601896019060191601926019360194601956019660197601986019960200602016020260203602046020560206602076020860209602106021160212602136021460215602166021760218602196022060221602226022360224602256022660227602286022960230602316023260233602346023560236602376023860239602406024160242602436024460245602466024760248602496025060251602526025360254602556025660257602586025960260602616026260263602646026560266602676026860269602706027160272602736027460275602766027760278602796028060281602826028360284602856028660287602886028960290602916029260293602946029560296602976029860299603006030160302603036030460305603066030760308603096031060311603126031360314603156031660317603186031960320603216032260323603246032560326603276032860329603306033160332603336033460335603366033760338603396034060341603426034360344603456034660347603486034960350603516035260353603546035560356603576035860359603606036160362603636036460365603666036760368603696037060371603726037360374603756037660377603786037960380603816038260383603846038560386603876038860389603906039160392603936039460395603966039760398603996040060401604026040360404604056040660407604086040960410604116041260413604146041560416604176041860419604206042160422604236042460425604266042760428604296043060431604326043360434604356043660437604386043960440604416044260443604446044560446604476044860449604506045160452604536045460455604566045760458604596046060461604626046360464604656046660467604686046960470604716047260473604746047560476604776047860479604806048160482604836048460485604866048760488604896049060491604926049360494604956049660497604986049960500605016050260503605046050560506605076050860509605106051160512605136051460515605166051760518605196052060521605226052360524605256052660527605286052960530605316053260533605346053560536605376053860539605406054160542605436054460545605466054760548605496055060551605526055360554605556055660557605586055960560605616056260563605646056560566605676056860569605706057160572605736057460575605766057760578605796058060581605826058360584605856058660587605886058960590605916059260593605946059560596605976059860599606006060160602606036060460605606066060760608606096061060611606126061360614606156061660617606186061960620606216062260623606246062560626606276062860629606306063160632606336063460635606366063760638606396064060641606426064360644606456064660647606486064960650606516065260653606546065560656606576065860659606606066160662606636066460665606666066760668606696067060671606726067360674606756067660677606786067960680606816068260683606846068560686606876068860689606906069160692606936069460695606966069760698606996070060701607026070360704607056070660707607086070960710607116071260713607146071560716607176071860719607206072160722607236072460725607266072760728607296073060731607326073360734607356073660737607386073960740607416074260743607446074560746607476074860749607506075160752607536075460755607566075760758607596076060761607626076360764607656076660767607686076960770607716077260773607746077560776607776077860779607806078160782607836078460785607866078760788607896079060791607926079360794607956079660797607986079960800608016080260803608046080560806608076080860809608106081160812608136081460815608166081760818608196082060821608226082360824608256082660827608286082960830608316083260833608346083560836608376083860839608406084160842608436084460845608466084760848608496085060851608526085360854608556085660857608586085960860608616086260863608646086560866608676086860869608706087160872608736087460875608766087760878608796088060881608826088360884608856088660887608886088960890608916089260893608946089560896608976089860899609006090160902609036090460905609066090760908609096091060911609126091360914609156091660917609186091960920609216092260923609246092560926609276092860929609306093160932609336093460935609366093760938609396094060941609426094360944609456094660947609486094960950609516095260953609546095560956609576095860959609606096160962609636096460965609666096760968609696097060971609726097360974609756097660977609786097960980609816098260983609846098560986609876098860989609906099160992609936099460995609966099760998609996100061001610026100361004610056100661007610086100961010610116101261013610146101561016610176101861019610206102161022610236102461025610266102761028610296103061031610326103361034610356103661037610386103961040610416104261043610446104561046610476104861049610506105161052610536105461055610566105761058610596106061061610626106361064610656106661067610686106961070610716107261073610746107561076610776107861079610806108161082610836108461085610866108761088610896109061091610926109361094610956109661097610986109961100611016110261103611046110561106611076110861109611106111161112611136111461115611166111761118611196112061121611226112361124611256112661127611286112961130611316113261133611346113561136611376113861139611406114161142611436114461145611466114761148611496115061151611526115361154611556115661157611586115961160611616116261163611646116561166611676116861169611706117161172611736117461175611766117761178611796118061181611826118361184611856118661187611886118961190611916119261193611946119561196611976119861199612006120161202612036120461205612066120761208612096121061211612126121361214612156121661217612186121961220612216122261223612246122561226612276122861229612306123161232612336123461235612366123761238612396124061241612426124361244612456124661247612486124961250612516125261253612546125561256612576125861259612606126161262612636126461265612666126761268612696127061271612726127361274612756127661277612786127961280612816128261283612846128561286612876128861289612906129161292612936129461295612966129761298612996130061301613026130361304613056130661307613086130961310613116131261313613146131561316613176131861319613206132161322613236132461325613266132761328613296133061331613326133361334613356133661337613386133961340613416134261343613446134561346613476134861349613506135161352613536135461355613566135761358613596136061361613626136361364613656136661367613686136961370613716137261373613746137561376613776137861379613806138161382613836138461385613866138761388613896139061391613926139361394613956139661397613986139961400614016140261403614046140561406614076140861409614106141161412614136141461415614166141761418614196142061421614226142361424614256142661427614286142961430614316143261433614346143561436614376143861439614406144161442614436144461445614466144761448614496145061451614526145361454614556145661457614586145961460614616146261463614646146561466614676146861469614706147161472614736147461475614766147761478614796148061481614826148361484614856148661487614886148961490614916149261493614946149561496614976149861499615006150161502615036150461505615066150761508615096151061511615126151361514615156151661517615186151961520615216152261523615246152561526615276152861529615306153161532615336153461535615366153761538615396154061541615426154361544615456154661547615486154961550615516155261553615546155561556615576155861559615606156161562615636156461565615666156761568615696157061571615726157361574615756157661577615786157961580615816158261583615846158561586615876158861589615906159161592615936159461595615966159761598615996160061601616026160361604616056160661607616086160961610616116161261613616146161561616616176161861619616206162161622616236162461625616266162761628616296163061631616326163361634616356163661637616386163961640616416164261643616446164561646616476164861649616506165161652616536165461655616566165761658616596166061661616626166361664616656166661667616686166961670616716167261673616746167561676616776167861679616806168161682616836168461685616866168761688616896169061691616926169361694616956169661697616986169961700617016170261703617046170561706617076170861709617106171161712617136171461715617166171761718617196172061721617226172361724617256172661727617286172961730617316173261733617346173561736617376173861739617406174161742617436174461745617466174761748617496175061751617526175361754617556175661757617586175961760617616176261763617646176561766617676176861769617706177161772617736177461775617766177761778617796178061781617826178361784617856178661787617886178961790617916179261793617946179561796617976179861799618006180161802618036180461805618066180761808618096181061811618126181361814618156181661817618186181961820618216182261823618246182561826618276182861829618306183161832618336183461835618366183761838618396184061841618426184361844618456184661847618486184961850618516185261853618546185561856618576185861859618606186161862618636186461865618666186761868618696187061871618726187361874618756187661877618786187961880618816188261883618846188561886618876188861889618906189161892618936189461895618966189761898618996190061901619026190361904619056190661907619086190961910619116191261913619146191561916619176191861919619206192161922619236192461925619266192761928619296193061931619326193361934619356193661937619386193961940619416194261943619446194561946619476194861949619506195161952619536195461955619566195761958619596196061961619626196361964619656196661967619686196961970619716197261973619746197561976619776197861979619806198161982619836198461985619866198761988619896199061991619926199361994619956199661997619986199962000620016200262003620046200562006620076200862009620106201162012620136201462015620166201762018620196202062021620226202362024620256202662027620286202962030620316203262033620346203562036620376203862039620406204162042620436204462045620466204762048620496205062051620526205362054620556205662057620586205962060620616206262063620646206562066620676206862069620706207162072620736207462075620766207762078620796208062081620826208362084620856208662087620886208962090620916209262093620946209562096620976209862099621006210162102621036210462105621066210762108621096211062111621126211362114621156211662117621186211962120621216212262123621246212562126621276212862129621306213162132621336213462135621366213762138621396214062141621426214362144621456214662147621486214962150621516215262153621546215562156621576215862159621606216162162621636216462165621666216762168621696217062171621726217362174621756217662177621786217962180621816218262183621846218562186621876218862189621906219162192621936219462195621966219762198621996220062201622026220362204622056220662207622086220962210622116221262213622146221562216622176221862219622206222162222622236222462225622266222762228622296223062231622326223362234622356223662237622386223962240622416224262243622446224562246622476224862249622506225162252622536225462255622566225762258622596226062261622626226362264622656226662267622686226962270622716227262273622746227562276622776227862279622806228162282622836228462285622866228762288622896229062291622926229362294622956229662297622986229962300623016230262303623046230562306623076230862309623106231162312623136231462315623166231762318623196232062321623226232362324623256232662327623286232962330623316233262333623346233562336623376233862339623406234162342623436234462345623466234762348623496235062351623526235362354623556235662357623586235962360623616236262363623646236562366623676236862369623706237162372623736237462375623766237762378623796238062381623826238362384623856238662387623886238962390623916239262393623946239562396623976239862399624006240162402624036240462405624066240762408624096241062411624126241362414624156241662417624186241962420624216242262423624246242562426624276242862429624306243162432624336243462435624366243762438624396244062441624426244362444624456244662447624486244962450624516245262453624546245562456624576245862459624606246162462624636246462465624666246762468624696247062471624726247362474624756247662477624786247962480624816248262483624846248562486624876248862489624906249162492624936249462495624966249762498624996250062501625026250362504625056250662507625086250962510625116251262513625146251562516625176251862519625206252162522625236252462525625266252762528625296253062531625326253362534625356253662537625386253962540625416254262543625446254562546625476254862549625506255162552625536255462555625566255762558625596256062561625626256362564625656256662567625686256962570625716257262573625746257562576625776257862579625806258162582625836258462585625866258762588625896259062591625926259362594625956259662597625986259962600626016260262603626046260562606626076260862609626106261162612626136261462615626166261762618626196262062621626226262362624626256262662627626286262962630626316263262633626346263562636626376263862639626406264162642626436264462645626466264762648626496265062651626526265362654626556265662657626586265962660626616266262663626646266562666626676266862669626706267162672626736267462675626766267762678626796268062681626826268362684626856268662687626886268962690626916269262693626946269562696626976269862699627006270162702627036270462705627066270762708627096271062711627126271362714627156271662717627186271962720627216272262723627246272562726627276272862729627306273162732627336273462735627366273762738627396274062741627426274362744627456274662747627486274962750627516275262753627546275562756627576275862759627606276162762627636276462765627666276762768627696277062771627726277362774627756277662777627786277962780627816278262783627846278562786627876278862789627906279162792627936279462795627966279762798627996280062801628026280362804628056280662807628086280962810628116281262813628146281562816628176281862819628206282162822628236282462825628266282762828628296283062831628326283362834628356283662837628386283962840628416284262843628446284562846628476284862849628506285162852628536285462855628566285762858628596286062861628626286362864628656286662867628686286962870628716287262873628746287562876628776287862879628806288162882628836288462885628866288762888628896289062891628926289362894628956289662897628986289962900629016290262903629046290562906629076290862909629106291162912629136291462915629166291762918629196292062921629226292362924629256292662927629286292962930629316293262933629346293562936629376293862939629406294162942629436294462945629466294762948629496295062951629526295362954629556295662957629586295962960629616296262963629646296562966629676296862969629706297162972629736297462975629766297762978629796298062981629826298362984629856298662987629886298962990629916299262993629946299562996629976299862999630006300163002630036300463005630066300763008630096301063011630126301363014630156301663017630186301963020630216302263023630246302563026630276302863029630306303163032630336303463035630366303763038630396304063041630426304363044630456304663047630486304963050630516305263053630546305563056630576305863059630606306163062630636306463065630666306763068630696307063071630726307363074630756307663077630786307963080630816308263083630846308563086630876308863089630906309163092630936309463095630966309763098630996310063101631026310363104631056310663107631086310963110631116311263113631146311563116631176311863119631206312163122631236312463125631266312763128631296313063131631326313363134631356313663137631386313963140631416314263143631446314563146631476314863149631506315163152631536315463155631566315763158631596316063161631626316363164631656316663167631686316963170631716317263173631746317563176631776317863179631806318163182631836318463185631866318763188631896319063191631926319363194631956319663197631986319963200632016320263203632046320563206632076320863209632106321163212632136321463215632166321763218632196322063221632226322363224632256322663227632286322963230632316323263233632346323563236632376323863239632406324163242632436324463245632466324763248632496325063251632526325363254632556325663257632586325963260632616326263263632646326563266632676326863269632706327163272632736327463275632766327763278632796328063281632826328363284632856328663287632886328963290632916329263293632946329563296632976329863299633006330163302633036330463305633066330763308633096331063311633126331363314633156331663317633186331963320633216332263323633246332563326633276332863329633306333163332633336333463335633366333763338633396334063341633426334363344633456334663347633486334963350633516335263353633546335563356633576335863359633606336163362633636336463365633666336763368633696337063371633726337363374633756337663377633786337963380633816338263383633846338563386633876338863389633906339163392633936339463395633966339763398633996340063401634026340363404634056340663407634086340963410634116341263413634146341563416634176341863419634206342163422634236342463425634266342763428634296343063431634326343363434634356343663437634386343963440634416344263443634446344563446634476344863449634506345163452634536345463455634566345763458634596346063461634626346363464634656346663467634686346963470634716347263473634746347563476634776347863479634806348163482634836348463485634866348763488634896349063491634926349363494634956349663497634986349963500635016350263503635046350563506635076350863509635106351163512635136351463515635166351763518635196352063521635226352363524635256352663527635286352963530635316353263533635346353563536635376353863539635406354163542635436354463545635466354763548635496355063551635526355363554635556355663557635586355963560635616356263563635646356563566635676356863569635706357163572635736357463575635766357763578635796358063581635826358363584635856358663587635886358963590635916359263593635946359563596635976359863599636006360163602636036360463605636066360763608636096361063611636126361363614636156361663617636186361963620636216362263623636246362563626636276362863629636306363163632636336363463635636366363763638636396364063641636426364363644636456364663647636486364963650636516365263653636546365563656636576365863659636606366163662636636366463665636666366763668636696367063671636726367363674636756367663677636786367963680636816368263683636846368563686636876368863689636906369163692636936369463695636966369763698636996370063701637026370363704637056370663707637086370963710637116371263713637146371563716637176371863719637206372163722637236372463725637266372763728637296373063731637326373363734637356373663737637386373963740637416374263743637446374563746637476374863749637506375163752637536375463755637566375763758637596376063761637626376363764637656376663767637686376963770637716377263773637746377563776637776377863779637806378163782637836378463785637866378763788637896379063791637926379363794637956379663797637986379963800638016380263803638046380563806638076380863809638106381163812638136381463815638166381763818638196382063821638226382363824638256382663827638286382963830638316383263833638346383563836638376383863839638406384163842638436384463845638466384763848638496385063851638526385363854638556385663857638586385963860638616386263863638646386563866638676386863869638706387163872638736387463875638766387763878638796388063881638826388363884638856388663887638886388963890638916389263893638946389563896638976389863899639006390163902639036390463905639066390763908639096391063911639126391363914639156391663917639186391963920639216392263923639246392563926639276392863929639306393163932639336393463935639366393763938639396394063941639426394363944639456394663947639486394963950639516395263953639546395563956639576395863959639606396163962639636396463965639666396763968639696397063971639726397363974639756397663977639786397963980639816398263983639846398563986639876398863989639906399163992639936399463995639966399763998639996400064001640026400364004640056400664007640086400964010640116401264013640146401564016640176401864019640206402164022640236402464025640266402764028640296403064031640326403364034640356403664037640386403964040640416404264043640446404564046640476404864049640506405164052640536405464055640566405764058640596406064061640626406364064640656406664067640686406964070640716407264073640746407564076640776407864079640806408164082640836408464085640866408764088640896409064091640926409364094640956409664097640986409964100641016410264103641046410564106641076410864109641106411164112641136411464115641166411764118641196412064121641226412364124641256412664127641286412964130641316413264133641346413564136641376413864139641406414164142641436414464145641466414764148641496415064151641526415364154641556415664157641586415964160641616416264163641646416564166641676416864169641706417164172641736417464175641766417764178641796418064181641826418364184641856418664187641886418964190641916419264193641946419564196641976419864199642006420164202642036420464205642066420764208642096421064211642126421364214642156421664217642186421964220642216422264223642246422564226642276422864229642306423164232642336423464235642366423764238642396424064241642426424364244642456424664247642486424964250642516425264253642546425564256642576425864259642606426164262642636426464265642666426764268642696427064271642726427364274642756427664277642786427964280642816428264283642846428564286642876428864289642906429164292642936429464295642966429764298642996430064301643026430364304643056430664307643086430964310643116431264313643146431564316643176431864319643206432164322643236432464325643266432764328643296433064331643326433364334643356433664337643386433964340643416434264343643446434564346643476434864349643506435164352643536435464355643566435764358643596436064361643626436364364643656436664367643686436964370643716437264373643746437564376643776437864379643806438164382643836438464385643866438764388643896439064391643926439364394643956439664397643986439964400644016440264403644046440564406644076440864409644106441164412644136441464415644166441764418644196442064421644226442364424644256442664427644286442964430644316443264433644346443564436644376443864439644406444164442644436444464445644466444764448644496445064451644526445364454644556445664457644586445964460644616446264463644646446564466644676446864469644706447164472644736447464475644766447764478644796448064481644826448364484644856448664487644886448964490644916449264493644946449564496644976449864499645006450164502645036450464505645066450764508645096451064511645126451364514645156451664517645186451964520645216452264523645246452564526645276452864529645306453164532645336453464535645366453764538645396454064541645426454364544645456454664547645486454964550645516455264553645546455564556645576455864559645606456164562645636456464565645666456764568645696457064571645726457364574645756457664577645786457964580645816458264583645846458564586645876458864589645906459164592645936459464595645966459764598645996460064601646026460364604646056460664607646086460964610646116461264613646146461564616646176461864619646206462164622646236462464625646266462764628646296463064631646326463364634646356463664637646386463964640646416464264643646446464564646646476464864649646506465164652646536465464655646566465764658646596466064661646626466364664646656466664667646686466964670646716467264673646746467564676646776467864679646806468164682646836468464685646866468764688646896469064691646926469364694646956469664697646986469964700647016470264703647046470564706647076470864709647106471164712647136471464715647166471764718647196472064721647226472364724647256472664727647286472964730647316473264733647346473564736647376473864739647406474164742647436474464745647466474764748647496475064751647526475364754647556475664757647586475964760647616476264763647646476564766647676476864769647706477164772647736477464775647766477764778647796478064781647826478364784647856478664787647886478964790647916479264793647946479564796647976479864799648006480164802648036480464805648066480764808648096481064811648126481364814648156481664817648186481964820648216482264823648246482564826648276482864829648306483164832648336483464835648366483764838648396484064841648426484364844648456484664847648486484964850648516485264853648546485564856648576485864859648606486164862648636486464865648666486764868648696487064871648726487364874648756487664877648786487964880648816488264883648846488564886648876488864889648906489164892648936489464895648966489764898648996490064901649026490364904649056490664907649086490964910649116491264913649146491564916649176491864919649206492164922649236492464925649266492764928649296493064931649326493364934649356493664937649386493964940649416494264943649446494564946649476494864949649506495164952649536495464955649566495764958649596496064961649626496364964649656496664967649686496964970649716497264973649746497564976649776497864979649806498164982649836498464985649866498764988649896499064991649926499364994649956499664997649986499965000650016500265003650046500565006650076500865009650106501165012650136501465015650166501765018650196502065021650226502365024650256502665027650286502965030650316503265033650346503565036650376503865039650406504165042650436504465045650466504765048650496505065051650526505365054650556505665057650586505965060650616506265063650646506565066650676506865069650706507165072650736507465075650766507765078650796508065081650826508365084650856508665087650886508965090650916509265093650946509565096650976509865099651006510165102651036510465105651066510765108651096511065111651126511365114651156511665117651186511965120651216512265123651246512565126651276512865129651306513165132651336513465135651366513765138651396514065141651426514365144651456514665147651486514965150651516515265153651546515565156651576515865159651606516165162651636516465165651666516765168651696517065171651726517365174651756517665177651786517965180651816518265183651846518565186651876518865189651906519165192651936519465195651966519765198651996520065201652026520365204652056520665207652086520965210652116521265213652146521565216652176521865219652206522165222652236522465225652266522765228652296523065231652326523365234652356523665237652386523965240652416524265243652446524565246652476524865249652506525165252652536525465255652566525765258652596526065261652626526365264652656526665267652686526965270652716527265273652746527565276652776527865279652806528165282652836528465285652866528765288652896529065291652926529365294652956529665297652986529965300653016530265303653046530565306653076530865309653106531165312653136531465315653166531765318653196532065321653226532365324653256532665327653286532965330653316533265333653346533565336653376533865339653406534165342653436534465345653466534765348653496535065351653526535365354653556535665357653586535965360653616536265363653646536565366653676536865369653706537165372653736537465375653766537765378653796538065381653826538365384653856538665387653886538965390653916539265393653946539565396653976539865399654006540165402654036540465405654066540765408654096541065411654126541365414654156541665417654186541965420654216542265423654246542565426654276542865429654306543165432654336543465435654366543765438654396544065441654426544365444654456544665447654486544965450654516545265453654546545565456654576545865459654606546165462654636546465465654666546765468654696547065471654726547365474654756547665477654786547965480654816548265483654846548565486654876548865489654906549165492654936549465495654966549765498654996550065501655026550365504655056550665507655086550965510655116551265513655146551565516655176551865519655206552165522655236552465525655266552765528655296553065531655326553365534655356553665537655386553965540655416554265543655446554565546655476554865549655506555165552655536555465555655566555765558655596556065561655626556365564655656556665567655686556965570655716557265573655746557565576655776557865579655806558165582655836558465585655866558765588655896559065591655926559365594655956559665597655986559965600656016560265603656046560565606656076560865609656106561165612656136561465615656166561765618656196562065621656226562365624656256562665627656286562965630656316563265633656346563565636656376563865639656406564165642656436564465645656466564765648656496565065651656526565365654656556565665657656586565965660656616566265663656646566565666656676566865669656706567165672656736567465675656766567765678656796568065681656826568365684656856568665687656886568965690656916569265693656946569565696656976569865699657006570165702657036570465705657066570765708657096571065711657126571365714657156571665717657186571965720657216572265723657246572565726657276572865729657306573165732657336573465735657366573765738657396574065741657426574365744657456574665747657486574965750657516575265753657546575565756657576575865759657606576165762657636576465765657666576765768657696577065771657726577365774657756577665777657786577965780657816578265783657846578565786657876578865789657906579165792657936579465795657966579765798657996580065801658026580365804658056580665807658086580965810658116581265813658146581565816658176581865819658206582165822658236582465825658266582765828658296583065831658326583365834658356583665837658386583965840658416584265843658446584565846658476584865849658506585165852658536585465855658566585765858658596586065861658626586365864658656586665867658686586965870658716587265873658746587565876658776587865879658806588165882658836588465885658866588765888658896589065891658926589365894658956589665897658986589965900659016590265903659046590565906659076590865909659106591165912659136591465915659166591765918659196592065921659226592365924659256592665927659286592965930659316593265933659346593565936659376593865939659406594165942659436594465945659466594765948659496595065951659526595365954659556595665957659586595965960659616596265963659646596565966659676596865969659706597165972659736597465975659766597765978659796598065981659826598365984659856598665987659886598965990659916599265993659946599565996659976599865999660006600166002660036600466005660066600766008660096601066011660126601366014660156601666017660186601966020660216602266023660246602566026660276602866029660306603166032660336603466035660366603766038660396604066041660426604366044660456604666047660486604966050660516605266053660546605566056660576605866059660606606166062660636606466065660666606766068660696607066071660726607366074660756607666077660786607966080660816608266083660846608566086660876608866089660906609166092660936609466095660966609766098660996610066101661026610366104661056610666107661086610966110661116611266113661146611566116661176611866119661206612166122661236612466125661266612766128661296613066131661326613366134661356613666137661386613966140661416614266143661446614566146661476614866149661506615166152661536615466155661566615766158661596616066161661626616366164661656616666167661686616966170661716617266173661746617566176661776617866179661806618166182661836618466185661866618766188661896619066191661926619366194661956619666197661986619966200662016620266203662046620566206662076620866209662106621166212662136621466215662166621766218662196622066221662226622366224662256622666227662286622966230662316623266233662346623566236662376623866239662406624166242662436624466245662466624766248662496625066251662526625366254662556625666257662586625966260662616626266263662646626566266662676626866269662706627166272662736627466275662766627766278662796628066281662826628366284662856628666287662886628966290662916629266293662946629566296662976629866299663006630166302663036630466305663066630766308663096631066311663126631366314663156631666317663186631966320663216632266323663246632566326663276632866329663306633166332663336633466335663366633766338663396634066341663426634366344663456634666347663486634966350663516635266353663546635566356663576635866359663606636166362663636636466365663666636766368663696637066371663726637366374663756637666377663786637966380663816638266383663846638566386663876638866389663906639166392663936639466395663966639766398663996640066401664026640366404664056640666407664086640966410664116641266413664146641566416664176641866419664206642166422664236642466425664266642766428664296643066431664326643366434664356643666437664386643966440664416644266443664446644566446664476644866449664506645166452664536645466455664566645766458664596646066461664626646366464664656646666467664686646966470664716647266473664746647566476664776647866479664806648166482664836648466485664866648766488664896649066491664926649366494664956649666497664986649966500665016650266503665046650566506665076650866509665106651166512665136651466515665166651766518665196652066521665226652366524665256652666527665286652966530665316653266533665346653566536665376653866539665406654166542665436654466545665466654766548665496655066551665526655366554665556655666557665586655966560665616656266563665646656566566665676656866569665706657166572665736657466575665766657766578665796658066581665826658366584665856658666587665886658966590665916659266593665946659566596665976659866599666006660166602666036660466605666066660766608666096661066611666126661366614666156661666617666186661966620666216662266623666246662566626666276662866629666306663166632666336663466635666366663766638666396664066641666426664366644666456664666647666486664966650666516665266653666546665566656666576665866659666606666166662666636666466665666666666766668666696667066671666726667366674666756667666677666786667966680666816668266683666846668566686666876668866689666906669166692666936669466695666966669766698666996670066701667026670366704667056670666707667086670966710667116671266713667146671566716667176671866719667206672166722667236672466725667266672766728667296673066731667326673366734667356673666737667386673966740667416674266743667446674566746667476674866749667506675166752667536675466755667566675766758667596676066761667626676366764667656676666767667686676966770667716677266773667746677566776667776677866779667806678166782667836678466785667866678766788667896679066791667926679366794667956679666797667986679966800668016680266803668046680566806668076680866809668106681166812668136681466815668166681766818668196682066821668226682366824668256682666827668286682966830668316683266833668346683566836668376683866839668406684166842668436684466845668466684766848668496685066851668526685366854668556685666857668586685966860668616686266863668646686566866668676686866869668706687166872668736687466875668766687766878668796688066881668826688366884668856688666887668886688966890668916689266893668946689566896668976689866899669006690166902669036690466905669066690766908669096691066911669126691366914669156691666917669186691966920669216692266923669246692566926669276692866929669306693166932669336693466935669366693766938669396694066941669426694366944669456694666947669486694966950669516695266953669546695566956669576695866959669606696166962669636696466965669666696766968669696697066971669726697366974669756697666977669786697966980669816698266983669846698566986669876698866989669906699166992669936699466995669966699766998669996700067001670026700367004670056700667007670086700967010670116701267013670146701567016670176701867019670206702167022670236702467025670266702767028670296703067031670326703367034670356703667037670386703967040670416704267043670446704567046670476704867049670506705167052670536705467055670566705767058670596706067061670626706367064670656706667067670686706967070670716707267073670746707567076670776707867079670806708167082670836708467085670866708767088670896709067091670926709367094670956709667097670986709967100671016710267103671046710567106671076710867109671106711167112671136711467115671166711767118671196712067121671226712367124671256712667127671286712967130671316713267133671346713567136671376713867139671406714167142671436714467145671466714767148671496715067151671526715367154671556715667157671586715967160671616716267163671646716567166671676716867169671706717167172671736717467175671766717767178671796718067181671826718367184671856718667187671886718967190671916719267193671946719567196671976719867199672006720167202672036720467205672066720767208672096721067211672126721367214672156721667217672186721967220672216722267223672246722567226672276722867229672306723167232672336723467235672366723767238672396724067241672426724367244672456724667247672486724967250672516725267253672546725567256672576725867259672606726167262672636726467265672666726767268672696727067271672726727367274672756727667277672786727967280672816728267283672846728567286672876728867289672906729167292672936729467295672966729767298672996730067301673026730367304673056730667307673086730967310673116731267313673146731567316673176731867319673206732167322673236732467325673266732767328673296733067331673326733367334673356733667337673386733967340673416734267343673446734567346673476734867349673506735167352673536735467355673566735767358673596736067361673626736367364673656736667367673686736967370673716737267373673746737567376673776737867379673806738167382673836738467385673866738767388673896739067391673926739367394673956739667397673986739967400674016740267403674046740567406674076740867409674106741167412674136741467415674166741767418674196742067421674226742367424674256742667427674286742967430674316743267433674346743567436674376743867439674406744167442674436744467445674466744767448674496745067451674526745367454674556745667457674586745967460674616746267463674646746567466674676746867469674706747167472674736747467475674766747767478674796748067481674826748367484674856748667487674886748967490674916749267493674946749567496674976749867499675006750167502675036750467505675066750767508675096751067511675126751367514675156751667517675186751967520675216752267523675246752567526675276752867529675306753167532675336753467535675366753767538675396754067541675426754367544675456754667547675486754967550675516755267553675546755567556675576755867559675606756167562675636756467565675666756767568675696757067571675726757367574675756757667577675786757967580675816758267583675846758567586675876758867589675906759167592675936759467595675966759767598675996760067601676026760367604676056760667607676086760967610676116761267613676146761567616676176761867619676206762167622676236762467625676266762767628676296763067631676326763367634676356763667637676386763967640676416764267643676446764567646676476764867649676506765167652676536765467655676566765767658676596766067661676626766367664676656766667667676686766967670676716767267673676746767567676676776767867679676806768167682676836768467685676866768767688676896769067691676926769367694676956769667697676986769967700677016770267703677046770567706677076770867709677106771167712677136771467715677166771767718677196772067721677226772367724677256772667727677286772967730677316773267733677346773567736677376773867739677406774167742677436774467745677466774767748677496775067751677526775367754677556775667757677586775967760677616776267763677646776567766677676776867769677706777167772677736777467775677766777767778677796778067781677826778367784677856778667787677886778967790677916779267793677946779567796677976779867799678006780167802678036780467805678066780767808678096781067811678126781367814678156781667817678186781967820678216782267823678246782567826678276782867829678306783167832678336783467835678366783767838678396784067841678426784367844678456784667847678486784967850678516785267853678546785567856678576785867859678606786167862678636786467865678666786767868678696787067871678726787367874678756787667877678786787967880678816788267883678846788567886678876788867889678906789167892678936789467895678966789767898678996790067901679026790367904679056790667907679086790967910679116791267913679146791567916679176791867919679206792167922679236792467925679266792767928679296793067931679326793367934679356793667937679386793967940679416794267943679446794567946679476794867949679506795167952679536795467955679566795767958679596796067961679626796367964679656796667967679686796967970679716797267973679746797567976679776797867979679806798167982679836798467985679866798767988679896799067991679926799367994679956799667997679986799968000680016800268003680046800568006680076800868009680106801168012680136801468015680166801768018680196802068021680226802368024680256802668027680286802968030680316803268033680346803568036680376803868039680406804168042680436804468045680466804768048680496805068051680526805368054680556805668057680586805968060680616806268063680646806568066680676806868069680706807168072680736807468075680766807768078680796808068081680826808368084680856808668087680886808968090680916809268093680946809568096680976809868099681006810168102681036810468105681066810768108681096811068111681126811368114681156811668117681186811968120681216812268123681246812568126681276812868129681306813168132681336813468135681366813768138681396814068141681426814368144681456814668147681486814968150681516815268153681546815568156681576815868159681606816168162681636816468165681666816768168681696817068171681726817368174681756817668177681786817968180681816818268183681846818568186681876818868189681906819168192681936819468195681966819768198681996820068201682026820368204682056820668207682086820968210682116821268213682146821568216682176821868219682206822168222682236822468225682266822768228682296823068231682326823368234682356823668237682386823968240682416824268243682446824568246682476824868249682506825168252682536825468255682566825768258682596826068261682626826368264682656826668267682686826968270682716827268273682746827568276682776827868279682806828168282682836828468285682866828768288682896829068291682926829368294682956829668297682986829968300683016830268303683046830568306683076830868309683106831168312683136831468315683166831768318683196832068321683226832368324683256832668327683286832968330683316833268333683346833568336683376833868339683406834168342683436834468345683466834768348683496835068351683526835368354683556835668357683586835968360683616836268363683646836568366683676836868369683706837168372683736837468375683766837768378683796838068381683826838368384683856838668387683886838968390683916839268393683946839568396683976839868399684006840168402684036840468405684066840768408684096841068411684126841368414684156841668417684186841968420684216842268423684246842568426684276842868429684306843168432684336843468435684366843768438684396844068441684426844368444684456844668447684486844968450684516845268453684546845568456684576845868459684606846168462684636846468465684666846768468684696847068471684726847368474684756847668477684786847968480684816848268483684846848568486684876848868489684906849168492684936849468495684966849768498684996850068501685026850368504685056850668507685086850968510685116851268513685146851568516685176851868519685206852168522685236852468525685266852768528685296853068531685326853368534685356853668537685386853968540685416854268543685446854568546685476854868549685506855168552685536855468555685566855768558685596856068561685626856368564685656856668567685686856968570685716857268573685746857568576685776857868579685806858168582685836858468585685866858768588685896859068591685926859368594685956859668597685986859968600686016860268603686046860568606686076860868609686106861168612686136861468615686166861768618686196862068621686226862368624686256862668627686286862968630686316863268633686346863568636686376863868639686406864168642686436864468645686466864768648686496865068651686526865368654686556865668657686586865968660686616866268663686646866568666686676866868669686706867168672686736867468675686766867768678686796868068681686826868368684686856868668687686886868968690686916869268693686946869568696686976869868699687006870168702687036870468705687066870768708687096871068711687126871368714687156871668717687186871968720687216872268723687246872568726687276872868729687306873168732687336873468735687366873768738687396874068741687426874368744687456874668747687486874968750687516875268753687546875568756687576875868759687606876168762687636876468765687666876768768687696877068771687726877368774687756877668777687786877968780687816878268783687846878568786687876878868789687906879168792687936879468795687966879768798687996880068801688026880368804688056880668807688086880968810688116881268813688146881568816688176881868819688206882168822688236882468825688266882768828688296883068831688326883368834688356883668837688386883968840688416884268843688446884568846688476884868849688506885168852688536885468855688566885768858688596886068861688626886368864688656886668867688686886968870688716887268873688746887568876688776887868879688806888168882688836888468885688866888768888688896889068891688926889368894688956889668897688986889968900689016890268903689046890568906689076890868909689106891168912689136891468915689166891768918689196892068921689226892368924689256892668927689286892968930689316893268933689346893568936689376893868939689406894168942689436894468945689466894768948689496895068951689526895368954689556895668957689586895968960689616896268963689646896568966689676896868969689706897168972689736897468975689766897768978689796898068981689826898368984689856898668987689886898968990689916899268993689946899568996689976899868999690006900169002690036900469005690066900769008690096901069011690126901369014690156901669017690186901969020690216902269023690246902569026690276902869029690306903169032690336903469035690366903769038690396904069041690426904369044690456904669047690486904969050690516905269053690546905569056690576905869059690606906169062690636906469065690666906769068690696907069071690726907369074690756907669077690786907969080690816908269083690846908569086690876908869089690906909169092690936909469095690966909769098690996910069101691026910369104691056910669107691086910969110691116911269113691146911569116691176911869119691206912169122691236912469125691266912769128691296913069131691326913369134691356913669137691386913969140691416914269143691446914569146691476914869149691506915169152691536915469155691566915769158691596916069161691626916369164691656916669167691686916969170691716917269173691746917569176691776917869179691806918169182691836918469185691866918769188691896919069191691926919369194691956919669197691986919969200692016920269203692046920569206692076920869209692106921169212692136921469215692166921769218692196922069221692226922369224692256922669227692286922969230692316923269233692346923569236692376923869239692406924169242692436924469245692466924769248692496925069251692526925369254692556925669257692586925969260692616926269263692646926569266692676926869269692706927169272692736927469275692766927769278692796928069281692826928369284692856928669287692886928969290692916929269293692946929569296692976929869299693006930169302693036930469305693066930769308693096931069311693126931369314693156931669317693186931969320693216932269323693246932569326693276932869329693306933169332693336933469335693366933769338693396934069341693426934369344693456934669347693486934969350693516935269353693546935569356693576935869359693606936169362693636936469365693666936769368693696937069371693726937369374693756937669377693786937969380693816938269383693846938569386693876938869389693906939169392693936939469395693966939769398693996940069401694026940369404694056940669407694086940969410694116941269413694146941569416694176941869419694206942169422694236942469425694266942769428694296943069431694326943369434694356943669437694386943969440694416944269443694446944569446694476944869449694506945169452694536945469455694566945769458694596946069461694626946369464694656946669467694686946969470694716947269473694746947569476694776947869479694806948169482694836948469485694866948769488694896949069491694926949369494694956949669497694986949969500695016950269503695046950569506695076950869509695106951169512695136951469515695166951769518695196952069521695226952369524695256952669527695286952969530695316953269533695346953569536695376953869539695406954169542695436954469545695466954769548695496955069551695526955369554695556955669557695586955969560695616956269563695646956569566695676956869569695706957169572695736957469575695766957769578695796958069581695826958369584695856958669587695886958969590695916959269593695946959569596695976959869599696006960169602696036960469605696066960769608696096961069611696126961369614696156961669617696186961969620696216962269623696246962569626696276962869629696306963169632696336963469635696366963769638696396964069641696426964369644696456964669647696486964969650696516965269653696546965569656696576965869659696606966169662696636966469665696666966769668696696967069671696726967369674696756967669677696786967969680696816968269683696846968569686696876968869689696906969169692696936969469695696966969769698696996970069701697026970369704697056970669707697086970969710697116971269713697146971569716697176971869719697206972169722697236972469725697266972769728697296973069731697326973369734697356973669737697386973969740697416974269743697446974569746697476974869749697506975169752697536975469755697566975769758697596976069761697626976369764697656976669767697686976969770697716977269773697746977569776697776977869779697806978169782697836978469785697866978769788697896979069791697926979369794697956979669797697986979969800698016980269803698046980569806698076980869809698106981169812698136981469815698166981769818698196982069821698226982369824698256982669827698286982969830698316983269833698346983569836698376983869839698406984169842698436984469845698466984769848698496985069851698526985369854698556985669857698586985969860698616986269863698646986569866698676986869869698706987169872698736987469875698766987769878698796988069881698826988369884698856988669887698886988969890698916989269893698946989569896698976989869899699006990169902699036990469905699066990769908699096991069911699126991369914699156991669917699186991969920699216992269923699246992569926699276992869929699306993169932699336993469935699366993769938699396994069941699426994369944699456994669947699486994969950699516995269953699546995569956699576995869959699606996169962699636996469965699666996769968699696997069971699726997369974699756997669977699786997969980699816998269983699846998569986699876998869989699906999169992699936999469995699966999769998699997000070001700027000370004700057000670007700087000970010700117001270013700147001570016700177001870019700207002170022700237002470025700267002770028700297003070031700327003370034700357003670037700387003970040700417004270043700447004570046700477004870049700507005170052700537005470055700567005770058700597006070061700627006370064700657006670067700687006970070700717007270073700747007570076700777007870079700807008170082700837008470085700867008770088700897009070091700927009370094700957009670097700987009970100701017010270103701047010570106701077010870109701107011170112701137011470115701167011770118701197012070121701227012370124701257012670127701287012970130701317013270133701347013570136701377013870139701407014170142701437014470145701467014770148701497015070151701527015370154701557015670157701587015970160701617016270163701647016570166701677016870169701707017170172701737017470175701767017770178701797018070181701827018370184701857018670187701887018970190701917019270193701947019570196701977019870199702007020170202702037020470205702067020770208702097021070211702127021370214702157021670217702187021970220702217022270223702247022570226702277022870229702307023170232702337023470235702367023770238702397024070241702427024370244702457024670247702487024970250702517025270253702547025570256702577025870259702607026170262702637026470265702667026770268702697027070271702727027370274702757027670277702787027970280702817028270283702847028570286702877028870289702907029170292702937029470295702967029770298702997030070301703027030370304703057030670307703087030970310703117031270313703147031570316703177031870319703207032170322703237032470325703267032770328703297033070331703327033370334703357033670337703387033970340703417034270343703447034570346703477034870349703507035170352703537035470355703567035770358703597036070361703627036370364703657036670367703687036970370703717037270373703747037570376703777037870379703807038170382703837038470385703867038770388703897039070391703927039370394703957039670397703987039970400704017040270403704047040570406704077040870409704107041170412704137041470415704167041770418704197042070421704227042370424704257042670427704287042970430704317043270433704347043570436704377043870439704407044170442704437044470445704467044770448704497045070451704527045370454704557045670457704587045970460704617046270463704647046570466704677046870469704707047170472704737047470475704767047770478704797048070481704827048370484704857048670487704887048970490704917049270493704947049570496704977049870499705007050170502705037050470505705067050770508705097051070511705127051370514705157051670517705187051970520705217052270523705247052570526705277052870529705307053170532705337053470535705367053770538705397054070541705427054370544705457054670547705487054970550705517055270553705547055570556705577055870559705607056170562705637056470565705667056770568705697057070571705727057370574705757057670577705787057970580705817058270583705847058570586705877058870589705907059170592705937059470595705967059770598705997060070601706027060370604706057060670607706087060970610706117061270613706147061570616706177061870619706207062170622706237062470625706267062770628706297063070631706327063370634706357063670637706387063970640706417064270643706447064570646706477064870649706507065170652706537065470655706567065770658706597066070661706627066370664706657066670667706687066970670706717067270673706747067570676706777067870679706807068170682706837068470685706867068770688706897069070691706927069370694706957069670697706987069970700707017070270703707047070570706707077070870709707107071170712707137071470715707167071770718707197072070721707227072370724707257072670727707287072970730707317073270733707347073570736707377073870739707407074170742707437074470745707467074770748707497075070751707527075370754707557075670757707587075970760707617076270763707647076570766707677076870769707707077170772707737077470775707767077770778707797078070781707827078370784707857078670787707887078970790707917079270793707947079570796707977079870799708007080170802708037080470805708067080770808708097081070811708127081370814708157081670817708187081970820708217082270823708247082570826708277082870829708307083170832708337083470835708367083770838708397084070841708427084370844708457084670847708487084970850708517085270853708547085570856708577085870859708607086170862708637086470865708667086770868708697087070871708727087370874708757087670877708787087970880708817088270883708847088570886708877088870889708907089170892708937089470895708967089770898708997090070901709027090370904709057090670907709087090970910709117091270913709147091570916709177091870919709207092170922709237092470925709267092770928709297093070931709327093370934709357093670937709387093970940709417094270943709447094570946709477094870949709507095170952709537095470955709567095770958709597096070961709627096370964709657096670967709687096970970709717097270973709747097570976709777097870979709807098170982709837098470985709867098770988709897099070991709927099370994709957099670997709987099971000710017100271003710047100571006710077100871009710107101171012710137101471015710167101771018710197102071021710227102371024710257102671027710287102971030710317103271033710347103571036710377103871039710407104171042710437104471045710467104771048710497105071051710527105371054710557105671057710587105971060710617106271063710647106571066710677106871069710707107171072710737107471075710767107771078710797108071081710827108371084710857108671087710887108971090710917109271093710947109571096710977109871099711007110171102711037110471105711067110771108711097111071111711127111371114711157111671117711187111971120711217112271123711247112571126711277112871129711307113171132711337113471135711367113771138711397114071141711427114371144711457114671147711487114971150711517115271153711547115571156711577115871159711607116171162711637116471165711667116771168711697117071171711727117371174711757117671177711787117971180711817118271183711847118571186711877118871189711907119171192711937119471195711967119771198711997120071201712027120371204712057120671207712087120971210712117121271213712147121571216712177121871219712207122171222712237122471225712267122771228712297123071231712327123371234712357123671237712387123971240712417124271243712447124571246712477124871249712507125171252712537125471255712567125771258712597126071261712627126371264712657126671267712687126971270712717127271273712747127571276712777127871279712807128171282712837128471285712867128771288712897129071291712927129371294712957129671297712987129971300713017130271303713047130571306713077130871309713107131171312713137131471315713167131771318713197132071321713227132371324713257132671327713287132971330713317133271333713347133571336713377133871339713407134171342713437134471345713467134771348713497135071351713527135371354713557135671357713587135971360713617136271363713647136571366713677136871369713707137171372713737137471375713767137771378713797138071381713827138371384713857138671387713887138971390713917139271393713947139571396713977139871399714007140171402714037140471405714067140771408714097141071411714127141371414714157141671417714187141971420714217142271423714247142571426714277142871429714307143171432714337143471435714367143771438714397144071441714427144371444714457144671447714487144971450714517145271453714547145571456714577145871459714607146171462714637146471465714667146771468714697147071471714727147371474714757147671477714787147971480714817148271483714847148571486714877148871489714907149171492714937149471495714967149771498714997150071501715027150371504715057150671507715087150971510715117151271513715147151571516715177151871519715207152171522715237152471525715267152771528715297153071531715327153371534715357153671537715387153971540715417154271543715447154571546715477154871549715507155171552715537155471555715567155771558715597156071561715627156371564715657156671567715687156971570715717157271573715747157571576715777157871579715807158171582715837158471585715867158771588715897159071591715927159371594715957159671597715987159971600716017160271603716047160571606716077160871609716107161171612716137161471615716167161771618716197162071621716227162371624716257162671627716287162971630716317163271633716347163571636716377163871639716407164171642716437164471645716467164771648716497165071651716527165371654716557165671657716587165971660716617166271663716647166571666716677166871669716707167171672716737167471675716767167771678716797168071681716827168371684716857168671687716887168971690716917169271693716947169571696716977169871699717007170171702717037170471705717067170771708717097171071711717127171371714717157171671717717187171971720717217172271723717247172571726717277172871729717307173171732717337173471735717367173771738717397174071741717427174371744717457174671747717487174971750717517175271753717547175571756717577175871759717607176171762717637176471765717667176771768717697177071771717727177371774717757177671777717787177971780717817178271783717847178571786717877178871789717907179171792717937179471795717967179771798717997180071801718027180371804718057180671807718087180971810718117181271813718147181571816718177181871819718207182171822718237182471825718267182771828718297183071831718327183371834718357183671837718387183971840718417184271843718447184571846718477184871849718507185171852718537185471855718567185771858718597186071861718627186371864718657186671867718687186971870718717187271873718747187571876718777187871879718807188171882718837188471885718867188771888718897189071891718927189371894718957189671897718987189971900719017190271903719047190571906719077190871909719107191171912719137191471915719167191771918719197192071921719227192371924719257192671927719287192971930719317193271933719347193571936719377193871939719407194171942719437194471945719467194771948719497195071951719527195371954719557195671957719587195971960719617196271963719647196571966719677196871969719707197171972719737197471975719767197771978719797198071981719827198371984719857198671987719887198971990719917199271993719947199571996719977199871999720007200172002720037200472005720067200772008720097201072011720127201372014720157201672017720187201972020720217202272023720247202572026720277202872029720307203172032720337203472035720367203772038720397204072041720427204372044720457204672047720487204972050720517205272053720547205572056720577205872059720607206172062720637206472065720667206772068720697207072071720727207372074720757207672077720787207972080720817208272083720847208572086720877208872089720907209172092720937209472095720967209772098720997210072101721027210372104721057210672107721087210972110721117211272113721147211572116721177211872119721207212172122721237212472125721267212772128721297213072131721327213372134721357213672137721387213972140721417214272143721447214572146721477214872149721507215172152721537215472155721567215772158721597216072161721627216372164721657216672167721687216972170721717217272173721747217572176721777217872179721807218172182721837218472185721867218772188721897219072191721927219372194721957219672197721987219972200722017220272203722047220572206722077220872209722107221172212722137221472215722167221772218722197222072221722227222372224722257222672227722287222972230722317223272233722347223572236722377223872239722407224172242722437224472245722467224772248722497225072251722527225372254722557225672257722587225972260722617226272263722647226572266722677226872269722707227172272722737227472275722767227772278722797228072281722827228372284722857228672287722887228972290722917229272293722947229572296722977229872299723007230172302723037230472305723067230772308723097231072311723127231372314723157231672317723187231972320723217232272323723247232572326723277232872329723307233172332723337233472335723367233772338723397234072341723427234372344723457234672347723487234972350723517235272353723547235572356723577235872359723607236172362723637236472365723667236772368723697237072371723727237372374723757237672377723787237972380723817238272383723847238572386723877238872389723907239172392723937239472395723967239772398723997240072401724027240372404724057240672407724087240972410724117241272413724147241572416724177241872419724207242172422724237242472425724267242772428724297243072431724327243372434724357243672437724387243972440724417244272443724447244572446724477244872449724507245172452724537245472455724567245772458724597246072461724627246372464724657246672467724687246972470724717247272473724747247572476724777247872479724807248172482724837248472485724867248772488724897249072491724927249372494724957249672497724987249972500725017250272503725047250572506725077250872509725107251172512725137251472515725167251772518725197252072521725227252372524725257252672527725287252972530725317253272533725347253572536725377253872539725407254172542725437254472545725467254772548725497255072551725527255372554725557255672557725587255972560725617256272563725647256572566725677256872569725707257172572725737257472575725767257772578725797258072581725827258372584725857258672587725887258972590725917259272593725947259572596725977259872599726007260172602726037260472605726067260772608726097261072611726127261372614726157261672617726187261972620726217262272623726247262572626726277262872629726307263172632726337263472635726367263772638726397264072641726427264372644726457264672647726487264972650726517265272653726547265572656726577265872659726607266172662726637266472665726667266772668726697267072671726727267372674726757267672677726787267972680726817268272683726847268572686726877268872689726907269172692726937269472695726967269772698726997270072701727027270372704727057270672707727087270972710727117271272713727147271572716727177271872719727207272172722727237272472725727267272772728727297273072731727327273372734727357273672737727387273972740727417274272743727447274572746727477274872749727507275172752727537275472755727567275772758727597276072761727627276372764727657276672767727687276972770727717277272773727747277572776727777277872779727807278172782727837278472785727867278772788727897279072791727927279372794727957279672797727987279972800728017280272803728047280572806728077280872809728107281172812728137281472815728167281772818728197282072821728227282372824728257282672827728287282972830728317283272833728347283572836728377283872839728407284172842728437284472845728467284772848728497285072851728527285372854728557285672857728587285972860728617286272863728647286572866728677286872869728707287172872728737287472875728767287772878728797288072881728827288372884728857288672887728887288972890728917289272893728947289572896728977289872899729007290172902729037290472905729067290772908729097291072911729127291372914729157291672917729187291972920729217292272923729247292572926729277292872929729307293172932729337293472935729367293772938729397294072941729427294372944729457294672947729487294972950729517295272953729547295572956729577295872959729607296172962729637296472965729667296772968729697297072971729727297372974729757297672977729787297972980729817298272983729847298572986729877298872989729907299172992729937299472995729967299772998729997300073001730027300373004730057300673007730087300973010730117301273013730147301573016730177301873019730207302173022730237302473025730267302773028730297303073031730327303373034730357303673037730387303973040730417304273043730447304573046730477304873049730507305173052730537305473055730567305773058730597306073061730627306373064730657306673067730687306973070730717307273073730747307573076730777307873079730807308173082730837308473085730867308773088730897309073091730927309373094730957309673097730987309973100731017310273103731047310573106731077310873109731107311173112731137311473115731167311773118731197312073121731227312373124731257312673127731287312973130731317313273133731347313573136731377313873139731407314173142731437314473145731467314773148731497315073151731527315373154731557315673157731587315973160731617316273163731647316573166731677316873169731707317173172731737317473175731767317773178731797318073181731827318373184731857318673187731887318973190731917319273193731947319573196731977319873199732007320173202732037320473205732067320773208732097321073211732127321373214732157321673217732187321973220732217322273223732247322573226732277322873229732307323173232732337323473235732367323773238732397324073241732427324373244732457324673247732487324973250732517325273253732547325573256732577325873259732607326173262732637326473265732667326773268732697327073271732727327373274732757327673277732787327973280732817328273283732847328573286732877328873289732907329173292732937329473295732967329773298732997330073301733027330373304733057330673307733087330973310733117331273313733147331573316733177331873319733207332173322733237332473325733267332773328733297333073331733327333373334733357333673337733387333973340733417334273343733447334573346733477334873349733507335173352733537335473355733567335773358733597336073361733627336373364733657336673367733687336973370733717337273373733747337573376733777337873379733807338173382733837338473385733867338773388733897339073391733927339373394733957339673397733987339973400734017340273403734047340573406734077340873409734107341173412734137341473415734167341773418734197342073421734227342373424734257342673427734287342973430734317343273433734347343573436734377343873439734407344173442734437344473445734467344773448734497345073451734527345373454734557345673457734587345973460734617346273463734647346573466734677346873469734707347173472734737347473475734767347773478734797348073481734827348373484734857348673487734887348973490734917349273493734947349573496734977349873499735007350173502735037350473505735067350773508735097351073511735127351373514735157351673517735187351973520735217352273523735247352573526735277352873529735307353173532735337353473535735367353773538735397354073541735427354373544735457354673547735487354973550735517355273553735547355573556735577355873559735607356173562735637356473565735667356773568735697357073571735727357373574735757357673577735787357973580735817358273583735847358573586735877358873589735907359173592735937359473595735967359773598735997360073601736027360373604736057360673607736087360973610736117361273613736147361573616736177361873619736207362173622736237362473625736267362773628736297363073631736327363373634736357363673637736387363973640736417364273643736447364573646736477364873649736507365173652736537365473655736567365773658736597366073661736627366373664736657366673667736687366973670736717367273673736747367573676736777367873679736807368173682736837368473685736867368773688736897369073691736927369373694736957369673697736987369973700737017370273703737047370573706737077370873709737107371173712737137371473715737167371773718737197372073721737227372373724737257372673727737287372973730737317373273733737347373573736737377373873739737407374173742737437374473745737467374773748737497375073751737527375373754737557375673757737587375973760737617376273763737647376573766737677376873769737707377173772737737377473775737767377773778737797378073781737827378373784737857378673787737887378973790737917379273793737947379573796737977379873799738007380173802738037380473805738067380773808738097381073811738127381373814738157381673817738187381973820738217382273823738247382573826738277382873829738307383173832738337383473835738367383773838738397384073841738427384373844738457384673847738487384973850738517385273853738547385573856738577385873859738607386173862738637386473865738667386773868738697387073871738727387373874738757387673877738787387973880738817388273883738847388573886738877388873889738907389173892738937389473895738967389773898738997390073901739027390373904739057390673907739087390973910739117391273913739147391573916739177391873919739207392173922739237392473925739267392773928739297393073931739327393373934739357393673937739387393973940739417394273943739447394573946739477394873949739507395173952739537395473955739567395773958739597396073961739627396373964739657396673967739687396973970739717397273973739747397573976739777397873979739807398173982739837398473985739867398773988739897399073991739927399373994739957399673997739987399974000740017400274003740047400574006740077400874009740107401174012740137401474015740167401774018740197402074021740227402374024740257402674027740287402974030740317403274033740347403574036740377403874039740407404174042740437404474045740467404774048740497405074051740527405374054740557405674057740587405974060740617406274063740647406574066740677406874069740707407174072740737407474075740767407774078740797408074081740827408374084740857408674087740887408974090740917409274093740947409574096740977409874099741007410174102741037410474105741067410774108741097411074111741127411374114741157411674117741187411974120741217412274123741247412574126741277412874129741307413174132741337413474135741367413774138741397414074141741427414374144741457414674147741487414974150741517415274153741547415574156741577415874159741607416174162741637416474165741667416774168741697417074171741727417374174741757417674177741787417974180741817418274183741847418574186741877418874189741907419174192741937419474195741967419774198741997420074201742027420374204742057420674207742087420974210742117421274213742147421574216742177421874219742207422174222742237422474225742267422774228742297423074231742327423374234742357423674237742387423974240742417424274243742447424574246742477424874249742507425174252742537425474255742567425774258742597426074261742627426374264742657426674267742687426974270742717427274273742747427574276742777427874279742807428174282742837428474285742867428774288742897429074291742927429374294742957429674297742987429974300743017430274303743047430574306743077430874309743107431174312743137431474315743167431774318743197432074321743227432374324743257432674327743287432974330743317433274333743347433574336743377433874339743407434174342743437434474345743467434774348743497435074351743527435374354743557435674357743587435974360743617436274363743647436574366743677436874369743707437174372743737437474375743767437774378743797438074381743827438374384743857438674387743887438974390743917439274393743947439574396743977439874399744007440174402744037440474405744067440774408744097441074411744127441374414744157441674417744187441974420744217442274423744247442574426744277442874429744307443174432744337443474435744367443774438744397444074441744427444374444744457444674447744487444974450744517445274453744547445574456744577445874459744607446174462744637446474465744667446774468744697447074471744727447374474744757447674477744787447974480744817448274483744847448574486744877448874489744907449174492744937449474495744967449774498744997450074501745027450374504745057450674507745087450974510745117451274513745147451574516745177451874519745207452174522745237452474525745267452774528745297453074531745327453374534745357453674537745387453974540745417454274543745447454574546745477454874549745507455174552745537455474555745567455774558745597456074561745627456374564745657456674567745687456974570745717457274573745747457574576745777457874579745807458174582745837458474585745867458774588745897459074591745927459374594745957459674597745987459974600746017460274603746047460574606746077460874609746107461174612746137461474615746167461774618746197462074621746227462374624746257462674627746287462974630746317463274633746347463574636746377463874639746407464174642746437464474645746467464774648746497465074651746527465374654746557465674657746587465974660746617466274663746647466574666746677466874669746707467174672746737467474675746767467774678746797468074681746827468374684746857468674687746887468974690746917469274693746947469574696746977469874699747007470174702747037470474705747067470774708747097471074711747127471374714747157471674717747187471974720747217472274723747247472574726747277472874729747307473174732747337473474735747367473774738747397474074741747427474374744747457474674747747487474974750747517475274753747547475574756747577475874759747607476174762747637476474765747667476774768747697477074771747727477374774747757477674777747787477974780747817478274783747847478574786747877478874789747907479174792747937479474795747967479774798747997480074801748027480374804748057480674807748087480974810748117481274813748147481574816748177481874819748207482174822748237482474825748267482774828748297483074831748327483374834748357483674837748387483974840748417484274843748447484574846748477484874849748507485174852748537485474855748567485774858748597486074861748627486374864748657486674867748687486974870748717487274873748747487574876748777487874879748807488174882748837488474885748867488774888748897489074891748927489374894748957489674897748987489974900749017490274903749047490574906749077490874909749107491174912749137491474915749167491774918749197492074921749227492374924749257492674927749287492974930749317493274933749347493574936749377493874939749407494174942749437494474945749467494774948749497495074951749527495374954749557495674957749587495974960749617496274963749647496574966749677496874969749707497174972749737497474975749767497774978749797498074981749827498374984749857498674987749887498974990749917499274993749947499574996749977499874999750007500175002750037500475005750067500775008750097501075011750127501375014750157501675017750187501975020750217502275023750247502575026750277502875029750307503175032750337503475035750367503775038750397504075041750427504375044750457504675047750487504975050750517505275053750547505575056750577505875059750607506175062750637506475065750667506775068750697507075071750727507375074750757507675077750787507975080750817508275083750847508575086750877508875089750907509175092750937509475095750967509775098750997510075101751027510375104751057510675107751087510975110751117511275113751147511575116751177511875119751207512175122751237512475125751267512775128751297513075131751327513375134751357513675137751387513975140751417514275143751447514575146751477514875149751507515175152751537515475155751567515775158751597516075161751627516375164751657516675167751687516975170751717517275173751747517575176751777517875179751807518175182751837518475185751867518775188751897519075191751927519375194751957519675197751987519975200752017520275203752047520575206752077520875209752107521175212752137521475215752167521775218752197522075221752227522375224752257522675227752287522975230752317523275233752347523575236752377523875239752407524175242752437524475245752467524775248752497525075251752527525375254752557525675257752587525975260752617526275263752647526575266752677526875269752707527175272752737527475275752767527775278752797528075281752827528375284752857528675287752887528975290752917529275293752947529575296752977529875299753007530175302753037530475305753067530775308753097531075311753127531375314753157531675317753187531975320753217532275323753247532575326753277532875329753307533175332753337533475335753367533775338753397534075341753427534375344753457534675347753487534975350753517535275353753547535575356753577535875359753607536175362753637536475365753667536775368753697537075371753727537375374753757537675377753787537975380753817538275383753847538575386753877538875389753907539175392753937539475395753967539775398753997540075401754027540375404754057540675407754087540975410754117541275413754147541575416754177541875419754207542175422754237542475425754267542775428754297543075431754327543375434754357543675437754387543975440754417544275443754447544575446754477544875449754507545175452754537545475455754567545775458754597546075461754627546375464754657546675467754687546975470754717547275473754747547575476754777547875479754807548175482754837548475485754867548775488754897549075491754927549375494754957549675497754987549975500755017550275503755047550575506755077550875509755107551175512755137551475515755167551775518755197552075521755227552375524755257552675527755287552975530755317553275533755347553575536755377553875539755407554175542755437554475545755467554775548755497555075551755527555375554755557555675557755587555975560755617556275563755647556575566755677556875569755707557175572755737557475575755767557775578755797558075581755827558375584755857558675587755887558975590755917559275593755947559575596755977559875599756007560175602756037560475605756067560775608756097561075611756127561375614756157561675617756187561975620756217562275623756247562575626756277562875629756307563175632756337563475635756367563775638756397564075641756427564375644756457564675647756487564975650756517565275653756547565575656756577565875659756607566175662756637566475665756667566775668756697567075671756727567375674756757567675677756787567975680756817568275683756847568575686756877568875689756907569175692756937569475695756967569775698756997570075701757027570375704757057570675707757087570975710757117571275713757147571575716757177571875719757207572175722757237572475725757267572775728757297573075731757327573375734757357573675737757387573975740757417574275743757447574575746757477574875749757507575175752757537575475755757567575775758757597576075761757627576375764757657576675767757687576975770757717577275773757747577575776757777577875779757807578175782757837578475785757867578775788757897579075791757927579375794757957579675797757987579975800758017580275803758047580575806758077580875809758107581175812758137581475815758167581775818758197582075821758227582375824758257582675827758287582975830758317583275833758347583575836758377583875839758407584175842758437584475845758467584775848758497585075851758527585375854758557585675857758587585975860758617586275863758647586575866758677586875869758707587175872758737587475875758767587775878758797588075881758827588375884758857588675887758887588975890758917589275893758947589575896758977589875899759007590175902759037590475905759067590775908759097591075911759127591375914759157591675917759187591975920759217592275923759247592575926759277592875929759307593175932759337593475935759367593775938759397594075941759427594375944759457594675947759487594975950759517595275953759547595575956759577595875959759607596175962759637596475965759667596775968759697597075971759727597375974759757597675977759787597975980759817598275983759847598575986759877598875989759907599175992759937599475995759967599775998759997600076001760027600376004760057600676007760087600976010760117601276013760147601576016760177601876019760207602176022760237602476025760267602776028760297603076031760327603376034760357603676037760387603976040760417604276043760447604576046760477604876049760507605176052760537605476055760567605776058760597606076061760627606376064760657606676067760687606976070760717607276073760747607576076760777607876079760807608176082760837608476085760867608776088760897609076091760927609376094760957609676097760987609976100761017610276103761047610576106761077610876109761107611176112761137611476115761167611776118761197612076121761227612376124761257612676127761287612976130761317613276133761347613576136761377613876139761407614176142761437614476145761467614776148761497615076151761527615376154761557615676157761587615976160761617616276163761647616576166761677616876169761707617176172761737617476175761767617776178761797618076181761827618376184761857618676187761887618976190761917619276193761947619576196761977619876199762007620176202762037620476205762067620776208762097621076211762127621376214762157621676217762187621976220762217622276223762247622576226762277622876229762307623176232762337623476235762367623776238762397624076241762427624376244762457624676247762487624976250762517625276253762547625576256762577625876259762607626176262762637626476265762667626776268762697627076271762727627376274762757627676277762787627976280762817628276283762847628576286762877628876289762907629176292762937629476295762967629776298762997630076301763027630376304763057630676307763087630976310763117631276313763147631576316763177631876319763207632176322763237632476325763267632776328763297633076331763327633376334763357633676337763387633976340763417634276343763447634576346763477634876349763507635176352763537635476355763567635776358763597636076361763627636376364763657636676367763687636976370763717637276373763747637576376763777637876379763807638176382763837638476385763867638776388763897639076391763927639376394763957639676397763987639976400764017640276403764047640576406764077640876409764107641176412764137641476415764167641776418764197642076421764227642376424764257642676427764287642976430764317643276433764347643576436764377643876439764407644176442764437644476445764467644776448764497645076451764527645376454764557645676457764587645976460764617646276463764647646576466764677646876469764707647176472764737647476475764767647776478764797648076481764827648376484764857648676487764887648976490764917649276493764947649576496764977649876499765007650176502765037650476505765067650776508765097651076511765127651376514765157651676517765187651976520765217652276523765247652576526765277652876529765307653176532765337653476535765367653776538765397654076541765427654376544765457654676547765487654976550765517655276553765547655576556765577655876559765607656176562765637656476565765667656776568765697657076571765727657376574765757657676577765787657976580765817658276583765847658576586765877658876589765907659176592765937659476595765967659776598765997660076601766027660376604766057660676607766087660976610766117661276613766147661576616766177661876619766207662176622766237662476625766267662776628766297663076631766327663376634766357663676637766387663976640766417664276643766447664576646766477664876649766507665176652766537665476655766567665776658766597666076661766627666376664766657666676667766687666976670766717667276673766747667576676766777667876679766807668176682766837668476685766867668776688766897669076691766927669376694766957669676697766987669976700767017670276703767047670576706767077670876709767107671176712767137671476715767167671776718767197672076721767227672376724767257672676727767287672976730767317673276733767347673576736767377673876739767407674176742767437674476745767467674776748767497675076751767527675376754767557675676757767587675976760767617676276763767647676576766767677676876769767707677176772767737677476775767767677776778767797678076781767827678376784767857678676787767887678976790767917679276793767947679576796767977679876799768007680176802768037680476805768067680776808768097681076811768127681376814768157681676817768187681976820768217682276823768247682576826768277682876829768307683176832768337683476835768367683776838768397684076841768427684376844768457684676847768487684976850768517685276853768547685576856768577685876859768607686176862768637686476865768667686776868768697687076871768727687376874768757687676877768787687976880768817688276883768847688576886768877688876889768907689176892768937689476895768967689776898768997690076901769027690376904769057690676907769087690976910769117691276913769147691576916769177691876919769207692176922769237692476925769267692776928769297693076931769327693376934769357693676937769387693976940769417694276943769447694576946769477694876949769507695176952769537695476955769567695776958769597696076961769627696376964769657696676967769687696976970769717697276973769747697576976769777697876979769807698176982769837698476985769867698776988769897699076991769927699376994769957699676997769987699977000770017700277003770047700577006770077700877009770107701177012770137701477015770167701777018770197702077021770227702377024770257702677027770287702977030770317703277033770347703577036770377703877039770407704177042770437704477045770467704777048770497705077051770527705377054770557705677057770587705977060770617706277063770647706577066770677706877069770707707177072770737707477075770767707777078770797708077081770827708377084770857708677087770887708977090770917709277093770947709577096770977709877099771007710177102771037710477105771067710777108771097711077111771127711377114771157711677117771187711977120771217712277123771247712577126771277712877129771307713177132771337713477135771367713777138771397714077141771427714377144771457714677147771487714977150771517715277153771547715577156771577715877159771607716177162771637716477165771667716777168771697717077171771727717377174771757717677177771787717977180771817718277183771847718577186771877718877189771907719177192771937719477195771967719777198771997720077201772027720377204772057720677207772087720977210772117721277213772147721577216772177721877219772207722177222772237722477225772267722777228772297723077231772327723377234772357723677237772387723977240772417724277243772447724577246772477724877249772507725177252772537725477255772567725777258772597726077261772627726377264772657726677267772687726977270772717727277273772747727577276772777727877279772807728177282772837728477285772867728777288772897729077291772927729377294772957729677297772987729977300773017730277303773047730577306773077730877309773107731177312773137731477315773167731777318773197732077321773227732377324773257732677327773287732977330773317733277333773347733577336773377733877339773407734177342773437734477345773467734777348773497735077351773527735377354773557735677357773587735977360773617736277363773647736577366773677736877369773707737177372773737737477375773767737777378773797738077381773827738377384773857738677387773887738977390773917739277393773947739577396773977739877399774007740177402774037740477405774067740777408774097741077411774127741377414774157741677417774187741977420774217742277423774247742577426774277742877429774307743177432774337743477435774367743777438774397744077441774427744377444774457744677447774487744977450774517745277453774547745577456774577745877459774607746177462774637746477465774667746777468774697747077471774727747377474774757747677477774787747977480774817748277483774847748577486774877748877489774907749177492774937749477495774967749777498
  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 mip = nearest */
  772. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  773. /** Bilinear is mag = linear and min = linear and mip = nearest */
  774. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  775. /** Trilinear is mag = linear and min = linear and mip = linear */
  776. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  777. /** nearest is mag = nearest and min = nearest and mip = linear */
  778. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  779. /** Bilinear is mag = linear and min = linear and mip = nearest */
  780. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: 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. /** mag = nearest and min = nearest and mip = none */
  792. static readonly TEXTURE_NEAREST_NEAREST: 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. /** mag = linear and min = linear and mip = none */
  798. static readonly TEXTURE_LINEAR_LINEAR: 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: string | ArrayBuffer | (string | ArrayBuffer)[], 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: ArrayBuffer, 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. }
  1466. declare module BABYLON {
  1467. /**
  1468. * @hidden
  1469. */
  1470. export interface IColor4Like {
  1471. r: float;
  1472. g: float;
  1473. b: float;
  1474. a: float;
  1475. }
  1476. /**
  1477. * @hidden
  1478. */
  1479. export interface IColor3Like {
  1480. r: float;
  1481. g: float;
  1482. b: float;
  1483. }
  1484. /**
  1485. * @hidden
  1486. */
  1487. export interface IVector4Like {
  1488. x: float;
  1489. y: float;
  1490. z: float;
  1491. w: float;
  1492. }
  1493. /**
  1494. * @hidden
  1495. */
  1496. export interface IVector3Like {
  1497. x: float;
  1498. y: float;
  1499. z: float;
  1500. }
  1501. /**
  1502. * @hidden
  1503. */
  1504. export interface IVector2Like {
  1505. x: float;
  1506. y: float;
  1507. }
  1508. /**
  1509. * @hidden
  1510. */
  1511. export interface IMatrixLike {
  1512. toArray(): DeepImmutable<Float32Array>;
  1513. updateFlag: int;
  1514. }
  1515. /**
  1516. * @hidden
  1517. */
  1518. export interface IViewportLike {
  1519. x: float;
  1520. y: float;
  1521. width: float;
  1522. height: float;
  1523. }
  1524. /**
  1525. * @hidden
  1526. */
  1527. export interface IPlaneLike {
  1528. normal: IVector3Like;
  1529. d: float;
  1530. normalize(): void;
  1531. }
  1532. }
  1533. declare module BABYLON {
  1534. /**
  1535. * Interface used to define common properties for effect fallbacks
  1536. */
  1537. export interface IEffectFallbacks {
  1538. /**
  1539. * Removes the defines that should be removed when falling back.
  1540. * @param currentDefines defines the current define statements for the shader.
  1541. * @param effect defines the current effect we try to compile
  1542. * @returns The resulting defines with defines of the current rank removed.
  1543. */
  1544. reduce(currentDefines: string, effect: Effect): string;
  1545. /**
  1546. * Removes the fallback from the bound mesh.
  1547. */
  1548. unBindMesh(): void;
  1549. /**
  1550. * Checks to see if more fallbacks are still availible.
  1551. */
  1552. hasMoreFallbacks: boolean;
  1553. }
  1554. }
  1555. declare module BABYLON {
  1556. /**
  1557. * Class used to evalaute queries containing `and` and `or` operators
  1558. */
  1559. export class AndOrNotEvaluator {
  1560. /**
  1561. * Evaluate a query
  1562. * @param query defines the query to evaluate
  1563. * @param evaluateCallback defines the callback used to filter result
  1564. * @returns true if the query matches
  1565. */
  1566. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1567. private static _HandleParenthesisContent;
  1568. private static _SimplifyNegation;
  1569. }
  1570. }
  1571. declare module BABYLON {
  1572. /**
  1573. * Class used to store custom tags
  1574. */
  1575. export class Tags {
  1576. /**
  1577. * Adds support for tags on the given object
  1578. * @param obj defines the object to use
  1579. */
  1580. static EnableFor(obj: any): void;
  1581. /**
  1582. * Removes tags support
  1583. * @param obj defines the object to use
  1584. */
  1585. static DisableFor(obj: any): void;
  1586. /**
  1587. * Gets a boolean indicating if the given object has tags
  1588. * @param obj defines the object to use
  1589. * @returns a boolean
  1590. */
  1591. static HasTags(obj: any): boolean;
  1592. /**
  1593. * Gets the tags available on a given object
  1594. * @param obj defines the object to use
  1595. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1596. * @returns the tags
  1597. */
  1598. static GetTags(obj: any, asString?: boolean): any;
  1599. /**
  1600. * Adds tags to an object
  1601. * @param obj defines the object to use
  1602. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1603. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1604. */
  1605. static AddTagsTo(obj: any, tagsString: string): void;
  1606. /**
  1607. * @hidden
  1608. */
  1609. static _AddTagTo(obj: any, tag: string): void;
  1610. /**
  1611. * Removes specific tags from a specific object
  1612. * @param obj defines the object to use
  1613. * @param tagsString defines the tags to remove
  1614. */
  1615. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1616. /**
  1617. * @hidden
  1618. */
  1619. static _RemoveTagFrom(obj: any, tag: string): void;
  1620. /**
  1621. * Defines if tags hosted on an object match a given query
  1622. * @param obj defines the object to use
  1623. * @param tagsQuery defines the tag query
  1624. * @returns a boolean
  1625. */
  1626. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1627. }
  1628. }
  1629. declare module BABYLON {
  1630. /**
  1631. * Scalar computation library
  1632. */
  1633. export class Scalar {
  1634. /**
  1635. * Two pi constants convenient for computation.
  1636. */
  1637. static TwoPi: number;
  1638. /**
  1639. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1640. * @param a number
  1641. * @param b number
  1642. * @param epsilon (default = 1.401298E-45)
  1643. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1644. */
  1645. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1646. /**
  1647. * Returns a string : the upper case translation of the number i to hexadecimal.
  1648. * @param i number
  1649. * @returns the upper case translation of the number i to hexadecimal.
  1650. */
  1651. static ToHex(i: number): string;
  1652. /**
  1653. * Returns -1 if value is negative and +1 is value is positive.
  1654. * @param value the value
  1655. * @returns the value itself if it's equal to zero.
  1656. */
  1657. static Sign(value: number): number;
  1658. /**
  1659. * Returns the value itself if it's between min and max.
  1660. * Returns min if the value is lower than min.
  1661. * Returns max if the value is greater than max.
  1662. * @param value the value to clmap
  1663. * @param min the min value to clamp to (default: 0)
  1664. * @param max the max value to clamp to (default: 1)
  1665. * @returns the clamped value
  1666. */
  1667. static Clamp(value: number, min?: number, max?: number): number;
  1668. /**
  1669. * the log2 of value.
  1670. * @param value the value to compute log2 of
  1671. * @returns the log2 of value.
  1672. */
  1673. static Log2(value: number): number;
  1674. /**
  1675. * Loops the value, so that it is never larger than length and never smaller than 0.
  1676. *
  1677. * This is similar to the modulo operator but it works with floating point numbers.
  1678. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1679. * With t = 5 and length = 2.5, the result would be 0.0.
  1680. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1681. * @param value the value
  1682. * @param length the length
  1683. * @returns the looped value
  1684. */
  1685. static Repeat(value: number, length: number): number;
  1686. /**
  1687. * Normalize the value between 0.0 and 1.0 using min and max values
  1688. * @param value value to normalize
  1689. * @param min max to normalize between
  1690. * @param max min to normalize between
  1691. * @returns the normalized value
  1692. */
  1693. static Normalize(value: number, min: number, max: number): number;
  1694. /**
  1695. * Denormalize the value from 0.0 and 1.0 using min and max values
  1696. * @param normalized value to denormalize
  1697. * @param min max to denormalize between
  1698. * @param max min to denormalize between
  1699. * @returns the denormalized value
  1700. */
  1701. static Denormalize(normalized: number, min: number, max: number): number;
  1702. /**
  1703. * Calculates the shortest difference between two given angles given in degrees.
  1704. * @param current current angle in degrees
  1705. * @param target target angle in degrees
  1706. * @returns the delta
  1707. */
  1708. static DeltaAngle(current: number, target: number): number;
  1709. /**
  1710. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1711. * @param tx value
  1712. * @param length length
  1713. * @returns The returned value will move back and forth between 0 and length
  1714. */
  1715. static PingPong(tx: number, length: number): number;
  1716. /**
  1717. * Interpolates between min and max with smoothing at the limits.
  1718. *
  1719. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1720. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1721. * @param from from
  1722. * @param to to
  1723. * @param tx value
  1724. * @returns the smooth stepped value
  1725. */
  1726. static SmoothStep(from: number, to: number, tx: number): number;
  1727. /**
  1728. * Moves a value current towards target.
  1729. *
  1730. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1731. * Negative values of maxDelta pushes the value away from target.
  1732. * @param current current value
  1733. * @param target target value
  1734. * @param maxDelta max distance to move
  1735. * @returns resulting value
  1736. */
  1737. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1738. /**
  1739. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1740. *
  1741. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1742. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1743. * @param current current value
  1744. * @param target target value
  1745. * @param maxDelta max distance to move
  1746. * @returns resulting angle
  1747. */
  1748. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1749. /**
  1750. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1751. * @param start start value
  1752. * @param end target value
  1753. * @param amount amount to lerp between
  1754. * @returns the lerped value
  1755. */
  1756. static Lerp(start: number, end: number, amount: number): number;
  1757. /**
  1758. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1759. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1760. * @param start start value
  1761. * @param end target value
  1762. * @param amount amount to lerp between
  1763. * @returns the lerped value
  1764. */
  1765. static LerpAngle(start: number, end: number, amount: number): number;
  1766. /**
  1767. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1768. * @param a start value
  1769. * @param b target value
  1770. * @param value value between a and b
  1771. * @returns the inverseLerp value
  1772. */
  1773. static InverseLerp(a: number, b: number, value: number): number;
  1774. /**
  1775. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1776. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1777. * @param value1 spline value
  1778. * @param tangent1 spline value
  1779. * @param value2 spline value
  1780. * @param tangent2 spline value
  1781. * @param amount input value
  1782. * @returns hermite result
  1783. */
  1784. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1785. /**
  1786. * Returns a random float number between and min and max values
  1787. * @param min min value of random
  1788. * @param max max value of random
  1789. * @returns random value
  1790. */
  1791. static RandomRange(min: number, max: number): number;
  1792. /**
  1793. * This function returns percentage of a number in a given range.
  1794. *
  1795. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1796. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1797. * @param number to convert to percentage
  1798. * @param min min range
  1799. * @param max max range
  1800. * @returns the percentage
  1801. */
  1802. static RangeToPercent(number: number, min: number, max: number): number;
  1803. /**
  1804. * This function returns number that corresponds to the percentage in a given range.
  1805. *
  1806. * PercentToRange(0.34,0,100) will return 34.
  1807. * @param percent to convert to number
  1808. * @param min min range
  1809. * @param max max range
  1810. * @returns the number
  1811. */
  1812. static PercentToRange(percent: number, min: number, max: number): number;
  1813. /**
  1814. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1815. * @param angle The angle to normalize in radian.
  1816. * @return The converted angle.
  1817. */
  1818. static NormalizeRadians(angle: number): number;
  1819. }
  1820. }
  1821. declare module BABYLON {
  1822. /**
  1823. * Constant used to convert a value to gamma space
  1824. * @ignorenaming
  1825. */
  1826. export const ToGammaSpace: number;
  1827. /**
  1828. * Constant used to convert a value to linear space
  1829. * @ignorenaming
  1830. */
  1831. export const ToLinearSpace = 2.2;
  1832. /**
  1833. * Constant used to define the minimal number value in Babylon.js
  1834. * @ignorenaming
  1835. */
  1836. let Epsilon: number;
  1837. }
  1838. declare module BABYLON {
  1839. /**
  1840. * Class used to represent a viewport on screen
  1841. */
  1842. export class Viewport {
  1843. /** viewport left coordinate */
  1844. x: number;
  1845. /** viewport top coordinate */
  1846. y: number;
  1847. /**viewport width */
  1848. width: number;
  1849. /** viewport height */
  1850. height: number;
  1851. /**
  1852. * Creates a Viewport object located at (x, y) and sized (width, height)
  1853. * @param x defines viewport left coordinate
  1854. * @param y defines viewport top coordinate
  1855. * @param width defines the viewport width
  1856. * @param height defines the viewport height
  1857. */
  1858. constructor(
  1859. /** viewport left coordinate */
  1860. x: number,
  1861. /** viewport top coordinate */
  1862. y: number,
  1863. /**viewport width */
  1864. width: number,
  1865. /** viewport height */
  1866. height: number);
  1867. /**
  1868. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1869. * @param renderWidth defines the rendering width
  1870. * @param renderHeight defines the rendering height
  1871. * @returns a new Viewport
  1872. */
  1873. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1874. /**
  1875. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1876. * @param renderWidth defines the rendering width
  1877. * @param renderHeight defines the rendering height
  1878. * @param ref defines the target viewport
  1879. * @returns the current viewport
  1880. */
  1881. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1882. /**
  1883. * Returns a new Viewport copied from the current one
  1884. * @returns a new Viewport
  1885. */
  1886. clone(): Viewport;
  1887. }
  1888. }
  1889. declare module BABYLON {
  1890. /**
  1891. * Class containing a set of static utilities functions for arrays.
  1892. */
  1893. export class ArrayTools {
  1894. /**
  1895. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1896. * @param size the number of element to construct and put in the array
  1897. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1898. * @returns a new array filled with new objects
  1899. */
  1900. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1901. }
  1902. }
  1903. declare module BABYLON {
  1904. /**
  1905. * Class representing a vector containing 2 coordinates
  1906. */
  1907. export class Vector2 {
  1908. /** defines the first coordinate */
  1909. x: number;
  1910. /** defines the second coordinate */
  1911. y: number;
  1912. /**
  1913. * Creates a new Vector2 from the given x and y coordinates
  1914. * @param x defines the first coordinate
  1915. * @param y defines the second coordinate
  1916. */
  1917. constructor(
  1918. /** defines the first coordinate */
  1919. x?: number,
  1920. /** defines the second coordinate */
  1921. y?: number);
  1922. /**
  1923. * Gets a string with the Vector2 coordinates
  1924. * @returns a string with the Vector2 coordinates
  1925. */
  1926. toString(): string;
  1927. /**
  1928. * Gets class name
  1929. * @returns the string "Vector2"
  1930. */
  1931. getClassName(): string;
  1932. /**
  1933. * Gets current vector hash code
  1934. * @returns the Vector2 hash code as a number
  1935. */
  1936. getHashCode(): number;
  1937. /**
  1938. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1939. * @param array defines the source array
  1940. * @param index defines the offset in source array
  1941. * @returns the current Vector2
  1942. */
  1943. toArray(array: FloatArray, index?: number): Vector2;
  1944. /**
  1945. * Copy the current vector to an array
  1946. * @returns a new array with 2 elements: the Vector2 coordinates.
  1947. */
  1948. asArray(): number[];
  1949. /**
  1950. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1951. * @param source defines the source Vector2
  1952. * @returns the current updated Vector2
  1953. */
  1954. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1955. /**
  1956. * Sets the Vector2 coordinates with the given floats
  1957. * @param x defines the first coordinate
  1958. * @param y defines the second coordinate
  1959. * @returns the current updated Vector2
  1960. */
  1961. copyFromFloats(x: number, y: number): Vector2;
  1962. /**
  1963. * Sets the Vector2 coordinates with the given floats
  1964. * @param x defines the first coordinate
  1965. * @param y defines the second coordinate
  1966. * @returns the current updated Vector2
  1967. */
  1968. set(x: number, y: number): Vector2;
  1969. /**
  1970. * Add another vector with the current one
  1971. * @param otherVector defines the other vector
  1972. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1973. */
  1974. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1975. /**
  1976. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  1977. * @param otherVector defines the other vector
  1978. * @param result defines the target vector
  1979. * @returns the unmodified current Vector2
  1980. */
  1981. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1982. /**
  1983. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  1984. * @param otherVector defines the other vector
  1985. * @returns the current updated Vector2
  1986. */
  1987. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1988. /**
  1989. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  1990. * @param otherVector defines the other vector
  1991. * @returns a new Vector2
  1992. */
  1993. addVector3(otherVector: Vector3): Vector2;
  1994. /**
  1995. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  1996. * @param otherVector defines the other vector
  1997. * @returns a new Vector2
  1998. */
  1999. subtract(otherVector: Vector2): Vector2;
  2000. /**
  2001. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2002. * @param otherVector defines the other vector
  2003. * @param result defines the target vector
  2004. * @returns the unmodified current Vector2
  2005. */
  2006. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2007. /**
  2008. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2009. * @param otherVector defines the other vector
  2010. * @returns the current updated Vector2
  2011. */
  2012. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2013. /**
  2014. * Multiplies in place the current Vector2 coordinates by the given ones
  2015. * @param otherVector defines the other vector
  2016. * @returns the current updated Vector2
  2017. */
  2018. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2019. /**
  2020. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2021. * @param otherVector defines the other vector
  2022. * @returns a new Vector2
  2023. */
  2024. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2025. /**
  2026. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2027. * @param otherVector defines the other vector
  2028. * @param result defines the target vector
  2029. * @returns the unmodified current Vector2
  2030. */
  2031. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2032. /**
  2033. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2034. * @param x defines the first coordinate
  2035. * @param y defines the second coordinate
  2036. * @returns a new Vector2
  2037. */
  2038. multiplyByFloats(x: number, y: number): Vector2;
  2039. /**
  2040. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2041. * @param otherVector defines the other vector
  2042. * @returns a new Vector2
  2043. */
  2044. divide(otherVector: Vector2): Vector2;
  2045. /**
  2046. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2047. * @param otherVector defines the other vector
  2048. * @param result defines the target vector
  2049. * @returns the unmodified current Vector2
  2050. */
  2051. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2052. /**
  2053. * Divides the current Vector2 coordinates by the given ones
  2054. * @param otherVector defines the other vector
  2055. * @returns the current updated Vector2
  2056. */
  2057. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2058. /**
  2059. * Gets a new Vector2 with current Vector2 negated coordinates
  2060. * @returns a new Vector2
  2061. */
  2062. negate(): Vector2;
  2063. /**
  2064. * Multiply the Vector2 coordinates by scale
  2065. * @param scale defines the scaling factor
  2066. * @returns the current updated Vector2
  2067. */
  2068. scaleInPlace(scale: number): Vector2;
  2069. /**
  2070. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2071. * @param scale defines the scaling factor
  2072. * @returns a new Vector2
  2073. */
  2074. scale(scale: number): Vector2;
  2075. /**
  2076. * Scale the current Vector2 values by a factor to a given Vector2
  2077. * @param scale defines the scale factor
  2078. * @param result defines the Vector2 object where to store the result
  2079. * @returns the unmodified current Vector2
  2080. */
  2081. scaleToRef(scale: number, result: Vector2): Vector2;
  2082. /**
  2083. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2084. * @param scale defines the scale factor
  2085. * @param result defines the Vector2 object where to store the result
  2086. * @returns the unmodified current Vector2
  2087. */
  2088. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2089. /**
  2090. * Gets a boolean if two vectors are equals
  2091. * @param otherVector defines the other vector
  2092. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2093. */
  2094. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2095. /**
  2096. * Gets a boolean if two vectors are equals (using an epsilon value)
  2097. * @param otherVector defines the other vector
  2098. * @param epsilon defines the minimal distance to consider equality
  2099. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2100. */
  2101. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2102. /**
  2103. * Gets a new Vector2 from current Vector2 floored values
  2104. * @returns a new Vector2
  2105. */
  2106. floor(): Vector2;
  2107. /**
  2108. * Gets a new Vector2 from current Vector2 floored values
  2109. * @returns a new Vector2
  2110. */
  2111. fract(): Vector2;
  2112. /**
  2113. * Gets the length of the vector
  2114. * @returns the vector length (float)
  2115. */
  2116. length(): number;
  2117. /**
  2118. * Gets the vector squared length
  2119. * @returns the vector squared length (float)
  2120. */
  2121. lengthSquared(): number;
  2122. /**
  2123. * Normalize the vector
  2124. * @returns the current updated Vector2
  2125. */
  2126. normalize(): Vector2;
  2127. /**
  2128. * Gets a new Vector2 copied from the Vector2
  2129. * @returns a new Vector2
  2130. */
  2131. clone(): Vector2;
  2132. /**
  2133. * Gets a new Vector2(0, 0)
  2134. * @returns a new Vector2
  2135. */
  2136. static Zero(): Vector2;
  2137. /**
  2138. * Gets a new Vector2(1, 1)
  2139. * @returns a new Vector2
  2140. */
  2141. static One(): Vector2;
  2142. /**
  2143. * Gets a new Vector2 set from the given index element of the given array
  2144. * @param array defines the data source
  2145. * @param offset defines the offset in the data source
  2146. * @returns a new Vector2
  2147. */
  2148. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2149. /**
  2150. * Sets "result" from the given index element of the given array
  2151. * @param array defines the data source
  2152. * @param offset defines the offset in the data source
  2153. * @param result defines the target vector
  2154. */
  2155. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2156. /**
  2157. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2158. * @param value1 defines 1st point of control
  2159. * @param value2 defines 2nd point of control
  2160. * @param value3 defines 3rd point of control
  2161. * @param value4 defines 4th point of control
  2162. * @param amount defines the interpolation factor
  2163. * @returns a new Vector2
  2164. */
  2165. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2166. /**
  2167. * 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".
  2168. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2169. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2170. * @param value defines the value to clamp
  2171. * @param min defines the lower limit
  2172. * @param max defines the upper limit
  2173. * @returns a new Vector2
  2174. */
  2175. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2176. /**
  2177. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2178. * @param value1 defines the 1st control point
  2179. * @param tangent1 defines the outgoing tangent
  2180. * @param value2 defines the 2nd control point
  2181. * @param tangent2 defines the incoming tangent
  2182. * @param amount defines the interpolation factor
  2183. * @returns a new Vector2
  2184. */
  2185. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2186. /**
  2187. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2188. * @param start defines the start vector
  2189. * @param end defines the end vector
  2190. * @param amount defines the interpolation factor
  2191. * @returns a new Vector2
  2192. */
  2193. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2194. /**
  2195. * Gets the dot product of the vector "left" and the vector "right"
  2196. * @param left defines first vector
  2197. * @param right defines second vector
  2198. * @returns the dot product (float)
  2199. */
  2200. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2201. /**
  2202. * Returns a new Vector2 equal to the normalized given vector
  2203. * @param vector defines the vector to normalize
  2204. * @returns a new Vector2
  2205. */
  2206. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2207. /**
  2208. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2209. * @param left defines 1st vector
  2210. * @param right defines 2nd vector
  2211. * @returns a new Vector2
  2212. */
  2213. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2214. /**
  2215. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2216. * @param left defines 1st vector
  2217. * @param right defines 2nd vector
  2218. * @returns a new Vector2
  2219. */
  2220. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2221. /**
  2222. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2223. * @param vector defines the vector to transform
  2224. * @param transformation defines the matrix to apply
  2225. * @returns a new Vector2
  2226. */
  2227. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2228. /**
  2229. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2230. * @param vector defines the vector to transform
  2231. * @param transformation defines the matrix to apply
  2232. * @param result defines the target vector
  2233. */
  2234. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2235. /**
  2236. * Determines if a given vector is included in a triangle
  2237. * @param p defines the vector to test
  2238. * @param p0 defines 1st triangle point
  2239. * @param p1 defines 2nd triangle point
  2240. * @param p2 defines 3rd triangle point
  2241. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2242. */
  2243. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2244. /**
  2245. * Gets the distance between the vectors "value1" and "value2"
  2246. * @param value1 defines first vector
  2247. * @param value2 defines second vector
  2248. * @returns the distance between vectors
  2249. */
  2250. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2251. /**
  2252. * Returns the squared distance between the vectors "value1" and "value2"
  2253. * @param value1 defines first vector
  2254. * @param value2 defines second vector
  2255. * @returns the squared distance between vectors
  2256. */
  2257. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2258. /**
  2259. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2260. * @param value1 defines first vector
  2261. * @param value2 defines second vector
  2262. * @returns a new Vector2
  2263. */
  2264. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2265. /**
  2266. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2267. * @param p defines the middle point
  2268. * @param segA defines one point of the segment
  2269. * @param segB defines the other point of the segment
  2270. * @returns the shortest distance
  2271. */
  2272. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2273. }
  2274. /**
  2275. * Class used to store (x,y,z) vector representation
  2276. * A Vector3 is the main object used in 3D geometry
  2277. * It can represent etiher the coordinates of a point the space, either a direction
  2278. * Reminder: js uses a left handed forward facing system
  2279. */
  2280. export class Vector3 {
  2281. /**
  2282. * Defines the first coordinates (on X axis)
  2283. */
  2284. x: number;
  2285. /**
  2286. * Defines the second coordinates (on Y axis)
  2287. */
  2288. y: number;
  2289. /**
  2290. * Defines the third coordinates (on Z axis)
  2291. */
  2292. z: number;
  2293. private static _UpReadOnly;
  2294. private static _ZeroReadOnly;
  2295. /**
  2296. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2297. * @param x defines the first coordinates (on X axis)
  2298. * @param y defines the second coordinates (on Y axis)
  2299. * @param z defines the third coordinates (on Z axis)
  2300. */
  2301. constructor(
  2302. /**
  2303. * Defines the first coordinates (on X axis)
  2304. */
  2305. x?: number,
  2306. /**
  2307. * Defines the second coordinates (on Y axis)
  2308. */
  2309. y?: number,
  2310. /**
  2311. * Defines the third coordinates (on Z axis)
  2312. */
  2313. z?: number);
  2314. /**
  2315. * Creates a string representation of the Vector3
  2316. * @returns a string with the Vector3 coordinates.
  2317. */
  2318. toString(): string;
  2319. /**
  2320. * Gets the class name
  2321. * @returns the string "Vector3"
  2322. */
  2323. getClassName(): string;
  2324. /**
  2325. * Creates the Vector3 hash code
  2326. * @returns a number which tends to be unique between Vector3 instances
  2327. */
  2328. getHashCode(): number;
  2329. /**
  2330. * Creates an array containing three elements : the coordinates of the Vector3
  2331. * @returns a new array of numbers
  2332. */
  2333. asArray(): number[];
  2334. /**
  2335. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2336. * @param array defines the destination array
  2337. * @param index defines the offset in the destination array
  2338. * @returns the current Vector3
  2339. */
  2340. toArray(array: FloatArray, index?: number): Vector3;
  2341. /**
  2342. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2343. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2344. */
  2345. toQuaternion(): Quaternion;
  2346. /**
  2347. * Adds the given vector to the current Vector3
  2348. * @param otherVector defines the second operand
  2349. * @returns the current updated Vector3
  2350. */
  2351. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2352. /**
  2353. * Adds the given coordinates to the current Vector3
  2354. * @param x defines the x coordinate of the operand
  2355. * @param y defines the y coordinate of the operand
  2356. * @param z defines the z coordinate of the operand
  2357. * @returns the current updated Vector3
  2358. */
  2359. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2360. /**
  2361. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2362. * @param otherVector defines the second operand
  2363. * @returns the resulting Vector3
  2364. */
  2365. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2366. /**
  2367. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2368. * @param otherVector defines the second operand
  2369. * @param result defines the Vector3 object where to store the result
  2370. * @returns the current Vector3
  2371. */
  2372. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2373. /**
  2374. * Subtract the given vector from the current Vector3
  2375. * @param otherVector defines the second operand
  2376. * @returns the current updated Vector3
  2377. */
  2378. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2379. /**
  2380. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2381. * @param otherVector defines the second operand
  2382. * @returns the resulting Vector3
  2383. */
  2384. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2385. /**
  2386. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2387. * @param otherVector defines the second operand
  2388. * @param result defines the Vector3 object where to store the result
  2389. * @returns the current Vector3
  2390. */
  2391. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2392. /**
  2393. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2394. * @param x defines the x coordinate of the operand
  2395. * @param y defines the y coordinate of the operand
  2396. * @param z defines the z coordinate of the operand
  2397. * @returns the resulting Vector3
  2398. */
  2399. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2400. /**
  2401. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2402. * @param x defines the x coordinate of the operand
  2403. * @param y defines the y coordinate of the operand
  2404. * @param z defines the z coordinate of the operand
  2405. * @param result defines the Vector3 object where to store the result
  2406. * @returns the current Vector3
  2407. */
  2408. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2409. /**
  2410. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2411. * @returns a new Vector3
  2412. */
  2413. negate(): Vector3;
  2414. /**
  2415. * Multiplies the Vector3 coordinates by the float "scale"
  2416. * @param scale defines the multiplier factor
  2417. * @returns the current updated Vector3
  2418. */
  2419. scaleInPlace(scale: number): Vector3;
  2420. /**
  2421. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2422. * @param scale defines the multiplier factor
  2423. * @returns a new Vector3
  2424. */
  2425. scale(scale: number): Vector3;
  2426. /**
  2427. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2428. * @param scale defines the multiplier factor
  2429. * @param result defines the Vector3 object where to store the result
  2430. * @returns the current Vector3
  2431. */
  2432. scaleToRef(scale: number, result: Vector3): Vector3;
  2433. /**
  2434. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2435. * @param scale defines the scale factor
  2436. * @param result defines the Vector3 object where to store the result
  2437. * @returns the unmodified current Vector3
  2438. */
  2439. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2440. /**
  2441. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2442. * @param otherVector defines the second operand
  2443. * @returns true if both vectors are equals
  2444. */
  2445. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2446. /**
  2447. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2448. * @param otherVector defines the second operand
  2449. * @param epsilon defines the minimal distance to define values as equals
  2450. * @returns true if both vectors are distant less than epsilon
  2451. */
  2452. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2453. /**
  2454. * Returns true if the current Vector3 coordinates equals the given floats
  2455. * @param x defines the x coordinate of the operand
  2456. * @param y defines the y coordinate of the operand
  2457. * @param z defines the z coordinate of the operand
  2458. * @returns true if both vectors are equals
  2459. */
  2460. equalsToFloats(x: number, y: number, z: number): boolean;
  2461. /**
  2462. * Multiplies the current Vector3 coordinates by the given ones
  2463. * @param otherVector defines the second operand
  2464. * @returns the current updated Vector3
  2465. */
  2466. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2467. /**
  2468. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2469. * @param otherVector defines the second operand
  2470. * @returns the new Vector3
  2471. */
  2472. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2473. /**
  2474. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2475. * @param otherVector defines the second operand
  2476. * @param result defines the Vector3 object where to store the result
  2477. * @returns the current Vector3
  2478. */
  2479. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2480. /**
  2481. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2482. * @param x defines the x coordinate of the operand
  2483. * @param y defines the y coordinate of the operand
  2484. * @param z defines the z coordinate of the operand
  2485. * @returns the new Vector3
  2486. */
  2487. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2488. /**
  2489. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2490. * @param otherVector defines the second operand
  2491. * @returns the new Vector3
  2492. */
  2493. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2494. /**
  2495. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2496. * @param otherVector defines the second operand
  2497. * @param result defines the Vector3 object where to store the result
  2498. * @returns the current Vector3
  2499. */
  2500. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2501. /**
  2502. * Divides the current Vector3 coordinates by the given ones.
  2503. * @param otherVector defines the second operand
  2504. * @returns the current updated Vector3
  2505. */
  2506. divideInPlace(otherVector: Vector3): Vector3;
  2507. /**
  2508. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2509. * @param other defines the second operand
  2510. * @returns the current updated Vector3
  2511. */
  2512. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2513. /**
  2514. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2515. * @param other defines the second operand
  2516. * @returns the current updated Vector3
  2517. */
  2518. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2519. /**
  2520. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2521. * @param x defines the x coordinate of the operand
  2522. * @param y defines the y coordinate of the operand
  2523. * @param z defines the z coordinate of the operand
  2524. * @returns the current updated Vector3
  2525. */
  2526. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2527. /**
  2528. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2529. * @param x defines the x coordinate of the operand
  2530. * @param y defines the y coordinate of the operand
  2531. * @param z defines the z coordinate of the operand
  2532. * @returns the current updated Vector3
  2533. */
  2534. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2535. /**
  2536. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2537. * Check if is non uniform within a certain amount of decimal places to account for this
  2538. * @param epsilon the amount the values can differ
  2539. * @returns if the the vector is non uniform to a certain number of decimal places
  2540. */
  2541. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2542. /**
  2543. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2544. */
  2545. get isNonUniform(): boolean;
  2546. /**
  2547. * Gets a new Vector3 from current Vector3 floored values
  2548. * @returns a new Vector3
  2549. */
  2550. floor(): Vector3;
  2551. /**
  2552. * Gets a new Vector3 from current Vector3 floored values
  2553. * @returns a new Vector3
  2554. */
  2555. fract(): Vector3;
  2556. /**
  2557. * Gets the length of the Vector3
  2558. * @returns the length of the Vector3
  2559. */
  2560. length(): number;
  2561. /**
  2562. * Gets the squared length of the Vector3
  2563. * @returns squared length of the Vector3
  2564. */
  2565. lengthSquared(): number;
  2566. /**
  2567. * Normalize the current Vector3.
  2568. * Please note that this is an in place operation.
  2569. * @returns the current updated Vector3
  2570. */
  2571. normalize(): Vector3;
  2572. /**
  2573. * Reorders the x y z properties of the vector in place
  2574. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2575. * @returns the current updated vector
  2576. */
  2577. reorderInPlace(order: string): this;
  2578. /**
  2579. * Rotates the vector around 0,0,0 by a quaternion
  2580. * @param quaternion the rotation quaternion
  2581. * @param result vector to store the result
  2582. * @returns the resulting vector
  2583. */
  2584. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2585. /**
  2586. * Rotates a vector around a given point
  2587. * @param quaternion the rotation quaternion
  2588. * @param point the point to rotate around
  2589. * @param result vector to store the result
  2590. * @returns the resulting vector
  2591. */
  2592. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2593. /**
  2594. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2595. * The cross product is then orthogonal to both current and "other"
  2596. * @param other defines the right operand
  2597. * @returns the cross product
  2598. */
  2599. cross(other: Vector3): Vector3;
  2600. /**
  2601. * Normalize the current Vector3 with the given input length.
  2602. * Please note that this is an in place operation.
  2603. * @param len the length of the vector
  2604. * @returns the current updated Vector3
  2605. */
  2606. normalizeFromLength(len: number): Vector3;
  2607. /**
  2608. * Normalize the current Vector3 to a new vector
  2609. * @returns the new Vector3
  2610. */
  2611. normalizeToNew(): Vector3;
  2612. /**
  2613. * Normalize the current Vector3 to the reference
  2614. * @param reference define the Vector3 to update
  2615. * @returns the updated Vector3
  2616. */
  2617. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2618. /**
  2619. * Creates a new Vector3 copied from the current Vector3
  2620. * @returns the new Vector3
  2621. */
  2622. clone(): Vector3;
  2623. /**
  2624. * Copies the given vector coordinates to the current Vector3 ones
  2625. * @param source defines the source Vector3
  2626. * @returns the current updated Vector3
  2627. */
  2628. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2629. /**
  2630. * Copies the given floats to the current Vector3 coordinates
  2631. * @param x defines the x coordinate of the operand
  2632. * @param y defines the y coordinate of the operand
  2633. * @param z defines the z coordinate of the operand
  2634. * @returns the current updated Vector3
  2635. */
  2636. copyFromFloats(x: number, y: number, z: number): Vector3;
  2637. /**
  2638. * Copies the given floats to the current Vector3 coordinates
  2639. * @param x defines the x coordinate of the operand
  2640. * @param y defines the y coordinate of the operand
  2641. * @param z defines the z coordinate of the operand
  2642. * @returns the current updated Vector3
  2643. */
  2644. set(x: number, y: number, z: number): Vector3;
  2645. /**
  2646. * Copies the given float to the current Vector3 coordinates
  2647. * @param v defines the x, y and z coordinates of the operand
  2648. * @returns the current updated Vector3
  2649. */
  2650. setAll(v: number): Vector3;
  2651. /**
  2652. * Get the clip factor between two vectors
  2653. * @param vector0 defines the first operand
  2654. * @param vector1 defines the second operand
  2655. * @param axis defines the axis to use
  2656. * @param size defines the size along the axis
  2657. * @returns the clip factor
  2658. */
  2659. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2660. /**
  2661. * Get angle between two vectors
  2662. * @param vector0 angle between vector0 and vector1
  2663. * @param vector1 angle between vector0 and vector1
  2664. * @param normal direction of the normal
  2665. * @return the angle between vector0 and vector1
  2666. */
  2667. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2668. /**
  2669. * Returns a new Vector3 set from the index "offset" of the given array
  2670. * @param array defines the source array
  2671. * @param offset defines the offset in the source array
  2672. * @returns the new Vector3
  2673. */
  2674. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2675. /**
  2676. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2677. * @param array defines the source array
  2678. * @param offset defines the offset in the source array
  2679. * @returns the new Vector3
  2680. * @deprecated Please use FromArray instead.
  2681. */
  2682. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2683. /**
  2684. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2685. * @param array defines the source array
  2686. * @param offset defines the offset in the source array
  2687. * @param result defines the Vector3 where to store the result
  2688. */
  2689. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2690. /**
  2691. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2692. * @param array defines the source array
  2693. * @param offset defines the offset in the source array
  2694. * @param result defines the Vector3 where to store the result
  2695. * @deprecated Please use FromArrayToRef instead.
  2696. */
  2697. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2698. /**
  2699. * Sets the given vector "result" with the given floats.
  2700. * @param x defines the x coordinate of the source
  2701. * @param y defines the y coordinate of the source
  2702. * @param z defines the z coordinate of the source
  2703. * @param result defines the Vector3 where to store the result
  2704. */
  2705. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2706. /**
  2707. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2708. * @returns a new empty Vector3
  2709. */
  2710. static Zero(): Vector3;
  2711. /**
  2712. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2713. * @returns a new unit Vector3
  2714. */
  2715. static One(): Vector3;
  2716. /**
  2717. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2718. * @returns a new up Vector3
  2719. */
  2720. static Up(): Vector3;
  2721. /**
  2722. * Gets a up Vector3 that must not be updated
  2723. */
  2724. static get UpReadOnly(): DeepImmutable<Vector3>;
  2725. /**
  2726. * Gets a zero Vector3 that must not be updated
  2727. */
  2728. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2729. /**
  2730. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2731. * @returns a new down Vector3
  2732. */
  2733. static Down(): Vector3;
  2734. /**
  2735. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2736. * @returns a new forward Vector3
  2737. */
  2738. static Forward(): Vector3;
  2739. /**
  2740. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2741. * @returns a new forward Vector3
  2742. */
  2743. static Backward(): Vector3;
  2744. /**
  2745. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2746. * @returns a new right Vector3
  2747. */
  2748. static Right(): Vector3;
  2749. /**
  2750. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2751. * @returns a new left Vector3
  2752. */
  2753. static Left(): Vector3;
  2754. /**
  2755. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2756. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2757. * @param vector defines the Vector3 to transform
  2758. * @param transformation defines the transformation matrix
  2759. * @returns the transformed Vector3
  2760. */
  2761. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2762. /**
  2763. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2764. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2765. * @param vector defines the Vector3 to transform
  2766. * @param transformation defines the transformation matrix
  2767. * @param result defines the Vector3 where to store the result
  2768. */
  2769. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2770. /**
  2771. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2772. * This method computes tranformed coordinates only, not transformed direction vectors
  2773. * @param x define the x coordinate of the source vector
  2774. * @param y define the y coordinate of the source vector
  2775. * @param z define the z coordinate of the source vector
  2776. * @param transformation defines the transformation matrix
  2777. * @param result defines the Vector3 where to store the result
  2778. */
  2779. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2780. /**
  2781. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2782. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2783. * @param vector defines the Vector3 to transform
  2784. * @param transformation defines the transformation matrix
  2785. * @returns the new Vector3
  2786. */
  2787. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2788. /**
  2789. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2790. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2791. * @param vector defines the Vector3 to transform
  2792. * @param transformation defines the transformation matrix
  2793. * @param result defines the Vector3 where to store the result
  2794. */
  2795. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2796. /**
  2797. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2798. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2799. * @param x define the x coordinate of the source vector
  2800. * @param y define the y coordinate of the source vector
  2801. * @param z define the z coordinate of the source vector
  2802. * @param transformation defines the transformation matrix
  2803. * @param result defines the Vector3 where to store the result
  2804. */
  2805. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2806. /**
  2807. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2808. * @param value1 defines the first control point
  2809. * @param value2 defines the second control point
  2810. * @param value3 defines the third control point
  2811. * @param value4 defines the fourth control point
  2812. * @param amount defines the amount on the spline to use
  2813. * @returns the new Vector3
  2814. */
  2815. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2816. /**
  2817. * 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"
  2818. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2819. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2820. * @param value defines the current value
  2821. * @param min defines the lower range value
  2822. * @param max defines the upper range value
  2823. * @returns the new Vector3
  2824. */
  2825. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2826. /**
  2827. * 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"
  2828. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2829. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2830. * @param value defines the current value
  2831. * @param min defines the lower range value
  2832. * @param max defines the upper range value
  2833. * @param result defines the Vector3 where to store the result
  2834. */
  2835. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2836. /**
  2837. * Checks if a given vector is inside a specific range
  2838. * @param v defines the vector to test
  2839. * @param min defines the minimum range
  2840. * @param max defines the maximum range
  2841. */
  2842. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2843. /**
  2844. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2845. * @param value1 defines the first control point
  2846. * @param tangent1 defines the first tangent vector
  2847. * @param value2 defines the second control point
  2848. * @param tangent2 defines the second tangent vector
  2849. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2850. * @returns the new Vector3
  2851. */
  2852. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2853. /**
  2854. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2855. * @param start defines the start value
  2856. * @param end defines the end value
  2857. * @param amount max defines amount between both (between 0 and 1)
  2858. * @returns the new Vector3
  2859. */
  2860. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2861. /**
  2862. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2863. * @param start defines the start value
  2864. * @param end defines the end value
  2865. * @param amount max defines amount between both (between 0 and 1)
  2866. * @param result defines the Vector3 where to store the result
  2867. */
  2868. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2869. /**
  2870. * Returns the dot product (float) between the vectors "left" and "right"
  2871. * @param left defines the left operand
  2872. * @param right defines the right operand
  2873. * @returns the dot product
  2874. */
  2875. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2876. /**
  2877. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2878. * The cross product is then orthogonal to both "left" and "right"
  2879. * @param left defines the left operand
  2880. * @param right defines the right operand
  2881. * @returns the cross product
  2882. */
  2883. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2884. /**
  2885. * Sets the given vector "result" with the cross product of "left" and "right"
  2886. * The cross product is then orthogonal to both "left" and "right"
  2887. * @param left defines the left operand
  2888. * @param right defines the right operand
  2889. * @param result defines the Vector3 where to store the result
  2890. */
  2891. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2892. /**
  2893. * Returns a new Vector3 as the normalization of the given vector
  2894. * @param vector defines the Vector3 to normalize
  2895. * @returns the new Vector3
  2896. */
  2897. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2898. /**
  2899. * Sets the given vector "result" with the normalization of the given first vector
  2900. * @param vector defines the Vector3 to normalize
  2901. * @param result defines the Vector3 where to store the result
  2902. */
  2903. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2904. /**
  2905. * Project a Vector3 onto screen space
  2906. * @param vector defines the Vector3 to project
  2907. * @param world defines the world matrix to use
  2908. * @param transform defines the transform (view x projection) matrix to use
  2909. * @param viewport defines the screen viewport to use
  2910. * @returns the new Vector3
  2911. */
  2912. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2913. /** @hidden */
  2914. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2915. /**
  2916. * Unproject from screen space to object space
  2917. * @param source defines the screen space Vector3 to use
  2918. * @param viewportWidth defines the current width of the viewport
  2919. * @param viewportHeight defines the current height of the viewport
  2920. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2921. * @param transform defines the transform (view x projection) matrix to use
  2922. * @returns the new Vector3
  2923. */
  2924. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2925. /**
  2926. * Unproject from screen space to object space
  2927. * @param source defines the screen space Vector3 to use
  2928. * @param viewportWidth defines the current width of the viewport
  2929. * @param viewportHeight defines the current height of the viewport
  2930. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2931. * @param view defines the view matrix to use
  2932. * @param projection defines the projection matrix to use
  2933. * @returns the new Vector3
  2934. */
  2935. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2936. /**
  2937. * Unproject from screen space to object space
  2938. * @param source defines the screen space Vector3 to use
  2939. * @param viewportWidth defines the current width of the viewport
  2940. * @param viewportHeight defines the current height of the viewport
  2941. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2942. * @param view defines the view matrix to use
  2943. * @param projection defines the projection matrix to use
  2944. * @param result defines the Vector3 where to store the result
  2945. */
  2946. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2947. /**
  2948. * Unproject from screen space to object space
  2949. * @param sourceX defines the screen space x coordinate to use
  2950. * @param sourceY defines the screen space y coordinate to use
  2951. * @param sourceZ defines the screen space z coordinate 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 view defines the view matrix to use
  2956. * @param projection defines the projection matrix to use
  2957. * @param result defines the Vector3 where to store the result
  2958. */
  2959. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2960. /**
  2961. * Gets the minimal coordinate values between two Vector3
  2962. * @param left defines the first operand
  2963. * @param right defines the second operand
  2964. * @returns the new Vector3
  2965. */
  2966. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2967. /**
  2968. * Gets the maximal coordinate values between two Vector3
  2969. * @param left defines the first operand
  2970. * @param right defines the second operand
  2971. * @returns the new Vector3
  2972. */
  2973. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2974. /**
  2975. * Returns the distance between the vectors "value1" and "value2"
  2976. * @param value1 defines the first operand
  2977. * @param value2 defines the second operand
  2978. * @returns the distance
  2979. */
  2980. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2981. /**
  2982. * Returns the squared distance between the vectors "value1" and "value2"
  2983. * @param value1 defines the first operand
  2984. * @param value2 defines the second operand
  2985. * @returns the squared distance
  2986. */
  2987. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2988. /**
  2989. * Returns a new Vector3 located at the center between "value1" and "value2"
  2990. * @param value1 defines the first operand
  2991. * @param value2 defines the second operand
  2992. * @returns the new Vector3
  2993. */
  2994. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  2995. /**
  2996. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  2997. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  2998. * to something in order to rotate it from its local system to the given target system
  2999. * Note: axis1, axis2 and axis3 are normalized during this operation
  3000. * @param axis1 defines the first axis
  3001. * @param axis2 defines the second axis
  3002. * @param axis3 defines the third axis
  3003. * @returns a new Vector3
  3004. */
  3005. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3006. /**
  3007. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3008. * @param axis1 defines the first axis
  3009. * @param axis2 defines the second axis
  3010. * @param axis3 defines the third axis
  3011. * @param ref defines the Vector3 where to store the result
  3012. */
  3013. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3014. }
  3015. /**
  3016. * Vector4 class created for EulerAngle class conversion to Quaternion
  3017. */
  3018. export class Vector4 {
  3019. /** x value of the vector */
  3020. x: number;
  3021. /** y value of the vector */
  3022. y: number;
  3023. /** z value of the vector */
  3024. z: number;
  3025. /** w value of the vector */
  3026. w: number;
  3027. /**
  3028. * Creates a Vector4 object from the given floats.
  3029. * @param x x value of the vector
  3030. * @param y y value of the vector
  3031. * @param z z value of the vector
  3032. * @param w w value of the vector
  3033. */
  3034. constructor(
  3035. /** x value of the vector */
  3036. x: number,
  3037. /** y value of the vector */
  3038. y: number,
  3039. /** z value of the vector */
  3040. z: number,
  3041. /** w value of the vector */
  3042. w: number);
  3043. /**
  3044. * Returns the string with the Vector4 coordinates.
  3045. * @returns a string containing all the vector values
  3046. */
  3047. toString(): string;
  3048. /**
  3049. * Returns the string "Vector4".
  3050. * @returns "Vector4"
  3051. */
  3052. getClassName(): string;
  3053. /**
  3054. * Returns the Vector4 hash code.
  3055. * @returns a unique hash code
  3056. */
  3057. getHashCode(): number;
  3058. /**
  3059. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3060. * @returns the resulting array
  3061. */
  3062. asArray(): number[];
  3063. /**
  3064. * Populates the given array from the given index with the Vector4 coordinates.
  3065. * @param array array to populate
  3066. * @param index index of the array to start at (default: 0)
  3067. * @returns the Vector4.
  3068. */
  3069. toArray(array: FloatArray, index?: number): Vector4;
  3070. /**
  3071. * Adds the given vector to the current Vector4.
  3072. * @param otherVector the vector to add
  3073. * @returns the updated Vector4.
  3074. */
  3075. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3076. /**
  3077. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3078. * @param otherVector the vector to add
  3079. * @returns the resulting vector
  3080. */
  3081. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3082. /**
  3083. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3084. * @param otherVector the vector to add
  3085. * @param result the vector to store the result
  3086. * @returns the current Vector4.
  3087. */
  3088. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3089. /**
  3090. * Subtract in place the given vector from the current Vector4.
  3091. * @param otherVector the vector to subtract
  3092. * @returns the updated Vector4.
  3093. */
  3094. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3095. /**
  3096. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3097. * @param otherVector the vector to add
  3098. * @returns the new vector with the result
  3099. */
  3100. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3101. /**
  3102. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3103. * @param otherVector the vector to subtract
  3104. * @param result the vector to store the result
  3105. * @returns the current Vector4.
  3106. */
  3107. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3108. /**
  3109. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3110. */
  3111. /**
  3112. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3113. * @param x value to subtract
  3114. * @param y value to subtract
  3115. * @param z value to subtract
  3116. * @param w value to subtract
  3117. * @returns new vector containing the result
  3118. */
  3119. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3120. /**
  3121. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3122. * @param x value to subtract
  3123. * @param y value to subtract
  3124. * @param z value to subtract
  3125. * @param w value to subtract
  3126. * @param result the vector to store the result in
  3127. * @returns the current Vector4.
  3128. */
  3129. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3130. /**
  3131. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3132. * @returns a new vector with the negated values
  3133. */
  3134. negate(): Vector4;
  3135. /**
  3136. * Multiplies the current Vector4 coordinates by scale (float).
  3137. * @param scale the number to scale with
  3138. * @returns the updated Vector4.
  3139. */
  3140. scaleInPlace(scale: number): Vector4;
  3141. /**
  3142. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3143. * @param scale the number to scale with
  3144. * @returns a new vector with the result
  3145. */
  3146. scale(scale: number): Vector4;
  3147. /**
  3148. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3149. * @param scale the number to scale with
  3150. * @param result a vector to store the result in
  3151. * @returns the current Vector4.
  3152. */
  3153. scaleToRef(scale: number, result: Vector4): Vector4;
  3154. /**
  3155. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3156. * @param scale defines the scale factor
  3157. * @param result defines the Vector4 object where to store the result
  3158. * @returns the unmodified current Vector4
  3159. */
  3160. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3161. /**
  3162. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3163. * @param otherVector the vector to compare against
  3164. * @returns true if they are equal
  3165. */
  3166. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3167. /**
  3168. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3169. * @param otherVector vector to compare against
  3170. * @param epsilon (Default: very small number)
  3171. * @returns true if they are equal
  3172. */
  3173. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3174. /**
  3175. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3176. * @param x x value to compare against
  3177. * @param y y value to compare against
  3178. * @param z z value to compare against
  3179. * @param w w value to compare against
  3180. * @returns true if equal
  3181. */
  3182. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3183. /**
  3184. * Multiplies in place the current Vector4 by the given one.
  3185. * @param otherVector vector to multiple with
  3186. * @returns the updated Vector4.
  3187. */
  3188. multiplyInPlace(otherVector: Vector4): Vector4;
  3189. /**
  3190. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3191. * @param otherVector vector to multiple with
  3192. * @returns resulting new vector
  3193. */
  3194. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3195. /**
  3196. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3197. * @param otherVector vector to multiple with
  3198. * @param result vector to store the result
  3199. * @returns the current Vector4.
  3200. */
  3201. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3202. /**
  3203. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3204. * @param x x value multiply with
  3205. * @param y y value multiply with
  3206. * @param z z value multiply with
  3207. * @param w w value multiply with
  3208. * @returns resulting new vector
  3209. */
  3210. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3211. /**
  3212. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3213. * @param otherVector vector to devide with
  3214. * @returns resulting new vector
  3215. */
  3216. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3217. /**
  3218. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3219. * @param otherVector vector to devide with
  3220. * @param result vector to store the result
  3221. * @returns the current Vector4.
  3222. */
  3223. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3224. /**
  3225. * Divides the current Vector3 coordinates by the given ones.
  3226. * @param otherVector vector to devide with
  3227. * @returns the updated Vector3.
  3228. */
  3229. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3230. /**
  3231. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3232. * @param other defines the second operand
  3233. * @returns the current updated Vector4
  3234. */
  3235. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3236. /**
  3237. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3238. * @param other defines the second operand
  3239. * @returns the current updated Vector4
  3240. */
  3241. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3242. /**
  3243. * Gets a new Vector4 from current Vector4 floored values
  3244. * @returns a new Vector4
  3245. */
  3246. floor(): Vector4;
  3247. /**
  3248. * Gets a new Vector4 from current Vector3 floored values
  3249. * @returns a new Vector4
  3250. */
  3251. fract(): Vector4;
  3252. /**
  3253. * Returns the Vector4 length (float).
  3254. * @returns the length
  3255. */
  3256. length(): number;
  3257. /**
  3258. * Returns the Vector4 squared length (float).
  3259. * @returns the length squared
  3260. */
  3261. lengthSquared(): number;
  3262. /**
  3263. * Normalizes in place the Vector4.
  3264. * @returns the updated Vector4.
  3265. */
  3266. normalize(): Vector4;
  3267. /**
  3268. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3269. * @returns this converted to a new vector3
  3270. */
  3271. toVector3(): Vector3;
  3272. /**
  3273. * Returns a new Vector4 copied from the current one.
  3274. * @returns the new cloned vector
  3275. */
  3276. clone(): Vector4;
  3277. /**
  3278. * Updates the current Vector4 with the given one coordinates.
  3279. * @param source the source vector to copy from
  3280. * @returns the updated Vector4.
  3281. */
  3282. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3283. /**
  3284. * Updates the current Vector4 coordinates with the given floats.
  3285. * @param x float to copy from
  3286. * @param y float to copy from
  3287. * @param z float to copy from
  3288. * @param w float to copy from
  3289. * @returns the updated Vector4.
  3290. */
  3291. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3292. /**
  3293. * Updates the current Vector4 coordinates with the given floats.
  3294. * @param x float to set from
  3295. * @param y float to set from
  3296. * @param z float to set from
  3297. * @param w float to set from
  3298. * @returns the updated Vector4.
  3299. */
  3300. set(x: number, y: number, z: number, w: number): Vector4;
  3301. /**
  3302. * Copies the given float to the current Vector3 coordinates
  3303. * @param v defines the x, y, z and w coordinates of the operand
  3304. * @returns the current updated Vector3
  3305. */
  3306. setAll(v: number): Vector4;
  3307. /**
  3308. * Returns a new Vector4 set from the starting index of the given array.
  3309. * @param array the array to pull values from
  3310. * @param offset the offset into the array to start at
  3311. * @returns the new vector
  3312. */
  3313. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3314. /**
  3315. * Updates the given vector "result" from the starting index of the given array.
  3316. * @param array the array to pull values from
  3317. * @param offset the offset into the array to start at
  3318. * @param result the vector to store the result in
  3319. */
  3320. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3321. /**
  3322. * Updates the given vector "result" from the starting index of the given Float32Array.
  3323. * @param array the array to pull values from
  3324. * @param offset the offset into the array to start at
  3325. * @param result the vector to store the result in
  3326. */
  3327. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3328. /**
  3329. * Updates the given vector "result" coordinates from the given floats.
  3330. * @param x float to set from
  3331. * @param y float to set from
  3332. * @param z float to set from
  3333. * @param w float to set from
  3334. * @param result the vector to the floats in
  3335. */
  3336. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3337. /**
  3338. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3339. * @returns the new vector
  3340. */
  3341. static Zero(): Vector4;
  3342. /**
  3343. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3344. * @returns the new vector
  3345. */
  3346. static One(): Vector4;
  3347. /**
  3348. * Returns a new normalized Vector4 from the given one.
  3349. * @param vector the vector to normalize
  3350. * @returns the vector
  3351. */
  3352. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3353. /**
  3354. * Updates the given vector "result" from the normalization of the given one.
  3355. * @param vector the vector to normalize
  3356. * @param result the vector to store the result in
  3357. */
  3358. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3359. /**
  3360. * Returns a vector with the minimum values from the left and right vectors
  3361. * @param left left vector to minimize
  3362. * @param right right vector to minimize
  3363. * @returns a new vector with the minimum of the left and right vector values
  3364. */
  3365. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3366. /**
  3367. * Returns a vector with the maximum values from the left and right vectors
  3368. * @param left left vector to maximize
  3369. * @param right right vector to maximize
  3370. * @returns a new vector with the maximum of the left and right vector values
  3371. */
  3372. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3373. /**
  3374. * Returns the distance (float) between the vectors "value1" and "value2".
  3375. * @param value1 value to calulate the distance between
  3376. * @param value2 value to calulate the distance between
  3377. * @return the distance between the two vectors
  3378. */
  3379. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3380. /**
  3381. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3382. * @param value1 value to calulate the distance between
  3383. * @param value2 value to calulate the distance between
  3384. * @return the distance between the two vectors squared
  3385. */
  3386. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3387. /**
  3388. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3389. * @param value1 value to calulate the center between
  3390. * @param value2 value to calulate the center between
  3391. * @return the center between the two vectors
  3392. */
  3393. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3394. /**
  3395. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3396. * This methods computes transformed normalized direction vectors only.
  3397. * @param vector the vector to transform
  3398. * @param transformation the transformation matrix to apply
  3399. * @returns the new vector
  3400. */
  3401. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3402. /**
  3403. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3404. * This methods computes transformed normalized direction vectors only.
  3405. * @param vector the vector to transform
  3406. * @param transformation the transformation matrix to apply
  3407. * @param result the vector to store the result in
  3408. */
  3409. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3410. /**
  3411. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3412. * This methods computes transformed normalized direction vectors only.
  3413. * @param x value to transform
  3414. * @param y value to transform
  3415. * @param z value to transform
  3416. * @param w value to transform
  3417. * @param transformation the transformation matrix to apply
  3418. * @param result the vector to store the results in
  3419. */
  3420. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3421. /**
  3422. * Creates a new Vector4 from a Vector3
  3423. * @param source defines the source data
  3424. * @param w defines the 4th component (default is 0)
  3425. * @returns a new Vector4
  3426. */
  3427. static FromVector3(source: Vector3, w?: number): Vector4;
  3428. }
  3429. /**
  3430. * Class used to store quaternion data
  3431. * @see https://en.wikipedia.org/wiki/Quaternion
  3432. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3433. */
  3434. export class Quaternion {
  3435. /** defines the first component (0 by default) */
  3436. x: number;
  3437. /** defines the second component (0 by default) */
  3438. y: number;
  3439. /** defines the third component (0 by default) */
  3440. z: number;
  3441. /** defines the fourth component (1.0 by default) */
  3442. w: number;
  3443. /**
  3444. * Creates a new Quaternion from the given floats
  3445. * @param x defines the first component (0 by default)
  3446. * @param y defines the second component (0 by default)
  3447. * @param z defines the third component (0 by default)
  3448. * @param w defines the fourth component (1.0 by default)
  3449. */
  3450. constructor(
  3451. /** defines the first component (0 by default) */
  3452. x?: number,
  3453. /** defines the second component (0 by default) */
  3454. y?: number,
  3455. /** defines the third component (0 by default) */
  3456. z?: number,
  3457. /** defines the fourth component (1.0 by default) */
  3458. w?: number);
  3459. /**
  3460. * Gets a string representation for the current quaternion
  3461. * @returns a string with the Quaternion coordinates
  3462. */
  3463. toString(): string;
  3464. /**
  3465. * Gets the class name of the quaternion
  3466. * @returns the string "Quaternion"
  3467. */
  3468. getClassName(): string;
  3469. /**
  3470. * Gets a hash code for this quaternion
  3471. * @returns the quaternion hash code
  3472. */
  3473. getHashCode(): number;
  3474. /**
  3475. * Copy the quaternion to an array
  3476. * @returns a new array populated with 4 elements from the quaternion coordinates
  3477. */
  3478. asArray(): number[];
  3479. /**
  3480. * Check if two quaternions are equals
  3481. * @param otherQuaternion defines the second operand
  3482. * @return true if the current quaternion and the given one coordinates are strictly equals
  3483. */
  3484. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3485. /**
  3486. * Clone the current quaternion
  3487. * @returns a new quaternion copied from the current one
  3488. */
  3489. clone(): Quaternion;
  3490. /**
  3491. * Copy a quaternion to the current one
  3492. * @param other defines the other quaternion
  3493. * @returns the updated current quaternion
  3494. */
  3495. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3496. /**
  3497. * Updates the current quaternion with the given float coordinates
  3498. * @param x defines the x coordinate
  3499. * @param y defines the y coordinate
  3500. * @param z defines the z coordinate
  3501. * @param w defines the w coordinate
  3502. * @returns the updated current quaternion
  3503. */
  3504. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3505. /**
  3506. * Updates the current quaternion from the given float coordinates
  3507. * @param x defines the x coordinate
  3508. * @param y defines the y coordinate
  3509. * @param z defines the z coordinate
  3510. * @param w defines the w coordinate
  3511. * @returns the updated current quaternion
  3512. */
  3513. set(x: number, y: number, z: number, w: number): Quaternion;
  3514. /**
  3515. * Adds two quaternions
  3516. * @param other defines the second operand
  3517. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3518. */
  3519. add(other: DeepImmutable<Quaternion>): Quaternion;
  3520. /**
  3521. * Add a quaternion to the current one
  3522. * @param other defines the quaternion to add
  3523. * @returns the current quaternion
  3524. */
  3525. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3526. /**
  3527. * Subtract two quaternions
  3528. * @param other defines the second operand
  3529. * @returns a new quaternion as the subtraction result of the given one from the current one
  3530. */
  3531. subtract(other: Quaternion): Quaternion;
  3532. /**
  3533. * Multiplies the current quaternion by a scale factor
  3534. * @param value defines the scale factor
  3535. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3536. */
  3537. scale(value: number): Quaternion;
  3538. /**
  3539. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3540. * @param scale defines the scale factor
  3541. * @param result defines the Quaternion object where to store the result
  3542. * @returns the unmodified current quaternion
  3543. */
  3544. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3545. /**
  3546. * Multiplies in place the current quaternion by a scale factor
  3547. * @param value defines the scale factor
  3548. * @returns the current modified quaternion
  3549. */
  3550. scaleInPlace(value: number): Quaternion;
  3551. /**
  3552. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3553. * @param scale defines the scale factor
  3554. * @param result defines the Quaternion object where to store the result
  3555. * @returns the unmodified current quaternion
  3556. */
  3557. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3558. /**
  3559. * Multiplies two quaternions
  3560. * @param q1 defines the second operand
  3561. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3562. */
  3563. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3564. /**
  3565. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3566. * @param q1 defines the second operand
  3567. * @param result defines the target quaternion
  3568. * @returns the current quaternion
  3569. */
  3570. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3571. /**
  3572. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3573. * @param q1 defines the second operand
  3574. * @returns the currentupdated quaternion
  3575. */
  3576. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3577. /**
  3578. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3579. * @param ref defines the target quaternion
  3580. * @returns the current quaternion
  3581. */
  3582. conjugateToRef(ref: Quaternion): Quaternion;
  3583. /**
  3584. * Conjugates in place (1-q) the current quaternion
  3585. * @returns the current updated quaternion
  3586. */
  3587. conjugateInPlace(): Quaternion;
  3588. /**
  3589. * Conjugates in place (1-q) the current quaternion
  3590. * @returns a new quaternion
  3591. */
  3592. conjugate(): Quaternion;
  3593. /**
  3594. * Gets length of current quaternion
  3595. * @returns the quaternion length (float)
  3596. */
  3597. length(): number;
  3598. /**
  3599. * Normalize in place the current quaternion
  3600. * @returns the current updated quaternion
  3601. */
  3602. normalize(): Quaternion;
  3603. /**
  3604. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3605. * @param order is a reserved parameter and is ignore for now
  3606. * @returns a new Vector3 containing the Euler angles
  3607. */
  3608. toEulerAngles(order?: string): Vector3;
  3609. /**
  3610. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3611. * @param result defines the vector which will be filled with the Euler angles
  3612. * @param order is a reserved parameter and is ignore for now
  3613. * @returns the current unchanged quaternion
  3614. */
  3615. toEulerAnglesToRef(result: Vector3): Quaternion;
  3616. /**
  3617. * Updates the given rotation matrix with the current quaternion values
  3618. * @param result defines the target matrix
  3619. * @returns the current unchanged quaternion
  3620. */
  3621. toRotationMatrix(result: Matrix): Quaternion;
  3622. /**
  3623. * Updates the current quaternion from the given rotation matrix values
  3624. * @param matrix defines the source matrix
  3625. * @returns the current updated quaternion
  3626. */
  3627. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3628. /**
  3629. * Creates a new quaternion from a rotation matrix
  3630. * @param matrix defines the source matrix
  3631. * @returns a new quaternion created from the given rotation matrix values
  3632. */
  3633. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3634. /**
  3635. * Updates the given quaternion with the given rotation matrix values
  3636. * @param matrix defines the source matrix
  3637. * @param result defines the target quaternion
  3638. */
  3639. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3640. /**
  3641. * Returns the dot product (float) between the quaternions "left" and "right"
  3642. * @param left defines the left operand
  3643. * @param right defines the right operand
  3644. * @returns the dot product
  3645. */
  3646. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3647. /**
  3648. * Checks if the two quaternions are close to each other
  3649. * @param quat0 defines the first quaternion to check
  3650. * @param quat1 defines the second quaternion to check
  3651. * @returns true if the two quaternions are close to each other
  3652. */
  3653. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3654. /**
  3655. * Creates an empty quaternion
  3656. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3657. */
  3658. static Zero(): Quaternion;
  3659. /**
  3660. * Inverse a given quaternion
  3661. * @param q defines the source quaternion
  3662. * @returns a new quaternion as the inverted current quaternion
  3663. */
  3664. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3665. /**
  3666. * Inverse a given quaternion
  3667. * @param q defines the source quaternion
  3668. * @param result the quaternion the result will be stored in
  3669. * @returns the result quaternion
  3670. */
  3671. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3672. /**
  3673. * Creates an identity quaternion
  3674. * @returns the identity quaternion
  3675. */
  3676. static Identity(): Quaternion;
  3677. /**
  3678. * Gets a boolean indicating if the given quaternion is identity
  3679. * @param quaternion defines the quaternion to check
  3680. * @returns true if the quaternion is identity
  3681. */
  3682. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3683. /**
  3684. * Creates a quaternion from a rotation around an axis
  3685. * @param axis defines the axis to use
  3686. * @param angle defines the angle to use
  3687. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3688. */
  3689. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3690. /**
  3691. * Creates a rotation around an axis and stores it into the given quaternion
  3692. * @param axis defines the axis to use
  3693. * @param angle defines the angle to use
  3694. * @param result defines the target quaternion
  3695. * @returns the target quaternion
  3696. */
  3697. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3698. /**
  3699. * Creates a new quaternion from data stored into an array
  3700. * @param array defines the data source
  3701. * @param offset defines the offset in the source array where the data starts
  3702. * @returns a new quaternion
  3703. */
  3704. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3705. /**
  3706. * Create a quaternion from Euler rotation angles
  3707. * @param x Pitch
  3708. * @param y Yaw
  3709. * @param z Roll
  3710. * @returns the new Quaternion
  3711. */
  3712. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3713. /**
  3714. * Updates a quaternion from Euler rotation angles
  3715. * @param x Pitch
  3716. * @param y Yaw
  3717. * @param z Roll
  3718. * @param result the quaternion to store the result
  3719. * @returns the updated quaternion
  3720. */
  3721. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3722. /**
  3723. * Create a quaternion from Euler rotation vector
  3724. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3725. * @returns the new Quaternion
  3726. */
  3727. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3728. /**
  3729. * Updates a quaternion from Euler rotation vector
  3730. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3731. * @param result the quaternion to store the result
  3732. * @returns the updated quaternion
  3733. */
  3734. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3735. /**
  3736. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3737. * @param yaw defines the rotation around Y axis
  3738. * @param pitch defines the rotation around X axis
  3739. * @param roll defines the rotation around Z axis
  3740. * @returns the new quaternion
  3741. */
  3742. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3743. /**
  3744. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3745. * @param yaw defines the rotation around Y axis
  3746. * @param pitch defines the rotation around X axis
  3747. * @param roll defines the rotation around Z axis
  3748. * @param result defines the target quaternion
  3749. */
  3750. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3751. /**
  3752. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3753. * @param alpha defines the rotation around first axis
  3754. * @param beta defines the rotation around second axis
  3755. * @param gamma defines the rotation around third axis
  3756. * @returns the new quaternion
  3757. */
  3758. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3759. /**
  3760. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3761. * @param alpha defines the rotation around first axis
  3762. * @param beta defines the rotation around second axis
  3763. * @param gamma defines the rotation around third axis
  3764. * @param result defines the target quaternion
  3765. */
  3766. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3767. /**
  3768. * 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)
  3769. * @param axis1 defines the first axis
  3770. * @param axis2 defines the second axis
  3771. * @param axis3 defines the third axis
  3772. * @returns the new quaternion
  3773. */
  3774. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3775. /**
  3776. * 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
  3777. * @param axis1 defines the first axis
  3778. * @param axis2 defines the second axis
  3779. * @param axis3 defines the third axis
  3780. * @param ref defines the target quaternion
  3781. */
  3782. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3783. /**
  3784. * Interpolates between two quaternions
  3785. * @param left defines first quaternion
  3786. * @param right defines second quaternion
  3787. * @param amount defines the gradient to use
  3788. * @returns the new interpolated quaternion
  3789. */
  3790. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3791. /**
  3792. * Interpolates between two quaternions and stores it into a target quaternion
  3793. * @param left defines first quaternion
  3794. * @param right defines second quaternion
  3795. * @param amount defines the gradient to use
  3796. * @param result defines the target quaternion
  3797. */
  3798. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3799. /**
  3800. * Interpolate between two quaternions using Hermite interpolation
  3801. * @param value1 defines first quaternion
  3802. * @param tangent1 defines the incoming tangent
  3803. * @param value2 defines second quaternion
  3804. * @param tangent2 defines the outgoing tangent
  3805. * @param amount defines the target quaternion
  3806. * @returns the new interpolated quaternion
  3807. */
  3808. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3809. }
  3810. /**
  3811. * Class used to store matrix data (4x4)
  3812. */
  3813. export class Matrix {
  3814. private static _updateFlagSeed;
  3815. private static _identityReadOnly;
  3816. private _isIdentity;
  3817. private _isIdentityDirty;
  3818. private _isIdentity3x2;
  3819. private _isIdentity3x2Dirty;
  3820. /**
  3821. * Gets the update flag of the matrix which is an unique number for the matrix.
  3822. * It will be incremented every time the matrix data change.
  3823. * You can use it to speed the comparison between two versions of the same matrix.
  3824. */
  3825. updateFlag: number;
  3826. private readonly _m;
  3827. /**
  3828. * Gets the internal data of the matrix
  3829. */
  3830. get m(): DeepImmutable<Float32Array>;
  3831. /** @hidden */
  3832. _markAsUpdated(): void;
  3833. /** @hidden */
  3834. private _updateIdentityStatus;
  3835. /**
  3836. * Creates an empty matrix (filled with zeros)
  3837. */
  3838. constructor();
  3839. /**
  3840. * Check if the current matrix is identity
  3841. * @returns true is the matrix is the identity matrix
  3842. */
  3843. isIdentity(): boolean;
  3844. /**
  3845. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3846. * @returns true is the matrix is the identity matrix
  3847. */
  3848. isIdentityAs3x2(): boolean;
  3849. /**
  3850. * Gets the determinant of the matrix
  3851. * @returns the matrix determinant
  3852. */
  3853. determinant(): number;
  3854. /**
  3855. * Returns the matrix as a Float32Array
  3856. * @returns the matrix underlying array
  3857. */
  3858. toArray(): DeepImmutable<Float32Array>;
  3859. /**
  3860. * Returns the matrix as a Float32Array
  3861. * @returns the matrix underlying array.
  3862. */
  3863. asArray(): DeepImmutable<Float32Array>;
  3864. /**
  3865. * Inverts the current matrix in place
  3866. * @returns the current inverted matrix
  3867. */
  3868. invert(): Matrix;
  3869. /**
  3870. * Sets all the matrix elements to zero
  3871. * @returns the current matrix
  3872. */
  3873. reset(): Matrix;
  3874. /**
  3875. * Adds the current matrix with a second one
  3876. * @param other defines the matrix to add
  3877. * @returns a new matrix as the addition of the current matrix and the given one
  3878. */
  3879. add(other: DeepImmutable<Matrix>): Matrix;
  3880. /**
  3881. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3882. * @param other defines the matrix to add
  3883. * @param result defines the target matrix
  3884. * @returns the current matrix
  3885. */
  3886. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3887. /**
  3888. * Adds in place the given matrix to the current matrix
  3889. * @param other defines the second operand
  3890. * @returns the current updated matrix
  3891. */
  3892. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3893. /**
  3894. * Sets the given matrix to the current inverted Matrix
  3895. * @param other defines the target matrix
  3896. * @returns the unmodified current matrix
  3897. */
  3898. invertToRef(other: Matrix): Matrix;
  3899. /**
  3900. * add a value at the specified position in the current Matrix
  3901. * @param index the index of the value within the matrix. between 0 and 15.
  3902. * @param value the value to be added
  3903. * @returns the current updated matrix
  3904. */
  3905. addAtIndex(index: number, value: number): Matrix;
  3906. /**
  3907. * mutiply the specified position in the current Matrix by a value
  3908. * @param index the index of the value within the matrix. between 0 and 15.
  3909. * @param value the value to be added
  3910. * @returns the current updated matrix
  3911. */
  3912. multiplyAtIndex(index: number, value: number): Matrix;
  3913. /**
  3914. * Inserts the translation vector (using 3 floats) in the current matrix
  3915. * @param x defines the 1st component of the translation
  3916. * @param y defines the 2nd component of the translation
  3917. * @param z defines the 3rd component of the translation
  3918. * @returns the current updated matrix
  3919. */
  3920. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3921. /**
  3922. * Adds the translation vector (using 3 floats) in the current matrix
  3923. * @param x defines the 1st component of the translation
  3924. * @param y defines the 2nd component of the translation
  3925. * @param z defines the 3rd component of the translation
  3926. * @returns the current updated matrix
  3927. */
  3928. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3929. /**
  3930. * Inserts the translation vector in the current matrix
  3931. * @param vector3 defines the translation to insert
  3932. * @returns the current updated matrix
  3933. */
  3934. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3935. /**
  3936. * Gets the translation value of the current matrix
  3937. * @returns a new Vector3 as the extracted translation from the matrix
  3938. */
  3939. getTranslation(): Vector3;
  3940. /**
  3941. * Fill a Vector3 with the extracted translation from the matrix
  3942. * @param result defines the Vector3 where to store the translation
  3943. * @returns the current matrix
  3944. */
  3945. getTranslationToRef(result: Vector3): Matrix;
  3946. /**
  3947. * Remove rotation and scaling part from the matrix
  3948. * @returns the updated matrix
  3949. */
  3950. removeRotationAndScaling(): Matrix;
  3951. /**
  3952. * Multiply two matrices
  3953. * @param other defines the second operand
  3954. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3955. */
  3956. multiply(other: DeepImmutable<Matrix>): Matrix;
  3957. /**
  3958. * Copy the current matrix from the given one
  3959. * @param other defines the source matrix
  3960. * @returns the current updated matrix
  3961. */
  3962. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3963. /**
  3964. * Populates the given array from the starting index with the current matrix values
  3965. * @param array defines the target array
  3966. * @param offset defines the offset in the target array where to start storing values
  3967. * @returns the current matrix
  3968. */
  3969. copyToArray(array: Float32Array, offset?: number): Matrix;
  3970. /**
  3971. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3972. * @param other defines the second operand
  3973. * @param result defines the matrix where to store the multiplication
  3974. * @returns the current matrix
  3975. */
  3976. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3977. /**
  3978. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  3979. * @param other defines the second operand
  3980. * @param result defines the array where to store the multiplication
  3981. * @param offset defines the offset in the target array where to start storing values
  3982. * @returns the current matrix
  3983. */
  3984. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3985. /**
  3986. * Check equality between this matrix and a second one
  3987. * @param value defines the second matrix to compare
  3988. * @returns true is the current matrix and the given one values are strictly equal
  3989. */
  3990. equals(value: DeepImmutable<Matrix>): boolean;
  3991. /**
  3992. * Clone the current matrix
  3993. * @returns a new matrix from the current matrix
  3994. */
  3995. clone(): Matrix;
  3996. /**
  3997. * Returns the name of the current matrix class
  3998. * @returns the string "Matrix"
  3999. */
  4000. getClassName(): string;
  4001. /**
  4002. * Gets the hash code of the current matrix
  4003. * @returns the hash code
  4004. */
  4005. getHashCode(): number;
  4006. /**
  4007. * Decomposes the current Matrix into a translation, rotation and scaling components
  4008. * @param scale defines the scale vector3 given as a reference to update
  4009. * @param rotation defines the rotation quaternion given as a reference to update
  4010. * @param translation defines the translation vector3 given as a reference to update
  4011. * @returns true if operation was successful
  4012. */
  4013. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4014. /**
  4015. * Gets specific row of the matrix
  4016. * @param index defines the number of the row to get
  4017. * @returns the index-th row of the current matrix as a new Vector4
  4018. */
  4019. getRow(index: number): Nullable<Vector4>;
  4020. /**
  4021. * Sets the index-th row of the current matrix to the vector4 values
  4022. * @param index defines the number of the row to set
  4023. * @param row defines the target vector4
  4024. * @returns the updated current matrix
  4025. */
  4026. setRow(index: number, row: Vector4): Matrix;
  4027. /**
  4028. * Compute the transpose of the matrix
  4029. * @returns the new transposed matrix
  4030. */
  4031. transpose(): Matrix;
  4032. /**
  4033. * Compute the transpose of the matrix and store it in a given matrix
  4034. * @param result defines the target matrix
  4035. * @returns the current matrix
  4036. */
  4037. transposeToRef(result: Matrix): Matrix;
  4038. /**
  4039. * Sets the index-th row of the current matrix with the given 4 x float values
  4040. * @param index defines the row index
  4041. * @param x defines the x component to set
  4042. * @param y defines the y component to set
  4043. * @param z defines the z component to set
  4044. * @param w defines the w component to set
  4045. * @returns the updated current matrix
  4046. */
  4047. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4048. /**
  4049. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4050. * @param scale defines the scale factor
  4051. * @returns a new matrix
  4052. */
  4053. scale(scale: number): Matrix;
  4054. /**
  4055. * Scale the current matrix values by a factor to a given result matrix
  4056. * @param scale defines the scale factor
  4057. * @param result defines the matrix to store the result
  4058. * @returns the current matrix
  4059. */
  4060. scaleToRef(scale: number, result: Matrix): Matrix;
  4061. /**
  4062. * Scale the current matrix values by a factor and add the result to a given matrix
  4063. * @param scale defines the scale factor
  4064. * @param result defines the Matrix to store the result
  4065. * @returns the current matrix
  4066. */
  4067. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4068. /**
  4069. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4070. * @param ref matrix to store the result
  4071. */
  4072. toNormalMatrix(ref: Matrix): void;
  4073. /**
  4074. * Gets only rotation part of the current matrix
  4075. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4076. */
  4077. getRotationMatrix(): Matrix;
  4078. /**
  4079. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4080. * @param result defines the target matrix to store data to
  4081. * @returns the current matrix
  4082. */
  4083. getRotationMatrixToRef(result: Matrix): Matrix;
  4084. /**
  4085. * Toggles model matrix from being right handed to left handed in place and vice versa
  4086. */
  4087. toggleModelMatrixHandInPlace(): void;
  4088. /**
  4089. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4090. */
  4091. toggleProjectionMatrixHandInPlace(): void;
  4092. /**
  4093. * Creates a matrix from an array
  4094. * @param array defines the source array
  4095. * @param offset defines an offset in the source array
  4096. * @returns a new Matrix set from the starting index of the given array
  4097. */
  4098. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4099. /**
  4100. * Copy the content of an array into a given matrix
  4101. * @param array defines the source array
  4102. * @param offset defines an offset in the source array
  4103. * @param result defines the target matrix
  4104. */
  4105. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4106. /**
  4107. * Stores an array into a matrix after having multiplied each component by a given factor
  4108. * @param array defines the source array
  4109. * @param offset defines the offset in the source array
  4110. * @param scale defines the scaling factor
  4111. * @param result defines the target matrix
  4112. */
  4113. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4114. /**
  4115. * Gets an identity matrix that must not be updated
  4116. */
  4117. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4118. /**
  4119. * Stores a list of values (16) inside a given matrix
  4120. * @param initialM11 defines 1st value of 1st row
  4121. * @param initialM12 defines 2nd value of 1st row
  4122. * @param initialM13 defines 3rd value of 1st row
  4123. * @param initialM14 defines 4th value of 1st row
  4124. * @param initialM21 defines 1st value of 2nd row
  4125. * @param initialM22 defines 2nd value of 2nd row
  4126. * @param initialM23 defines 3rd value of 2nd row
  4127. * @param initialM24 defines 4th value of 2nd row
  4128. * @param initialM31 defines 1st value of 3rd row
  4129. * @param initialM32 defines 2nd value of 3rd row
  4130. * @param initialM33 defines 3rd value of 3rd row
  4131. * @param initialM34 defines 4th value of 3rd row
  4132. * @param initialM41 defines 1st value of 4th row
  4133. * @param initialM42 defines 2nd value of 4th row
  4134. * @param initialM43 defines 3rd value of 4th row
  4135. * @param initialM44 defines 4th value of 4th row
  4136. * @param result defines the target matrix
  4137. */
  4138. 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;
  4139. /**
  4140. * Creates new matrix from a list of values (16)
  4141. * @param initialM11 defines 1st value of 1st row
  4142. * @param initialM12 defines 2nd value of 1st row
  4143. * @param initialM13 defines 3rd value of 1st row
  4144. * @param initialM14 defines 4th value of 1st row
  4145. * @param initialM21 defines 1st value of 2nd row
  4146. * @param initialM22 defines 2nd value of 2nd row
  4147. * @param initialM23 defines 3rd value of 2nd row
  4148. * @param initialM24 defines 4th value of 2nd row
  4149. * @param initialM31 defines 1st value of 3rd row
  4150. * @param initialM32 defines 2nd value of 3rd row
  4151. * @param initialM33 defines 3rd value of 3rd row
  4152. * @param initialM34 defines 4th value of 3rd row
  4153. * @param initialM41 defines 1st value of 4th row
  4154. * @param initialM42 defines 2nd value of 4th row
  4155. * @param initialM43 defines 3rd value of 4th row
  4156. * @param initialM44 defines 4th value of 4th row
  4157. * @returns the new matrix
  4158. */
  4159. 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;
  4160. /**
  4161. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4162. * @param scale defines the scale vector3
  4163. * @param rotation defines the rotation quaternion
  4164. * @param translation defines the translation vector3
  4165. * @returns a new matrix
  4166. */
  4167. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4168. /**
  4169. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4170. * @param scale defines the scale vector3
  4171. * @param rotation defines the rotation quaternion
  4172. * @param translation defines the translation vector3
  4173. * @param result defines the target matrix
  4174. */
  4175. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4176. /**
  4177. * Creates a new identity matrix
  4178. * @returns a new identity matrix
  4179. */
  4180. static Identity(): Matrix;
  4181. /**
  4182. * Creates a new identity matrix and stores the result in a given matrix
  4183. * @param result defines the target matrix
  4184. */
  4185. static IdentityToRef(result: Matrix): void;
  4186. /**
  4187. * Creates a new zero matrix
  4188. * @returns a new zero matrix
  4189. */
  4190. static Zero(): Matrix;
  4191. /**
  4192. * Creates a new rotation matrix for "angle" radians around the X axis
  4193. * @param angle defines the angle (in radians) to use
  4194. * @return the new matrix
  4195. */
  4196. static RotationX(angle: number): Matrix;
  4197. /**
  4198. * Creates a new matrix as the invert of a given matrix
  4199. * @param source defines the source matrix
  4200. * @returns the new matrix
  4201. */
  4202. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4203. /**
  4204. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4205. * @param angle defines the angle (in radians) to use
  4206. * @param result defines the target matrix
  4207. */
  4208. static RotationXToRef(angle: number, result: Matrix): void;
  4209. /**
  4210. * Creates a new rotation matrix for "angle" radians around the Y axis
  4211. * @param angle defines the angle (in radians) to use
  4212. * @return the new matrix
  4213. */
  4214. static RotationY(angle: number): Matrix;
  4215. /**
  4216. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4217. * @param angle defines the angle (in radians) to use
  4218. * @param result defines the target matrix
  4219. */
  4220. static RotationYToRef(angle: number, result: Matrix): void;
  4221. /**
  4222. * Creates a new rotation matrix for "angle" radians around the Z axis
  4223. * @param angle defines the angle (in radians) to use
  4224. * @return the new matrix
  4225. */
  4226. static RotationZ(angle: number): Matrix;
  4227. /**
  4228. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4229. * @param angle defines the angle (in radians) to use
  4230. * @param result defines the target matrix
  4231. */
  4232. static RotationZToRef(angle: number, result: Matrix): void;
  4233. /**
  4234. * Creates a new rotation matrix for "angle" radians around the given axis
  4235. * @param axis defines the axis to use
  4236. * @param angle defines the angle (in radians) to use
  4237. * @return the new matrix
  4238. */
  4239. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4240. /**
  4241. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4242. * @param axis defines the axis to use
  4243. * @param angle defines the angle (in radians) to use
  4244. * @param result defines the target matrix
  4245. */
  4246. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4247. /**
  4248. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4249. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4250. * @param from defines the vector to align
  4251. * @param to defines the vector to align to
  4252. * @param result defines the target matrix
  4253. */
  4254. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4255. /**
  4256. * Creates a rotation matrix
  4257. * @param yaw defines the yaw angle in radians (Y axis)
  4258. * @param pitch defines the pitch angle in radians (X axis)
  4259. * @param roll defines the roll angle in radians (X axis)
  4260. * @returns the new rotation matrix
  4261. */
  4262. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4263. /**
  4264. * Creates a rotation matrix and stores it in a given matrix
  4265. * @param yaw defines the yaw angle in radians (Y axis)
  4266. * @param pitch defines the pitch angle in radians (X axis)
  4267. * @param roll defines the roll angle in radians (X axis)
  4268. * @param result defines the target matrix
  4269. */
  4270. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4271. /**
  4272. * Creates a scaling matrix
  4273. * @param x defines the scale factor on X axis
  4274. * @param y defines the scale factor on Y axis
  4275. * @param z defines the scale factor on Z axis
  4276. * @returns the new matrix
  4277. */
  4278. static Scaling(x: number, y: number, z: number): Matrix;
  4279. /**
  4280. * Creates a scaling matrix and stores it in a given matrix
  4281. * @param x defines the scale factor on X axis
  4282. * @param y defines the scale factor on Y axis
  4283. * @param z defines the scale factor on Z axis
  4284. * @param result defines the target matrix
  4285. */
  4286. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4287. /**
  4288. * Creates a translation matrix
  4289. * @param x defines the translation on X axis
  4290. * @param y defines the translation on Y axis
  4291. * @param z defines the translationon Z axis
  4292. * @returns the new matrix
  4293. */
  4294. static Translation(x: number, y: number, z: number): Matrix;
  4295. /**
  4296. * Creates a translation matrix and stores it in a given matrix
  4297. * @param x defines the translation on X axis
  4298. * @param y defines the translation on Y axis
  4299. * @param z defines the translationon Z axis
  4300. * @param result defines the target matrix
  4301. */
  4302. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4303. /**
  4304. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4305. * @param startValue defines the start value
  4306. * @param endValue defines the end value
  4307. * @param gradient defines the gradient factor
  4308. * @returns the new matrix
  4309. */
  4310. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4311. /**
  4312. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4313. * @param startValue defines the start value
  4314. * @param endValue defines the end value
  4315. * @param gradient defines the gradient factor
  4316. * @param result defines the Matrix object where to store data
  4317. */
  4318. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4319. /**
  4320. * Builds a new matrix whose values are computed by:
  4321. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4322. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4323. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4324. * @param startValue defines the first matrix
  4325. * @param endValue defines the second matrix
  4326. * @param gradient defines the gradient between the two matrices
  4327. * @returns the new matrix
  4328. */
  4329. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4330. /**
  4331. * Update a matrix to values which are computed by:
  4332. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4333. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4334. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4335. * @param startValue defines the first matrix
  4336. * @param endValue defines the second matrix
  4337. * @param gradient defines the gradient between the two matrices
  4338. * @param result defines the target matrix
  4339. */
  4340. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4341. /**
  4342. * 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"
  4343. * This function works in left handed mode
  4344. * @param eye defines the final position of the entity
  4345. * @param target defines where the entity should look at
  4346. * @param up defines the up vector for the entity
  4347. * @returns the new matrix
  4348. */
  4349. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4350. /**
  4351. * 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".
  4352. * This function works in left handed mode
  4353. * @param eye defines the final position of the entity
  4354. * @param target defines where the entity should look at
  4355. * @param up defines the up vector for the entity
  4356. * @param result defines the target matrix
  4357. */
  4358. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4359. /**
  4360. * 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"
  4361. * This function works in right handed mode
  4362. * @param eye defines the final position of the entity
  4363. * @param target defines where the entity should look at
  4364. * @param up defines the up vector for the entity
  4365. * @returns the new matrix
  4366. */
  4367. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4368. /**
  4369. * 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".
  4370. * This function works in right handed mode
  4371. * @param eye defines the final position of the entity
  4372. * @param target defines where the entity should look at
  4373. * @param up defines the up vector for the entity
  4374. * @param result defines the target matrix
  4375. */
  4376. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4377. /**
  4378. * Create a left-handed orthographic projection matrix
  4379. * @param width defines the viewport width
  4380. * @param height defines the viewport height
  4381. * @param znear defines the near clip plane
  4382. * @param zfar defines the far clip plane
  4383. * @returns a new matrix as a left-handed orthographic projection matrix
  4384. */
  4385. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4386. /**
  4387. * Store a left-handed orthographic projection to a given matrix
  4388. * @param width defines the viewport width
  4389. * @param height defines the viewport height
  4390. * @param znear defines the near clip plane
  4391. * @param zfar defines the far clip plane
  4392. * @param result defines the target matrix
  4393. */
  4394. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4395. /**
  4396. * Create a left-handed orthographic projection matrix
  4397. * @param left defines the viewport left coordinate
  4398. * @param right defines the viewport right coordinate
  4399. * @param bottom defines the viewport bottom coordinate
  4400. * @param top defines the viewport top coordinate
  4401. * @param znear defines the near clip plane
  4402. * @param zfar defines the far clip plane
  4403. * @returns a new matrix as a left-handed orthographic projection matrix
  4404. */
  4405. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4406. /**
  4407. * Stores a left-handed orthographic projection into a given matrix
  4408. * @param left defines the viewport left coordinate
  4409. * @param right defines the viewport right coordinate
  4410. * @param bottom defines the viewport bottom coordinate
  4411. * @param top defines the viewport top coordinate
  4412. * @param znear defines the near clip plane
  4413. * @param zfar defines the far clip plane
  4414. * @param result defines the target matrix
  4415. */
  4416. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4417. /**
  4418. * Creates a right-handed orthographic projection matrix
  4419. * @param left defines the viewport left coordinate
  4420. * @param right defines the viewport right coordinate
  4421. * @param bottom defines the viewport bottom coordinate
  4422. * @param top defines the viewport top coordinate
  4423. * @param znear defines the near clip plane
  4424. * @param zfar defines the far clip plane
  4425. * @returns a new matrix as a right-handed orthographic projection matrix
  4426. */
  4427. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4428. /**
  4429. * Stores a right-handed orthographic projection into a given matrix
  4430. * @param left defines the viewport left coordinate
  4431. * @param right defines the viewport right coordinate
  4432. * @param bottom defines the viewport bottom coordinate
  4433. * @param top defines the viewport top coordinate
  4434. * @param znear defines the near clip plane
  4435. * @param zfar defines the far clip plane
  4436. * @param result defines the target matrix
  4437. */
  4438. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4439. /**
  4440. * Creates a left-handed perspective projection matrix
  4441. * @param width defines the viewport width
  4442. * @param height defines the viewport height
  4443. * @param znear defines the near clip plane
  4444. * @param zfar defines the far clip plane
  4445. * @returns a new matrix as a left-handed perspective projection matrix
  4446. */
  4447. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4448. /**
  4449. * Creates a left-handed perspective projection matrix
  4450. * @param fov defines the horizontal field of view
  4451. * @param aspect defines the aspect ratio
  4452. * @param znear defines the near clip plane
  4453. * @param zfar defines the far clip plane
  4454. * @returns a new matrix as a left-handed perspective projection matrix
  4455. */
  4456. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4457. /**
  4458. * Stores a left-handed perspective projection into a given matrix
  4459. * @param fov defines the horizontal field of view
  4460. * @param aspect defines the aspect ratio
  4461. * @param znear defines the near clip plane
  4462. * @param zfar defines the far clip plane
  4463. * @param result defines the target matrix
  4464. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4465. */
  4466. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4467. /**
  4468. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4469. * @param fov defines the horizontal field of view
  4470. * @param aspect defines the aspect ratio
  4471. * @param znear defines the near clip plane
  4472. * @param zfar not used as infinity is used as far clip
  4473. * @param result defines the target matrix
  4474. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4475. */
  4476. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4477. /**
  4478. * Creates a right-handed perspective projection matrix
  4479. * @param fov defines the horizontal field of view
  4480. * @param aspect defines the aspect ratio
  4481. * @param znear defines the near clip plane
  4482. * @param zfar defines the far clip plane
  4483. * @returns a new matrix as a right-handed perspective projection matrix
  4484. */
  4485. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4486. /**
  4487. * Stores a right-handed perspective projection into a given matrix
  4488. * @param fov defines the horizontal field of view
  4489. * @param aspect defines the aspect ratio
  4490. * @param znear defines the near clip plane
  4491. * @param zfar defines the far clip plane
  4492. * @param result defines the target matrix
  4493. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4494. */
  4495. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4496. /**
  4497. * Stores a right-handed perspective projection into a given matrix
  4498. * @param fov defines the horizontal field of view
  4499. * @param aspect defines the aspect ratio
  4500. * @param znear defines the near clip plane
  4501. * @param zfar not used as infinity is used as far clip
  4502. * @param result defines the target matrix
  4503. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4504. */
  4505. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4506. /**
  4507. * Stores a perspective projection for WebVR info a given matrix
  4508. * @param fov defines the field of view
  4509. * @param znear defines the near clip plane
  4510. * @param zfar defines the far clip plane
  4511. * @param result defines the target matrix
  4512. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4513. */
  4514. static PerspectiveFovWebVRToRef(fov: {
  4515. upDegrees: number;
  4516. downDegrees: number;
  4517. leftDegrees: number;
  4518. rightDegrees: number;
  4519. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4520. /**
  4521. * Computes a complete transformation matrix
  4522. * @param viewport defines the viewport to use
  4523. * @param world defines the world matrix
  4524. * @param view defines the view matrix
  4525. * @param projection defines the projection matrix
  4526. * @param zmin defines the near clip plane
  4527. * @param zmax defines the far clip plane
  4528. * @returns the transformation matrix
  4529. */
  4530. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4531. /**
  4532. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4533. * @param matrix defines the matrix to use
  4534. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4535. */
  4536. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4537. /**
  4538. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4539. * @param matrix defines the matrix to use
  4540. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4541. */
  4542. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4543. /**
  4544. * Compute the transpose of a given matrix
  4545. * @param matrix defines the matrix to transpose
  4546. * @returns the new matrix
  4547. */
  4548. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4549. /**
  4550. * Compute the transpose of a matrix and store it in a target matrix
  4551. * @param matrix defines the matrix to transpose
  4552. * @param result defines the target matrix
  4553. */
  4554. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4555. /**
  4556. * Computes a reflection matrix from a plane
  4557. * @param plane defines the reflection plane
  4558. * @returns a new matrix
  4559. */
  4560. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4561. /**
  4562. * Computes a reflection matrix from a plane
  4563. * @param plane defines the reflection plane
  4564. * @param result defines the target matrix
  4565. */
  4566. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4567. /**
  4568. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4569. * @param xaxis defines the value of the 1st axis
  4570. * @param yaxis defines the value of the 2nd axis
  4571. * @param zaxis defines the value of the 3rd axis
  4572. * @param result defines the target matrix
  4573. */
  4574. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4575. /**
  4576. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4577. * @param quat defines the quaternion to use
  4578. * @param result defines the target matrix
  4579. */
  4580. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4581. }
  4582. /**
  4583. * @hidden
  4584. */
  4585. export class TmpVectors {
  4586. static Vector2: Vector2[];
  4587. static Vector3: Vector3[];
  4588. static Vector4: Vector4[];
  4589. static Quaternion: Quaternion[];
  4590. static Matrix: Matrix[];
  4591. }
  4592. }
  4593. declare module BABYLON {
  4594. /**
  4595. * Defines potential orientation for back face culling
  4596. */
  4597. export enum Orientation {
  4598. /**
  4599. * Clockwise
  4600. */
  4601. CW = 0,
  4602. /** Counter clockwise */
  4603. CCW = 1
  4604. }
  4605. /** Class used to represent a Bezier curve */
  4606. export class BezierCurve {
  4607. /**
  4608. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4609. * @param t defines the time
  4610. * @param x1 defines the left coordinate on X axis
  4611. * @param y1 defines the left coordinate on Y axis
  4612. * @param x2 defines the right coordinate on X axis
  4613. * @param y2 defines the right coordinate on Y axis
  4614. * @returns the interpolated value
  4615. */
  4616. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4617. }
  4618. /**
  4619. * Defines angle representation
  4620. */
  4621. export class Angle {
  4622. private _radians;
  4623. /**
  4624. * Creates an Angle object of "radians" radians (float).
  4625. * @param radians the angle in radians
  4626. */
  4627. constructor(radians: number);
  4628. /**
  4629. * Get value in degrees
  4630. * @returns the Angle value in degrees (float)
  4631. */
  4632. degrees(): number;
  4633. /**
  4634. * Get value in radians
  4635. * @returns the Angle value in radians (float)
  4636. */
  4637. radians(): number;
  4638. /**
  4639. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4640. * @param a defines first vector
  4641. * @param b defines second vector
  4642. * @returns a new Angle
  4643. */
  4644. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4645. /**
  4646. * Gets a new Angle object from the given float in radians
  4647. * @param radians defines the angle value in radians
  4648. * @returns a new Angle
  4649. */
  4650. static FromRadians(radians: number): Angle;
  4651. /**
  4652. * Gets a new Angle object from the given float in degrees
  4653. * @param degrees defines the angle value in degrees
  4654. * @returns a new Angle
  4655. */
  4656. static FromDegrees(degrees: number): Angle;
  4657. }
  4658. /**
  4659. * This represents an arc in a 2d space.
  4660. */
  4661. export class Arc2 {
  4662. /** Defines the start point of the arc */
  4663. startPoint: Vector2;
  4664. /** Defines the mid point of the arc */
  4665. midPoint: Vector2;
  4666. /** Defines the end point of the arc */
  4667. endPoint: Vector2;
  4668. /**
  4669. * Defines the center point of the arc.
  4670. */
  4671. centerPoint: Vector2;
  4672. /**
  4673. * Defines the radius of the arc.
  4674. */
  4675. radius: number;
  4676. /**
  4677. * Defines the angle of the arc (from mid point to end point).
  4678. */
  4679. angle: Angle;
  4680. /**
  4681. * Defines the start angle of the arc (from start point to middle point).
  4682. */
  4683. startAngle: Angle;
  4684. /**
  4685. * Defines the orientation of the arc (clock wise/counter clock wise).
  4686. */
  4687. orientation: Orientation;
  4688. /**
  4689. * Creates an Arc object from the three given points : start, middle and end.
  4690. * @param startPoint Defines the start point of the arc
  4691. * @param midPoint Defines the midlle point of the arc
  4692. * @param endPoint Defines the end point of the arc
  4693. */
  4694. constructor(
  4695. /** Defines the start point of the arc */
  4696. startPoint: Vector2,
  4697. /** Defines the mid point of the arc */
  4698. midPoint: Vector2,
  4699. /** Defines the end point of the arc */
  4700. endPoint: Vector2);
  4701. }
  4702. /**
  4703. * Represents a 2D path made up of multiple 2D points
  4704. */
  4705. export class Path2 {
  4706. private _points;
  4707. private _length;
  4708. /**
  4709. * If the path start and end point are the same
  4710. */
  4711. closed: boolean;
  4712. /**
  4713. * Creates a Path2 object from the starting 2D coordinates x and y.
  4714. * @param x the starting points x value
  4715. * @param y the starting points y value
  4716. */
  4717. constructor(x: number, y: number);
  4718. /**
  4719. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4720. * @param x the added points x value
  4721. * @param y the added points y value
  4722. * @returns the updated Path2.
  4723. */
  4724. addLineTo(x: number, y: number): Path2;
  4725. /**
  4726. * 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.
  4727. * @param midX middle point x value
  4728. * @param midY middle point y value
  4729. * @param endX end point x value
  4730. * @param endY end point y value
  4731. * @param numberOfSegments (default: 36)
  4732. * @returns the updated Path2.
  4733. */
  4734. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4735. /**
  4736. * Closes the Path2.
  4737. * @returns the Path2.
  4738. */
  4739. close(): Path2;
  4740. /**
  4741. * Gets the sum of the distance between each sequential point in the path
  4742. * @returns the Path2 total length (float).
  4743. */
  4744. length(): number;
  4745. /**
  4746. * Gets the points which construct the path
  4747. * @returns the Path2 internal array of points.
  4748. */
  4749. getPoints(): Vector2[];
  4750. /**
  4751. * Retreives the point at the distance aways from the starting point
  4752. * @param normalizedLengthPosition the length along the path to retreive the point from
  4753. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4754. */
  4755. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4756. /**
  4757. * Creates a new path starting from an x and y position
  4758. * @param x starting x value
  4759. * @param y starting y value
  4760. * @returns a new Path2 starting at the coordinates (x, y).
  4761. */
  4762. static StartingAt(x: number, y: number): Path2;
  4763. }
  4764. /**
  4765. * Represents a 3D path made up of multiple 3D points
  4766. */
  4767. export class Path3D {
  4768. /**
  4769. * an array of Vector3, the curve axis of the Path3D
  4770. */
  4771. path: Vector3[];
  4772. private _curve;
  4773. private _distances;
  4774. private _tangents;
  4775. private _normals;
  4776. private _binormals;
  4777. private _raw;
  4778. private _alignTangentsWithPath;
  4779. private readonly _pointAtData;
  4780. /**
  4781. * new Path3D(path, normal, raw)
  4782. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4783. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4784. * @param path an array of Vector3, the curve axis of the Path3D
  4785. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4786. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4787. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  4788. */
  4789. constructor(
  4790. /**
  4791. * an array of Vector3, the curve axis of the Path3D
  4792. */
  4793. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  4794. /**
  4795. * Returns the Path3D array of successive Vector3 designing its curve.
  4796. * @returns the Path3D array of successive Vector3 designing its curve.
  4797. */
  4798. getCurve(): Vector3[];
  4799. /**
  4800. * Returns the Path3D array of successive Vector3 designing its curve.
  4801. * @returns the Path3D array of successive Vector3 designing its curve.
  4802. */
  4803. getPoints(): Vector3[];
  4804. /**
  4805. * @returns the computed length (float) of the path.
  4806. */
  4807. length(): number;
  4808. /**
  4809. * Returns an array populated with tangent vectors on each Path3D curve point.
  4810. * @returns an array populated with tangent vectors on each Path3D curve point.
  4811. */
  4812. getTangents(): Vector3[];
  4813. /**
  4814. * Returns an array populated with normal vectors on each Path3D curve point.
  4815. * @returns an array populated with normal vectors on each Path3D curve point.
  4816. */
  4817. getNormals(): Vector3[];
  4818. /**
  4819. * Returns an array populated with binormal vectors on each Path3D curve point.
  4820. * @returns an array populated with binormal vectors on each Path3D curve point.
  4821. */
  4822. getBinormals(): Vector3[];
  4823. /**
  4824. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4825. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4826. */
  4827. getDistances(): number[];
  4828. /**
  4829. * Returns an interpolated point along this path
  4830. * @param position the position of the point along this path, from 0.0 to 1.0
  4831. * @returns a new Vector3 as the point
  4832. */
  4833. getPointAt(position: number): Vector3;
  4834. /**
  4835. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4836. * @param position the position of the point along this path, from 0.0 to 1.0
  4837. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  4838. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  4839. */
  4840. getTangentAt(position: number, interpolated?: boolean): Vector3;
  4841. /**
  4842. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4843. * @param position the position of the point along this path, from 0.0 to 1.0
  4844. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  4845. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  4846. */
  4847. getNormalAt(position: number, interpolated?: boolean): Vector3;
  4848. /**
  4849. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  4850. * @param position the position of the point along this path, from 0.0 to 1.0
  4851. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  4852. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  4853. */
  4854. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  4855. /**
  4856. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  4857. * @param position the position of the point along this path, from 0.0 to 1.0
  4858. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  4859. */
  4860. getDistanceAt(position: number): number;
  4861. /**
  4862. * Returns the array index of the previous point of an interpolated point along this path
  4863. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4864. * @returns the array index
  4865. */
  4866. getPreviousPointIndexAt(position: number): number;
  4867. /**
  4868. * 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)
  4869. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4870. * @returns the sub position
  4871. */
  4872. getSubPositionAt(position: number): number;
  4873. /**
  4874. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  4875. * @param target the vector of which to get the closest position to
  4876. * @returns the position of the closest virtual point on this path to the target vector
  4877. */
  4878. getClosestPositionTo(target: Vector3): number;
  4879. /**
  4880. * Returns a sub path (slice) of this path
  4881. * @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
  4882. * @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
  4883. * @returns a sub path (slice) of this path
  4884. */
  4885. slice(start?: number, end?: number): Path3D;
  4886. /**
  4887. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4888. * @param path path which all values are copied into the curves points
  4889. * @param firstNormal which should be projected onto the curve
  4890. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  4891. * @returns the same object updated.
  4892. */
  4893. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  4894. private _compute;
  4895. private _getFirstNonNullVector;
  4896. private _getLastNonNullVector;
  4897. private _normalVector;
  4898. /**
  4899. * Updates the point at data for an interpolated point along this curve
  4900. * @param position the position of the point along this curve, from 0.0 to 1.0
  4901. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  4902. * @returns the (updated) point at data
  4903. */
  4904. private _updatePointAtData;
  4905. /**
  4906. * Updates the point at data from the specified parameters
  4907. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  4908. * @param point the interpolated point
  4909. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  4910. */
  4911. private _setPointAtData;
  4912. /**
  4913. * Updates the point at interpolation matrix for the tangents, normals and binormals
  4914. */
  4915. private _updateInterpolationMatrix;
  4916. }
  4917. /**
  4918. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4919. * A Curve3 is designed from a series of successive Vector3.
  4920. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4921. */
  4922. export class Curve3 {
  4923. private _points;
  4924. private _length;
  4925. /**
  4926. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4927. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4928. * @param v1 (Vector3) the control point
  4929. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4930. * @param nbPoints (integer) the wanted number of points in the curve
  4931. * @returns the created Curve3
  4932. */
  4933. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4934. /**
  4935. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4936. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4937. * @param v1 (Vector3) the first control point
  4938. * @param v2 (Vector3) the second control point
  4939. * @param v3 (Vector3) the end point of the Cubic Bezier
  4940. * @param nbPoints (integer) the wanted number of points in the curve
  4941. * @returns the created Curve3
  4942. */
  4943. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4944. /**
  4945. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4946. * @param p1 (Vector3) the origin point of the Hermite Spline
  4947. * @param t1 (Vector3) the tangent vector at the origin point
  4948. * @param p2 (Vector3) the end point of the Hermite Spline
  4949. * @param t2 (Vector3) the tangent vector at the end point
  4950. * @param nbPoints (integer) the wanted number of points in the curve
  4951. * @returns the created Curve3
  4952. */
  4953. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4954. /**
  4955. * Returns a Curve3 object along a CatmullRom Spline curve :
  4956. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4957. * @param nbPoints (integer) the wanted number of points between each curve control points
  4958. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4959. * @returns the created Curve3
  4960. */
  4961. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4962. /**
  4963. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4964. * A Curve3 is designed from a series of successive Vector3.
  4965. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4966. * @param points points which make up the curve
  4967. */
  4968. constructor(points: Vector3[]);
  4969. /**
  4970. * @returns the Curve3 stored array of successive Vector3
  4971. */
  4972. getPoints(): Vector3[];
  4973. /**
  4974. * @returns the computed length (float) of the curve.
  4975. */
  4976. length(): number;
  4977. /**
  4978. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4979. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4980. * curveA and curveB keep unchanged.
  4981. * @param curve the curve to continue from this curve
  4982. * @returns the newly constructed curve
  4983. */
  4984. continue(curve: DeepImmutable<Curve3>): Curve3;
  4985. private _computeLength;
  4986. }
  4987. }
  4988. declare module BABYLON {
  4989. /**
  4990. * This represents the main contract an easing function should follow.
  4991. * Easing functions are used throughout the animation system.
  4992. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4993. */
  4994. export interface IEasingFunction {
  4995. /**
  4996. * Given an input gradient between 0 and 1, this returns the corrseponding value
  4997. * of the easing function.
  4998. * The link below provides some of the most common examples of easing functions.
  4999. * @see https://easings.net/
  5000. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5001. * @returns the corresponding value on the curve defined by the easing function
  5002. */
  5003. ease(gradient: number): number;
  5004. }
  5005. /**
  5006. * Base class used for every default easing function.
  5007. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5008. */
  5009. export class EasingFunction implements IEasingFunction {
  5010. /**
  5011. * Interpolation follows the mathematical formula associated with the easing function.
  5012. */
  5013. static readonly EASINGMODE_EASEIN: number;
  5014. /**
  5015. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5016. */
  5017. static readonly EASINGMODE_EASEOUT: number;
  5018. /**
  5019. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5020. */
  5021. static readonly EASINGMODE_EASEINOUT: number;
  5022. private _easingMode;
  5023. /**
  5024. * Sets the easing mode of the current function.
  5025. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5026. */
  5027. setEasingMode(easingMode: number): void;
  5028. /**
  5029. * Gets the current easing mode.
  5030. * @returns the easing mode
  5031. */
  5032. getEasingMode(): number;
  5033. /**
  5034. * @hidden
  5035. */
  5036. easeInCore(gradient: number): number;
  5037. /**
  5038. * Given an input gradient between 0 and 1, this returns the corresponding value
  5039. * of the easing function.
  5040. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5041. * @returns the corresponding value on the curve defined by the easing function
  5042. */
  5043. ease(gradient: number): number;
  5044. }
  5045. /**
  5046. * Easing function with a circle shape (see link below).
  5047. * @see https://easings.net/#easeInCirc
  5048. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5049. */
  5050. export class CircleEase extends EasingFunction implements IEasingFunction {
  5051. /** @hidden */
  5052. easeInCore(gradient: number): number;
  5053. }
  5054. /**
  5055. * Easing function with a ease back shape (see link below).
  5056. * @see https://easings.net/#easeInBack
  5057. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5058. */
  5059. export class BackEase extends EasingFunction implements IEasingFunction {
  5060. /** Defines the amplitude of the function */
  5061. amplitude: number;
  5062. /**
  5063. * Instantiates a back ease easing
  5064. * @see https://easings.net/#easeInBack
  5065. * @param amplitude Defines the amplitude of the function
  5066. */
  5067. constructor(
  5068. /** Defines the amplitude of the function */
  5069. amplitude?: number);
  5070. /** @hidden */
  5071. easeInCore(gradient: number): number;
  5072. }
  5073. /**
  5074. * Easing function with a bouncing shape (see link below).
  5075. * @see https://easings.net/#easeInBounce
  5076. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5077. */
  5078. export class BounceEase extends EasingFunction implements IEasingFunction {
  5079. /** Defines the number of bounces */
  5080. bounces: number;
  5081. /** Defines the amplitude of the bounce */
  5082. bounciness: number;
  5083. /**
  5084. * Instantiates a bounce easing
  5085. * @see https://easings.net/#easeInBounce
  5086. * @param bounces Defines the number of bounces
  5087. * @param bounciness Defines the amplitude of the bounce
  5088. */
  5089. constructor(
  5090. /** Defines the number of bounces */
  5091. bounces?: number,
  5092. /** Defines the amplitude of the bounce */
  5093. bounciness?: number);
  5094. /** @hidden */
  5095. easeInCore(gradient: number): number;
  5096. }
  5097. /**
  5098. * Easing function with a power of 3 shape (see link below).
  5099. * @see https://easings.net/#easeInCubic
  5100. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5101. */
  5102. export class CubicEase extends EasingFunction implements IEasingFunction {
  5103. /** @hidden */
  5104. easeInCore(gradient: number): number;
  5105. }
  5106. /**
  5107. * Easing function with an elastic shape (see link below).
  5108. * @see https://easings.net/#easeInElastic
  5109. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5110. */
  5111. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5112. /** Defines the number of oscillations*/
  5113. oscillations: number;
  5114. /** Defines the amplitude of the oscillations*/
  5115. springiness: number;
  5116. /**
  5117. * Instantiates an elastic easing function
  5118. * @see https://easings.net/#easeInElastic
  5119. * @param oscillations Defines the number of oscillations
  5120. * @param springiness Defines the amplitude of the oscillations
  5121. */
  5122. constructor(
  5123. /** Defines the number of oscillations*/
  5124. oscillations?: number,
  5125. /** Defines the amplitude of the oscillations*/
  5126. springiness?: number);
  5127. /** @hidden */
  5128. easeInCore(gradient: number): number;
  5129. }
  5130. /**
  5131. * Easing function with an exponential shape (see link below).
  5132. * @see https://easings.net/#easeInExpo
  5133. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5134. */
  5135. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5136. /** Defines the exponent of the function */
  5137. exponent: number;
  5138. /**
  5139. * Instantiates an exponential easing function
  5140. * @see https://easings.net/#easeInExpo
  5141. * @param exponent Defines the exponent of the function
  5142. */
  5143. constructor(
  5144. /** Defines the exponent of the function */
  5145. exponent?: number);
  5146. /** @hidden */
  5147. easeInCore(gradient: number): number;
  5148. }
  5149. /**
  5150. * Easing function with a power shape (see link below).
  5151. * @see https://easings.net/#easeInQuad
  5152. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5153. */
  5154. export class PowerEase extends EasingFunction implements IEasingFunction {
  5155. /** Defines the power of the function */
  5156. power: number;
  5157. /**
  5158. * Instantiates an power base easing function
  5159. * @see https://easings.net/#easeInQuad
  5160. * @param power Defines the power of the function
  5161. */
  5162. constructor(
  5163. /** Defines the power of the function */
  5164. power?: number);
  5165. /** @hidden */
  5166. easeInCore(gradient: number): number;
  5167. }
  5168. /**
  5169. * Easing function with a power of 2 shape (see link below).
  5170. * @see https://easings.net/#easeInQuad
  5171. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5172. */
  5173. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5174. /** @hidden */
  5175. easeInCore(gradient: number): number;
  5176. }
  5177. /**
  5178. * Easing function with a power of 4 shape (see link below).
  5179. * @see https://easings.net/#easeInQuart
  5180. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5181. */
  5182. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5183. /** @hidden */
  5184. easeInCore(gradient: number): number;
  5185. }
  5186. /**
  5187. * Easing function with a power of 5 shape (see link below).
  5188. * @see https://easings.net/#easeInQuint
  5189. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5190. */
  5191. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5192. /** @hidden */
  5193. easeInCore(gradient: number): number;
  5194. }
  5195. /**
  5196. * Easing function with a sin shape (see link below).
  5197. * @see https://easings.net/#easeInSine
  5198. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5199. */
  5200. export class SineEase extends EasingFunction implements IEasingFunction {
  5201. /** @hidden */
  5202. easeInCore(gradient: number): number;
  5203. }
  5204. /**
  5205. * Easing function with a bezier shape (see link below).
  5206. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5207. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5208. */
  5209. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5210. /** Defines the x component of the start tangent in the bezier curve */
  5211. x1: number;
  5212. /** Defines the y component of the start tangent in the bezier curve */
  5213. y1: number;
  5214. /** Defines the x component of the end tangent in the bezier curve */
  5215. x2: number;
  5216. /** Defines the y component of the end tangent in the bezier curve */
  5217. y2: number;
  5218. /**
  5219. * Instantiates a bezier function
  5220. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5221. * @param x1 Defines the x component of the start tangent in the bezier curve
  5222. * @param y1 Defines the y component of the start tangent in the bezier curve
  5223. * @param x2 Defines the x component of the end tangent in the bezier curve
  5224. * @param y2 Defines the y component of the end tangent in the bezier curve
  5225. */
  5226. constructor(
  5227. /** Defines the x component of the start tangent in the bezier curve */
  5228. x1?: number,
  5229. /** Defines the y component of the start tangent in the bezier curve */
  5230. y1?: number,
  5231. /** Defines the x component of the end tangent in the bezier curve */
  5232. x2?: number,
  5233. /** Defines the y component of the end tangent in the bezier curve */
  5234. y2?: number);
  5235. /** @hidden */
  5236. easeInCore(gradient: number): number;
  5237. }
  5238. }
  5239. declare module BABYLON {
  5240. /**
  5241. * Class used to hold a RBG color
  5242. */
  5243. export class Color3 {
  5244. /**
  5245. * Defines the red component (between 0 and 1, default is 0)
  5246. */
  5247. r: number;
  5248. /**
  5249. * Defines the green component (between 0 and 1, default is 0)
  5250. */
  5251. g: number;
  5252. /**
  5253. * Defines the blue component (between 0 and 1, default is 0)
  5254. */
  5255. b: number;
  5256. /**
  5257. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5258. * @param r defines the red component (between 0 and 1, default is 0)
  5259. * @param g defines the green component (between 0 and 1, default is 0)
  5260. * @param b defines the blue component (between 0 and 1, default is 0)
  5261. */
  5262. constructor(
  5263. /**
  5264. * Defines the red component (between 0 and 1, default is 0)
  5265. */
  5266. r?: number,
  5267. /**
  5268. * Defines the green component (between 0 and 1, default is 0)
  5269. */
  5270. g?: number,
  5271. /**
  5272. * Defines the blue component (between 0 and 1, default is 0)
  5273. */
  5274. b?: number);
  5275. /**
  5276. * Creates a string with the Color3 current values
  5277. * @returns the string representation of the Color3 object
  5278. */
  5279. toString(): string;
  5280. /**
  5281. * Returns the string "Color3"
  5282. * @returns "Color3"
  5283. */
  5284. getClassName(): string;
  5285. /**
  5286. * Compute the Color3 hash code
  5287. * @returns an unique number that can be used to hash Color3 objects
  5288. */
  5289. getHashCode(): number;
  5290. /**
  5291. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5292. * @param array defines the array where to store the r,g,b components
  5293. * @param index defines an optional index in the target array to define where to start storing values
  5294. * @returns the current Color3 object
  5295. */
  5296. toArray(array: FloatArray, index?: number): Color3;
  5297. /**
  5298. * Returns a new Color4 object from the current Color3 and the given alpha
  5299. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5300. * @returns a new Color4 object
  5301. */
  5302. toColor4(alpha?: number): Color4;
  5303. /**
  5304. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5305. * @returns the new array
  5306. */
  5307. asArray(): number[];
  5308. /**
  5309. * Returns the luminance value
  5310. * @returns a float value
  5311. */
  5312. toLuminance(): number;
  5313. /**
  5314. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5315. * @param otherColor defines the second operand
  5316. * @returns the new Color3 object
  5317. */
  5318. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5319. /**
  5320. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5321. * @param otherColor defines the second operand
  5322. * @param result defines the Color3 object where to store the result
  5323. * @returns the current Color3
  5324. */
  5325. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5326. /**
  5327. * Determines equality between Color3 objects
  5328. * @param otherColor defines the second operand
  5329. * @returns true if the rgb values are equal to the given ones
  5330. */
  5331. equals(otherColor: DeepImmutable<Color3>): boolean;
  5332. /**
  5333. * Determines equality between the current Color3 object and a set of r,b,g values
  5334. * @param r defines the red component to check
  5335. * @param g defines the green component to check
  5336. * @param b defines the blue component to check
  5337. * @returns true if the rgb values are equal to the given ones
  5338. */
  5339. equalsFloats(r: number, g: number, b: number): boolean;
  5340. /**
  5341. * Multiplies in place each rgb value by scale
  5342. * @param scale defines the scaling factor
  5343. * @returns the updated Color3
  5344. */
  5345. scale(scale: number): Color3;
  5346. /**
  5347. * Multiplies the rgb values by scale and stores the result into "result"
  5348. * @param scale defines the scaling factor
  5349. * @param result defines the Color3 object where to store the result
  5350. * @returns the unmodified current Color3
  5351. */
  5352. scaleToRef(scale: number, result: Color3): Color3;
  5353. /**
  5354. * Scale the current Color3 values by a factor and add the result to a given Color3
  5355. * @param scale defines the scale factor
  5356. * @param result defines color to store the result into
  5357. * @returns the unmodified current Color3
  5358. */
  5359. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5360. /**
  5361. * Clamps the rgb values by the min and max values and stores the result into "result"
  5362. * @param min defines minimum clamping value (default is 0)
  5363. * @param max defines maximum clamping value (default is 1)
  5364. * @param result defines color to store the result into
  5365. * @returns the original Color3
  5366. */
  5367. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5368. /**
  5369. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5370. * @param otherColor defines the second operand
  5371. * @returns the new Color3
  5372. */
  5373. add(otherColor: DeepImmutable<Color3>): Color3;
  5374. /**
  5375. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5376. * @param otherColor defines the second operand
  5377. * @param result defines Color3 object to store the result into
  5378. * @returns the unmodified current Color3
  5379. */
  5380. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5381. /**
  5382. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5383. * @param otherColor defines the second operand
  5384. * @returns the new Color3
  5385. */
  5386. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5387. /**
  5388. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5389. * @param otherColor defines the second operand
  5390. * @param result defines Color3 object to store the result into
  5391. * @returns the unmodified current Color3
  5392. */
  5393. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5394. /**
  5395. * Copy the current object
  5396. * @returns a new Color3 copied the current one
  5397. */
  5398. clone(): Color3;
  5399. /**
  5400. * Copies the rgb values from the source in the current Color3
  5401. * @param source defines the source Color3 object
  5402. * @returns the updated Color3 object
  5403. */
  5404. copyFrom(source: DeepImmutable<Color3>): Color3;
  5405. /**
  5406. * Updates the Color3 rgb values from the given floats
  5407. * @param r defines the red component to read from
  5408. * @param g defines the green component to read from
  5409. * @param b defines the blue component to read from
  5410. * @returns the current Color3 object
  5411. */
  5412. copyFromFloats(r: number, g: number, b: number): Color3;
  5413. /**
  5414. * Updates the Color3 rgb values from the given floats
  5415. * @param r defines the red component to read from
  5416. * @param g defines the green component to read from
  5417. * @param b defines the blue component to read from
  5418. * @returns the current Color3 object
  5419. */
  5420. set(r: number, g: number, b: number): Color3;
  5421. /**
  5422. * Compute the Color3 hexadecimal code as a string
  5423. * @returns a string containing the hexadecimal representation of the Color3 object
  5424. */
  5425. toHexString(): string;
  5426. /**
  5427. * Computes a new Color3 converted from the current one to linear space
  5428. * @returns a new Color3 object
  5429. */
  5430. toLinearSpace(): Color3;
  5431. /**
  5432. * Converts current color in rgb space to HSV values
  5433. * @returns a new color3 representing the HSV values
  5434. */
  5435. toHSV(): Color3;
  5436. /**
  5437. * Converts current color in rgb space to HSV values
  5438. * @param result defines the Color3 where to store the HSV values
  5439. */
  5440. toHSVToRef(result: Color3): void;
  5441. /**
  5442. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5443. * @param convertedColor defines the Color3 object where to store the linear space version
  5444. * @returns the unmodified Color3
  5445. */
  5446. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5447. /**
  5448. * Computes a new Color3 converted from the current one to gamma space
  5449. * @returns a new Color3 object
  5450. */
  5451. toGammaSpace(): Color3;
  5452. /**
  5453. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5454. * @param convertedColor defines the Color3 object where to store the gamma space version
  5455. * @returns the unmodified Color3
  5456. */
  5457. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5458. private static _BlackReadOnly;
  5459. /**
  5460. * Convert Hue, saturation and value to a Color3 (RGB)
  5461. * @param hue defines the hue
  5462. * @param saturation defines the saturation
  5463. * @param value defines the value
  5464. * @param result defines the Color3 where to store the RGB values
  5465. */
  5466. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5467. /**
  5468. * Creates a new Color3 from the string containing valid hexadecimal values
  5469. * @param hex defines a string containing valid hexadecimal values
  5470. * @returns a new Color3 object
  5471. */
  5472. static FromHexString(hex: string): Color3;
  5473. /**
  5474. * Creates a new Color3 from the starting index of the given array
  5475. * @param array defines the source array
  5476. * @param offset defines an offset in the source array
  5477. * @returns a new Color3 object
  5478. */
  5479. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5480. /**
  5481. * Creates a new Color3 from integer values (< 256)
  5482. * @param r defines the red component to read from (value between 0 and 255)
  5483. * @param g defines the green component to read from (value between 0 and 255)
  5484. * @param b defines the blue component to read from (value between 0 and 255)
  5485. * @returns a new Color3 object
  5486. */
  5487. static FromInts(r: number, g: number, b: number): Color3;
  5488. /**
  5489. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5490. * @param start defines the start Color3 value
  5491. * @param end defines the end Color3 value
  5492. * @param amount defines the gradient value between start and end
  5493. * @returns a new Color3 object
  5494. */
  5495. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5496. /**
  5497. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5498. * @param left defines the start value
  5499. * @param right defines the end value
  5500. * @param amount defines the gradient factor
  5501. * @param result defines the Color3 object where to store the result
  5502. */
  5503. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5504. /**
  5505. * Returns a Color3 value containing a red color
  5506. * @returns a new Color3 object
  5507. */
  5508. static Red(): Color3;
  5509. /**
  5510. * Returns a Color3 value containing a green color
  5511. * @returns a new Color3 object
  5512. */
  5513. static Green(): Color3;
  5514. /**
  5515. * Returns a Color3 value containing a blue color
  5516. * @returns a new Color3 object
  5517. */
  5518. static Blue(): Color3;
  5519. /**
  5520. * Returns a Color3 value containing a black color
  5521. * @returns a new Color3 object
  5522. */
  5523. static Black(): Color3;
  5524. /**
  5525. * Gets a Color3 value containing a black color that must not be updated
  5526. */
  5527. static get BlackReadOnly(): DeepImmutable<Color3>;
  5528. /**
  5529. * Returns a Color3 value containing a white color
  5530. * @returns a new Color3 object
  5531. */
  5532. static White(): Color3;
  5533. /**
  5534. * Returns a Color3 value containing a purple color
  5535. * @returns a new Color3 object
  5536. */
  5537. static Purple(): Color3;
  5538. /**
  5539. * Returns a Color3 value containing a magenta color
  5540. * @returns a new Color3 object
  5541. */
  5542. static Magenta(): Color3;
  5543. /**
  5544. * Returns a Color3 value containing a yellow color
  5545. * @returns a new Color3 object
  5546. */
  5547. static Yellow(): Color3;
  5548. /**
  5549. * Returns a Color3 value containing a gray color
  5550. * @returns a new Color3 object
  5551. */
  5552. static Gray(): Color3;
  5553. /**
  5554. * Returns a Color3 value containing a teal color
  5555. * @returns a new Color3 object
  5556. */
  5557. static Teal(): Color3;
  5558. /**
  5559. * Returns a Color3 value containing a random color
  5560. * @returns a new Color3 object
  5561. */
  5562. static Random(): Color3;
  5563. }
  5564. /**
  5565. * Class used to hold a RBGA color
  5566. */
  5567. export class Color4 {
  5568. /**
  5569. * Defines the red component (between 0 and 1, default is 0)
  5570. */
  5571. r: number;
  5572. /**
  5573. * Defines the green component (between 0 and 1, default is 0)
  5574. */
  5575. g: number;
  5576. /**
  5577. * Defines the blue component (between 0 and 1, default is 0)
  5578. */
  5579. b: number;
  5580. /**
  5581. * Defines the alpha component (between 0 and 1, default is 1)
  5582. */
  5583. a: number;
  5584. /**
  5585. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5586. * @param r defines the red component (between 0 and 1, default is 0)
  5587. * @param g defines the green component (between 0 and 1, default is 0)
  5588. * @param b defines the blue component (between 0 and 1, default is 0)
  5589. * @param a defines the alpha component (between 0 and 1, default is 1)
  5590. */
  5591. constructor(
  5592. /**
  5593. * Defines the red component (between 0 and 1, default is 0)
  5594. */
  5595. r?: number,
  5596. /**
  5597. * Defines the green component (between 0 and 1, default is 0)
  5598. */
  5599. g?: number,
  5600. /**
  5601. * Defines the blue component (between 0 and 1, default is 0)
  5602. */
  5603. b?: number,
  5604. /**
  5605. * Defines the alpha component (between 0 and 1, default is 1)
  5606. */
  5607. a?: number);
  5608. /**
  5609. * Adds in place the given Color4 values to the current Color4 object
  5610. * @param right defines the second operand
  5611. * @returns the current updated Color4 object
  5612. */
  5613. addInPlace(right: DeepImmutable<Color4>): Color4;
  5614. /**
  5615. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5616. * @returns the new array
  5617. */
  5618. asArray(): number[];
  5619. /**
  5620. * Stores from the starting index in the given array the Color4 successive values
  5621. * @param array defines the array where to store the r,g,b components
  5622. * @param index defines an optional index in the target array to define where to start storing values
  5623. * @returns the current Color4 object
  5624. */
  5625. toArray(array: number[], index?: number): Color4;
  5626. /**
  5627. * Determines equality between Color4 objects
  5628. * @param otherColor defines the second operand
  5629. * @returns true if the rgba values are equal to the given ones
  5630. */
  5631. equals(otherColor: DeepImmutable<Color4>): boolean;
  5632. /**
  5633. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5634. * @param right defines the second operand
  5635. * @returns a new Color4 object
  5636. */
  5637. add(right: DeepImmutable<Color4>): Color4;
  5638. /**
  5639. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5640. * @param right defines the second operand
  5641. * @returns a new Color4 object
  5642. */
  5643. subtract(right: DeepImmutable<Color4>): Color4;
  5644. /**
  5645. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5646. * @param right defines the second operand
  5647. * @param result defines the Color4 object where to store the result
  5648. * @returns the current Color4 object
  5649. */
  5650. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5651. /**
  5652. * Creates a new Color4 with the current Color4 values multiplied by scale
  5653. * @param scale defines the scaling factor to apply
  5654. * @returns a new Color4 object
  5655. */
  5656. scale(scale: number): Color4;
  5657. /**
  5658. * Multiplies the current Color4 values by scale and stores the result in "result"
  5659. * @param scale defines the scaling factor to apply
  5660. * @param result defines the Color4 object where to store the result
  5661. * @returns the current unmodified Color4
  5662. */
  5663. scaleToRef(scale: number, result: Color4): Color4;
  5664. /**
  5665. * Scale the current Color4 values by a factor and add the result to a given Color4
  5666. * @param scale defines the scale factor
  5667. * @param result defines the Color4 object where to store the result
  5668. * @returns the unmodified current Color4
  5669. */
  5670. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5671. /**
  5672. * Clamps the rgb values by the min and max values and stores the result into "result"
  5673. * @param min defines minimum clamping value (default is 0)
  5674. * @param max defines maximum clamping value (default is 1)
  5675. * @param result defines color to store the result into.
  5676. * @returns the cuurent Color4
  5677. */
  5678. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5679. /**
  5680. * Multipy an Color4 value by another and return a new Color4 object
  5681. * @param color defines the Color4 value to multiply by
  5682. * @returns a new Color4 object
  5683. */
  5684. multiply(color: Color4): Color4;
  5685. /**
  5686. * Multipy a Color4 value by another and push the result in a reference value
  5687. * @param color defines the Color4 value to multiply by
  5688. * @param result defines the Color4 to fill the result in
  5689. * @returns the result Color4
  5690. */
  5691. multiplyToRef(color: Color4, result: Color4): Color4;
  5692. /**
  5693. * Creates a string with the Color4 current values
  5694. * @returns the string representation of the Color4 object
  5695. */
  5696. toString(): string;
  5697. /**
  5698. * Returns the string "Color4"
  5699. * @returns "Color4"
  5700. */
  5701. getClassName(): string;
  5702. /**
  5703. * Compute the Color4 hash code
  5704. * @returns an unique number that can be used to hash Color4 objects
  5705. */
  5706. getHashCode(): number;
  5707. /**
  5708. * Creates a new Color4 copied from the current one
  5709. * @returns a new Color4 object
  5710. */
  5711. clone(): Color4;
  5712. /**
  5713. * Copies the given Color4 values into the current one
  5714. * @param source defines the source Color4 object
  5715. * @returns the current updated Color4 object
  5716. */
  5717. copyFrom(source: Color4): Color4;
  5718. /**
  5719. * Copies the given float values into the current one
  5720. * @param r defines the red component to read from
  5721. * @param g defines the green component to read from
  5722. * @param b defines the blue component to read from
  5723. * @param a defines the alpha component to read from
  5724. * @returns the current updated Color4 object
  5725. */
  5726. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5727. /**
  5728. * Copies the given float values into the current one
  5729. * @param r defines the red component to read from
  5730. * @param g defines the green component to read from
  5731. * @param b defines the blue component to read from
  5732. * @param a defines the alpha component to read from
  5733. * @returns the current updated Color4 object
  5734. */
  5735. set(r: number, g: number, b: number, a: number): Color4;
  5736. /**
  5737. * Compute the Color4 hexadecimal code as a string
  5738. * @returns a string containing the hexadecimal representation of the Color4 object
  5739. */
  5740. toHexString(): string;
  5741. /**
  5742. * Computes a new Color4 converted from the current one to linear space
  5743. * @returns a new Color4 object
  5744. */
  5745. toLinearSpace(): Color4;
  5746. /**
  5747. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5748. * @param convertedColor defines the Color4 object where to store the linear space version
  5749. * @returns the unmodified Color4
  5750. */
  5751. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5752. /**
  5753. * Computes a new Color4 converted from the current one to gamma space
  5754. * @returns a new Color4 object
  5755. */
  5756. toGammaSpace(): Color4;
  5757. /**
  5758. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5759. * @param convertedColor defines the Color4 object where to store the gamma space version
  5760. * @returns the unmodified Color4
  5761. */
  5762. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5763. /**
  5764. * Creates a new Color4 from the string containing valid hexadecimal values
  5765. * @param hex defines a string containing valid hexadecimal values
  5766. * @returns a new Color4 object
  5767. */
  5768. static FromHexString(hex: string): Color4;
  5769. /**
  5770. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5771. * @param left defines the start value
  5772. * @param right defines the end value
  5773. * @param amount defines the gradient factor
  5774. * @returns a new Color4 object
  5775. */
  5776. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5777. /**
  5778. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5779. * @param left defines the start value
  5780. * @param right defines the end value
  5781. * @param amount defines the gradient factor
  5782. * @param result defines the Color4 object where to store data
  5783. */
  5784. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5785. /**
  5786. * Creates a new Color4 from a Color3 and an alpha value
  5787. * @param color3 defines the source Color3 to read from
  5788. * @param alpha defines the alpha component (1.0 by default)
  5789. * @returns a new Color4 object
  5790. */
  5791. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5792. /**
  5793. * Creates a new Color4 from the starting index element of the given array
  5794. * @param array defines the source array to read from
  5795. * @param offset defines the offset in the source array
  5796. * @returns a new Color4 object
  5797. */
  5798. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5799. /**
  5800. * Creates a new Color3 from integer values (< 256)
  5801. * @param r defines the red component to read from (value between 0 and 255)
  5802. * @param g defines the green component to read from (value between 0 and 255)
  5803. * @param b defines the blue component to read from (value between 0 and 255)
  5804. * @param a defines the alpha component to read from (value between 0 and 255)
  5805. * @returns a new Color3 object
  5806. */
  5807. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5808. /**
  5809. * Check the content of a given array and convert it to an array containing RGBA data
  5810. * If the original array was already containing count * 4 values then it is returned directly
  5811. * @param colors defines the array to check
  5812. * @param count defines the number of RGBA data to expect
  5813. * @returns an array containing count * 4 values (RGBA)
  5814. */
  5815. static CheckColors4(colors: number[], count: number): number[];
  5816. }
  5817. /**
  5818. * @hidden
  5819. */
  5820. export class TmpColors {
  5821. static Color3: Color3[];
  5822. static Color4: Color4[];
  5823. }
  5824. }
  5825. declare module BABYLON {
  5826. /**
  5827. * Defines an interface which represents an animation key frame
  5828. */
  5829. export interface IAnimationKey {
  5830. /**
  5831. * Frame of the key frame
  5832. */
  5833. frame: number;
  5834. /**
  5835. * Value at the specifies key frame
  5836. */
  5837. value: any;
  5838. /**
  5839. * The input tangent for the cubic hermite spline
  5840. */
  5841. inTangent?: any;
  5842. /**
  5843. * The output tangent for the cubic hermite spline
  5844. */
  5845. outTangent?: any;
  5846. /**
  5847. * The animation interpolation type
  5848. */
  5849. interpolation?: AnimationKeyInterpolation;
  5850. }
  5851. /**
  5852. * Enum for the animation key frame interpolation type
  5853. */
  5854. export enum AnimationKeyInterpolation {
  5855. /**
  5856. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5857. */
  5858. STEP = 1
  5859. }
  5860. }
  5861. declare module BABYLON {
  5862. /**
  5863. * Represents the range of an animation
  5864. */
  5865. export class AnimationRange {
  5866. /**The name of the animation range**/
  5867. name: string;
  5868. /**The starting frame of the animation */
  5869. from: number;
  5870. /**The ending frame of the animation*/
  5871. to: number;
  5872. /**
  5873. * Initializes the range of an animation
  5874. * @param name The name of the animation range
  5875. * @param from The starting frame of the animation
  5876. * @param to The ending frame of the animation
  5877. */
  5878. constructor(
  5879. /**The name of the animation range**/
  5880. name: string,
  5881. /**The starting frame of the animation */
  5882. from: number,
  5883. /**The ending frame of the animation*/
  5884. to: number);
  5885. /**
  5886. * Makes a copy of the animation range
  5887. * @returns A copy of the animation range
  5888. */
  5889. clone(): AnimationRange;
  5890. }
  5891. }
  5892. declare module BABYLON {
  5893. /**
  5894. * Composed of a frame, and an action function
  5895. */
  5896. export class AnimationEvent {
  5897. /** The frame for which the event is triggered **/
  5898. frame: number;
  5899. /** The event to perform when triggered **/
  5900. action: (currentFrame: number) => void;
  5901. /** Specifies if the event should be triggered only once**/
  5902. onlyOnce?: boolean | undefined;
  5903. /**
  5904. * Specifies if the animation event is done
  5905. */
  5906. isDone: boolean;
  5907. /**
  5908. * Initializes the animation event
  5909. * @param frame The frame for which the event is triggered
  5910. * @param action The event to perform when triggered
  5911. * @param onlyOnce Specifies if the event should be triggered only once
  5912. */
  5913. constructor(
  5914. /** The frame for which the event is triggered **/
  5915. frame: number,
  5916. /** The event to perform when triggered **/
  5917. action: (currentFrame: number) => void,
  5918. /** Specifies if the event should be triggered only once**/
  5919. onlyOnce?: boolean | undefined);
  5920. /** @hidden */
  5921. _clone(): AnimationEvent;
  5922. }
  5923. }
  5924. declare module BABYLON {
  5925. /**
  5926. * Interface used to define a behavior
  5927. */
  5928. export interface Behavior<T> {
  5929. /** gets or sets behavior's name */
  5930. name: string;
  5931. /**
  5932. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5933. */
  5934. init(): void;
  5935. /**
  5936. * Called when the behavior is attached to a target
  5937. * @param target defines the target where the behavior is attached to
  5938. */
  5939. attach(target: T): void;
  5940. /**
  5941. * Called when the behavior is detached from its target
  5942. */
  5943. detach(): void;
  5944. }
  5945. /**
  5946. * Interface implemented by classes supporting behaviors
  5947. */
  5948. export interface IBehaviorAware<T> {
  5949. /**
  5950. * Attach a behavior
  5951. * @param behavior defines the behavior to attach
  5952. * @returns the current host
  5953. */
  5954. addBehavior(behavior: Behavior<T>): T;
  5955. /**
  5956. * Remove a behavior from the current object
  5957. * @param behavior defines the behavior to detach
  5958. * @returns the current host
  5959. */
  5960. removeBehavior(behavior: Behavior<T>): T;
  5961. /**
  5962. * Gets a behavior using its name to search
  5963. * @param name defines the name to search
  5964. * @returns the behavior or null if not found
  5965. */
  5966. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  5967. }
  5968. }
  5969. declare module BABYLON {
  5970. /**
  5971. * Defines an array and its length.
  5972. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  5973. */
  5974. export interface ISmartArrayLike<T> {
  5975. /**
  5976. * The data of the array.
  5977. */
  5978. data: Array<T>;
  5979. /**
  5980. * The active length of the array.
  5981. */
  5982. length: number;
  5983. }
  5984. /**
  5985. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  5986. */
  5987. export class SmartArray<T> implements ISmartArrayLike<T> {
  5988. /**
  5989. * The full set of data from the array.
  5990. */
  5991. data: Array<T>;
  5992. /**
  5993. * The active length of the array.
  5994. */
  5995. length: number;
  5996. protected _id: number;
  5997. /**
  5998. * Instantiates a Smart Array.
  5999. * @param capacity defines the default capacity of the array.
  6000. */
  6001. constructor(capacity: number);
  6002. /**
  6003. * Pushes a value at the end of the active data.
  6004. * @param value defines the object to push in the array.
  6005. */
  6006. push(value: T): void;
  6007. /**
  6008. * Iterates over the active data and apply the lambda to them.
  6009. * @param func defines the action to apply on each value.
  6010. */
  6011. forEach(func: (content: T) => void): void;
  6012. /**
  6013. * Sorts the full sets of data.
  6014. * @param compareFn defines the comparison function to apply.
  6015. */
  6016. sort(compareFn: (a: T, b: T) => number): void;
  6017. /**
  6018. * Resets the active data to an empty array.
  6019. */
  6020. reset(): void;
  6021. /**
  6022. * Releases all the data from the array as well as the array.
  6023. */
  6024. dispose(): void;
  6025. /**
  6026. * Concats the active data with a given array.
  6027. * @param array defines the data to concatenate with.
  6028. */
  6029. concat(array: any): void;
  6030. /**
  6031. * Returns the position of a value in the active data.
  6032. * @param value defines the value to find the index for
  6033. * @returns the index if found in the active data otherwise -1
  6034. */
  6035. indexOf(value: T): number;
  6036. /**
  6037. * Returns whether an element is part of the active data.
  6038. * @param value defines the value to look for
  6039. * @returns true if found in the active data otherwise false
  6040. */
  6041. contains(value: T): boolean;
  6042. private static _GlobalId;
  6043. }
  6044. /**
  6045. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6046. * The data in this array can only be present once
  6047. */
  6048. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6049. private _duplicateId;
  6050. /**
  6051. * Pushes a value at the end of the active data.
  6052. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6053. * @param value defines the object to push in the array.
  6054. */
  6055. push(value: T): void;
  6056. /**
  6057. * Pushes a value at the end of the active data.
  6058. * If the data is already present, it won t be added again
  6059. * @param value defines the object to push in the array.
  6060. * @returns true if added false if it was already present
  6061. */
  6062. pushNoDuplicate(value: T): boolean;
  6063. /**
  6064. * Resets the active data to an empty array.
  6065. */
  6066. reset(): void;
  6067. /**
  6068. * Concats the active data with a given array.
  6069. * This ensures no dupplicate will be present in the result.
  6070. * @param array defines the data to concatenate with.
  6071. */
  6072. concatWithNoDuplicate(array: any): void;
  6073. }
  6074. }
  6075. declare module BABYLON {
  6076. /**
  6077. * @ignore
  6078. * This is a list of all the different input types that are available in the application.
  6079. * Fo instance: ArcRotateCameraGamepadInput...
  6080. */
  6081. export var CameraInputTypes: {};
  6082. /**
  6083. * This is the contract to implement in order to create a new input class.
  6084. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6085. */
  6086. export interface ICameraInput<TCamera extends Camera> {
  6087. /**
  6088. * Defines the camera the input is attached to.
  6089. */
  6090. camera: Nullable<TCamera>;
  6091. /**
  6092. * Gets the class name of the current intput.
  6093. * @returns the class name
  6094. */
  6095. getClassName(): string;
  6096. /**
  6097. * Get the friendly name associated with the input class.
  6098. * @returns the input friendly name
  6099. */
  6100. getSimpleName(): string;
  6101. /**
  6102. * Attach the input controls to a specific dom element to get the input from.
  6103. * @param element Defines the element the controls should be listened from
  6104. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6105. */
  6106. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6107. /**
  6108. * Detach the current controls from the specified dom element.
  6109. * @param element Defines the element to stop listening the inputs from
  6110. */
  6111. detachControl(element: Nullable<HTMLElement>): void;
  6112. /**
  6113. * Update the current camera state depending on the inputs that have been used this frame.
  6114. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6115. */
  6116. checkInputs?: () => void;
  6117. }
  6118. /**
  6119. * Represents a map of input types to input instance or input index to input instance.
  6120. */
  6121. export interface CameraInputsMap<TCamera extends Camera> {
  6122. /**
  6123. * Accessor to the input by input type.
  6124. */
  6125. [name: string]: ICameraInput<TCamera>;
  6126. /**
  6127. * Accessor to the input by input index.
  6128. */
  6129. [idx: number]: ICameraInput<TCamera>;
  6130. }
  6131. /**
  6132. * This represents the input manager used within a camera.
  6133. * It helps dealing with all the different kind of input attached to a camera.
  6134. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6135. */
  6136. export class CameraInputsManager<TCamera extends Camera> {
  6137. /**
  6138. * Defines the list of inputs attahed to the camera.
  6139. */
  6140. attached: CameraInputsMap<TCamera>;
  6141. /**
  6142. * Defines the dom element the camera is collecting inputs from.
  6143. * This is null if the controls have not been attached.
  6144. */
  6145. attachedElement: Nullable<HTMLElement>;
  6146. /**
  6147. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6148. */
  6149. noPreventDefault: boolean;
  6150. /**
  6151. * Defined the camera the input manager belongs to.
  6152. */
  6153. camera: TCamera;
  6154. /**
  6155. * Update the current camera state depending on the inputs that have been used this frame.
  6156. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6157. */
  6158. checkInputs: () => void;
  6159. /**
  6160. * Instantiate a new Camera Input Manager.
  6161. * @param camera Defines the camera the input manager blongs to
  6162. */
  6163. constructor(camera: TCamera);
  6164. /**
  6165. * Add an input method to a camera
  6166. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6167. * @param input camera input method
  6168. */
  6169. add(input: ICameraInput<TCamera>): void;
  6170. /**
  6171. * Remove a specific input method from a camera
  6172. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6173. * @param inputToRemove camera input method
  6174. */
  6175. remove(inputToRemove: ICameraInput<TCamera>): void;
  6176. /**
  6177. * Remove a specific input type from a camera
  6178. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6179. * @param inputType the type of the input to remove
  6180. */
  6181. removeByType(inputType: string): void;
  6182. private _addCheckInputs;
  6183. /**
  6184. * Attach the input controls to the currently attached dom element to listen the events from.
  6185. * @param input Defines the input to attach
  6186. */
  6187. attachInput(input: ICameraInput<TCamera>): void;
  6188. /**
  6189. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6190. * @param element Defines the dom element to collect the events from
  6191. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6192. */
  6193. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6194. /**
  6195. * Detach the current manager inputs controls from a specific dom element.
  6196. * @param element Defines the dom element to collect the events from
  6197. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6198. */
  6199. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6200. /**
  6201. * Rebuild the dynamic inputCheck function from the current list of
  6202. * defined inputs in the manager.
  6203. */
  6204. rebuildInputCheck(): void;
  6205. /**
  6206. * Remove all attached input methods from a camera
  6207. */
  6208. clear(): void;
  6209. /**
  6210. * Serialize the current input manager attached to a camera.
  6211. * This ensures than once parsed,
  6212. * the input associated to the camera will be identical to the current ones
  6213. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6214. */
  6215. serialize(serializedCamera: any): void;
  6216. /**
  6217. * Parses an input manager serialized JSON to restore the previous list of inputs
  6218. * and states associated to a camera.
  6219. * @param parsedCamera Defines the JSON to parse
  6220. */
  6221. parse(parsedCamera: any): void;
  6222. }
  6223. }
  6224. declare module BABYLON {
  6225. /**
  6226. * Class used to store data that will be store in GPU memory
  6227. */
  6228. export class Buffer {
  6229. private _engine;
  6230. private _buffer;
  6231. /** @hidden */
  6232. _data: Nullable<DataArray>;
  6233. private _updatable;
  6234. private _instanced;
  6235. private _divisor;
  6236. /**
  6237. * Gets the byte stride.
  6238. */
  6239. readonly byteStride: number;
  6240. /**
  6241. * Constructor
  6242. * @param engine the engine
  6243. * @param data the data to use for this buffer
  6244. * @param updatable whether the data is updatable
  6245. * @param stride the stride (optional)
  6246. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6247. * @param instanced whether the buffer is instanced (optional)
  6248. * @param useBytes set to true if the stride in in bytes (optional)
  6249. * @param divisor sets an optional divisor for instances (1 by default)
  6250. */
  6251. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6252. /**
  6253. * Create a new VertexBuffer based on the current buffer
  6254. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6255. * @param offset defines offset in the buffer (0 by default)
  6256. * @param size defines the size in floats of attributes (position is 3 for instance)
  6257. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6258. * @param instanced defines if the vertex buffer contains indexed data
  6259. * @param useBytes defines if the offset and stride are in bytes *
  6260. * @param divisor sets an optional divisor for instances (1 by default)
  6261. * @returns the new vertex buffer
  6262. */
  6263. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6264. /**
  6265. * Gets a boolean indicating if the Buffer is updatable?
  6266. * @returns true if the buffer is updatable
  6267. */
  6268. isUpdatable(): boolean;
  6269. /**
  6270. * Gets current buffer's data
  6271. * @returns a DataArray or null
  6272. */
  6273. getData(): Nullable<DataArray>;
  6274. /**
  6275. * Gets underlying native buffer
  6276. * @returns underlying native buffer
  6277. */
  6278. getBuffer(): Nullable<DataBuffer>;
  6279. /**
  6280. * Gets the stride in float32 units (i.e. byte stride / 4).
  6281. * May not be an integer if the byte stride is not divisible by 4.
  6282. * @returns the stride in float32 units
  6283. * @deprecated Please use byteStride instead.
  6284. */
  6285. getStrideSize(): number;
  6286. /**
  6287. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6288. * @param data defines the data to store
  6289. */
  6290. create(data?: Nullable<DataArray>): void;
  6291. /** @hidden */
  6292. _rebuild(): void;
  6293. /**
  6294. * Update current buffer data
  6295. * @param data defines the data to store
  6296. */
  6297. update(data: DataArray): void;
  6298. /**
  6299. * Updates the data directly.
  6300. * @param data the new data
  6301. * @param offset the new offset
  6302. * @param vertexCount the vertex count (optional)
  6303. * @param useBytes set to true if the offset is in bytes
  6304. */
  6305. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6306. /**
  6307. * Release all resources
  6308. */
  6309. dispose(): void;
  6310. }
  6311. /**
  6312. * Specialized buffer used to store vertex data
  6313. */
  6314. export class VertexBuffer {
  6315. /** @hidden */
  6316. _buffer: Buffer;
  6317. private _kind;
  6318. private _size;
  6319. private _ownsBuffer;
  6320. private _instanced;
  6321. private _instanceDivisor;
  6322. /**
  6323. * The byte type.
  6324. */
  6325. static readonly BYTE: number;
  6326. /**
  6327. * The unsigned byte type.
  6328. */
  6329. static readonly UNSIGNED_BYTE: number;
  6330. /**
  6331. * The short type.
  6332. */
  6333. static readonly SHORT: number;
  6334. /**
  6335. * The unsigned short type.
  6336. */
  6337. static readonly UNSIGNED_SHORT: number;
  6338. /**
  6339. * The integer type.
  6340. */
  6341. static readonly INT: number;
  6342. /**
  6343. * The unsigned integer type.
  6344. */
  6345. static readonly UNSIGNED_INT: number;
  6346. /**
  6347. * The float type.
  6348. */
  6349. static readonly FLOAT: number;
  6350. /**
  6351. * Gets or sets the instance divisor when in instanced mode
  6352. */
  6353. get instanceDivisor(): number;
  6354. set instanceDivisor(value: number);
  6355. /**
  6356. * Gets the byte stride.
  6357. */
  6358. readonly byteStride: number;
  6359. /**
  6360. * Gets the byte offset.
  6361. */
  6362. readonly byteOffset: number;
  6363. /**
  6364. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6365. */
  6366. readonly normalized: boolean;
  6367. /**
  6368. * Gets the data type of each component in the array.
  6369. */
  6370. readonly type: number;
  6371. /**
  6372. * Constructor
  6373. * @param engine the engine
  6374. * @param data the data to use for this vertex buffer
  6375. * @param kind the vertex buffer kind
  6376. * @param updatable whether the data is updatable
  6377. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6378. * @param stride the stride (optional)
  6379. * @param instanced whether the buffer is instanced (optional)
  6380. * @param offset the offset of the data (optional)
  6381. * @param size the number of components (optional)
  6382. * @param type the type of the component (optional)
  6383. * @param normalized whether the data contains normalized data (optional)
  6384. * @param useBytes set to true if stride and offset are in bytes (optional)
  6385. * @param divisor defines the instance divisor to use (1 by default)
  6386. */
  6387. 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);
  6388. /** @hidden */
  6389. _rebuild(): void;
  6390. /**
  6391. * Returns the kind of the VertexBuffer (string)
  6392. * @returns a string
  6393. */
  6394. getKind(): string;
  6395. /**
  6396. * Gets a boolean indicating if the VertexBuffer is updatable?
  6397. * @returns true if the buffer is updatable
  6398. */
  6399. isUpdatable(): boolean;
  6400. /**
  6401. * Gets current buffer's data
  6402. * @returns a DataArray or null
  6403. */
  6404. getData(): Nullable<DataArray>;
  6405. /**
  6406. * Gets underlying native buffer
  6407. * @returns underlying native buffer
  6408. */
  6409. getBuffer(): Nullable<DataBuffer>;
  6410. /**
  6411. * Gets the stride in float32 units (i.e. byte stride / 4).
  6412. * May not be an integer if the byte stride is not divisible by 4.
  6413. * @returns the stride in float32 units
  6414. * @deprecated Please use byteStride instead.
  6415. */
  6416. getStrideSize(): number;
  6417. /**
  6418. * Returns the offset as a multiple of the type byte length.
  6419. * @returns the offset in bytes
  6420. * @deprecated Please use byteOffset instead.
  6421. */
  6422. getOffset(): number;
  6423. /**
  6424. * Returns the number of components per vertex attribute (integer)
  6425. * @returns the size in float
  6426. */
  6427. getSize(): number;
  6428. /**
  6429. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6430. * @returns true if this buffer is instanced
  6431. */
  6432. getIsInstanced(): boolean;
  6433. /**
  6434. * Returns the instancing divisor, zero for non-instanced (integer).
  6435. * @returns a number
  6436. */
  6437. getInstanceDivisor(): number;
  6438. /**
  6439. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6440. * @param data defines the data to store
  6441. */
  6442. create(data?: DataArray): void;
  6443. /**
  6444. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6445. * This function will create a new buffer if the current one is not updatable
  6446. * @param data defines the data to store
  6447. */
  6448. update(data: DataArray): void;
  6449. /**
  6450. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6451. * Returns the directly updated WebGLBuffer.
  6452. * @param data the new data
  6453. * @param offset the new offset
  6454. * @param useBytes set to true if the offset is in bytes
  6455. */
  6456. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6457. /**
  6458. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6459. */
  6460. dispose(): void;
  6461. /**
  6462. * Enumerates each value of this vertex buffer as numbers.
  6463. * @param count the number of values to enumerate
  6464. * @param callback the callback function called for each value
  6465. */
  6466. forEach(count: number, callback: (value: number, index: number) => void): void;
  6467. /**
  6468. * Positions
  6469. */
  6470. static readonly PositionKind: string;
  6471. /**
  6472. * Normals
  6473. */
  6474. static readonly NormalKind: string;
  6475. /**
  6476. * Tangents
  6477. */
  6478. static readonly TangentKind: string;
  6479. /**
  6480. * Texture coordinates
  6481. */
  6482. static readonly UVKind: string;
  6483. /**
  6484. * Texture coordinates 2
  6485. */
  6486. static readonly UV2Kind: string;
  6487. /**
  6488. * Texture coordinates 3
  6489. */
  6490. static readonly UV3Kind: string;
  6491. /**
  6492. * Texture coordinates 4
  6493. */
  6494. static readonly UV4Kind: string;
  6495. /**
  6496. * Texture coordinates 5
  6497. */
  6498. static readonly UV5Kind: string;
  6499. /**
  6500. * Texture coordinates 6
  6501. */
  6502. static readonly UV6Kind: string;
  6503. /**
  6504. * Colors
  6505. */
  6506. static readonly ColorKind: string;
  6507. /**
  6508. * Matrix indices (for bones)
  6509. */
  6510. static readonly MatricesIndicesKind: string;
  6511. /**
  6512. * Matrix weights (for bones)
  6513. */
  6514. static readonly MatricesWeightsKind: string;
  6515. /**
  6516. * Additional matrix indices (for bones)
  6517. */
  6518. static readonly MatricesIndicesExtraKind: string;
  6519. /**
  6520. * Additional matrix weights (for bones)
  6521. */
  6522. static readonly MatricesWeightsExtraKind: string;
  6523. /**
  6524. * Deduces the stride given a kind.
  6525. * @param kind The kind string to deduce
  6526. * @returns The deduced stride
  6527. */
  6528. static DeduceStride(kind: string): number;
  6529. /**
  6530. * Gets the byte length of the given type.
  6531. * @param type the type
  6532. * @returns the number of bytes
  6533. */
  6534. static GetTypeByteLength(type: number): number;
  6535. /**
  6536. * Enumerates each value of the given parameters as numbers.
  6537. * @param data the data to enumerate
  6538. * @param byteOffset the byte offset of the data
  6539. * @param byteStride the byte stride of the data
  6540. * @param componentCount the number of components per element
  6541. * @param componentType the type of the component
  6542. * @param count the number of values to enumerate
  6543. * @param normalized whether the data is normalized
  6544. * @param callback the callback function called for each value
  6545. */
  6546. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6547. private static _GetFloatValue;
  6548. }
  6549. }
  6550. declare module BABYLON {
  6551. /**
  6552. * @hidden
  6553. */
  6554. export class IntersectionInfo {
  6555. bu: Nullable<number>;
  6556. bv: Nullable<number>;
  6557. distance: number;
  6558. faceId: number;
  6559. subMeshId: number;
  6560. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6561. }
  6562. }
  6563. declare module BABYLON {
  6564. /**
  6565. * Represens a plane by the equation ax + by + cz + d = 0
  6566. */
  6567. export class Plane {
  6568. private static _TmpMatrix;
  6569. /**
  6570. * Normal of the plane (a,b,c)
  6571. */
  6572. normal: Vector3;
  6573. /**
  6574. * d component of the plane
  6575. */
  6576. d: number;
  6577. /**
  6578. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6579. * @param a a component of the plane
  6580. * @param b b component of the plane
  6581. * @param c c component of the plane
  6582. * @param d d component of the plane
  6583. */
  6584. constructor(a: number, b: number, c: number, d: number);
  6585. /**
  6586. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6587. */
  6588. asArray(): number[];
  6589. /**
  6590. * @returns a new plane copied from the current Plane.
  6591. */
  6592. clone(): Plane;
  6593. /**
  6594. * @returns the string "Plane".
  6595. */
  6596. getClassName(): string;
  6597. /**
  6598. * @returns the Plane hash code.
  6599. */
  6600. getHashCode(): number;
  6601. /**
  6602. * Normalize the current Plane in place.
  6603. * @returns the updated Plane.
  6604. */
  6605. normalize(): Plane;
  6606. /**
  6607. * Applies a transformation the plane and returns the result
  6608. * @param transformation the transformation matrix to be applied to the plane
  6609. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6610. */
  6611. transform(transformation: DeepImmutable<Matrix>): Plane;
  6612. /**
  6613. * Calcualtte the dot product between the point and the plane normal
  6614. * @param point point to calculate the dot product with
  6615. * @returns the dot product (float) of the point coordinates and the plane normal.
  6616. */
  6617. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6618. /**
  6619. * Updates the current Plane from the plane defined by the three given points.
  6620. * @param point1 one of the points used to contruct the plane
  6621. * @param point2 one of the points used to contruct the plane
  6622. * @param point3 one of the points used to contruct the plane
  6623. * @returns the updated Plane.
  6624. */
  6625. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6626. /**
  6627. * Checks if the plane is facing a given direction
  6628. * @param direction the direction to check if the plane is facing
  6629. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6630. * @returns True is the vector "direction" is the same side than the plane normal.
  6631. */
  6632. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6633. /**
  6634. * Calculates the distance to a point
  6635. * @param point point to calculate distance to
  6636. * @returns the signed distance (float) from the given point to the Plane.
  6637. */
  6638. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6639. /**
  6640. * Creates a plane from an array
  6641. * @param array the array to create a plane from
  6642. * @returns a new Plane from the given array.
  6643. */
  6644. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6645. /**
  6646. * Creates a plane from three points
  6647. * @param point1 point used to create the plane
  6648. * @param point2 point used to create the plane
  6649. * @param point3 point used to create the plane
  6650. * @returns a new Plane defined by the three given points.
  6651. */
  6652. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6653. /**
  6654. * Creates a plane from an origin point and a normal
  6655. * @param origin origin of the plane to be constructed
  6656. * @param normal normal of the plane to be constructed
  6657. * @returns a new Plane the normal vector to this plane at the given origin point.
  6658. * Note : the vector "normal" is updated because normalized.
  6659. */
  6660. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6661. /**
  6662. * Calculates the distance from a plane and a point
  6663. * @param origin origin of the plane to be constructed
  6664. * @param normal normal of the plane to be constructed
  6665. * @param point point to calculate distance to
  6666. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6667. */
  6668. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6669. }
  6670. }
  6671. declare module BABYLON {
  6672. /**
  6673. * Class used to store bounding sphere information
  6674. */
  6675. export class BoundingSphere {
  6676. /**
  6677. * Gets the center of the bounding sphere in local space
  6678. */
  6679. readonly center: Vector3;
  6680. /**
  6681. * Radius of the bounding sphere in local space
  6682. */
  6683. radius: number;
  6684. /**
  6685. * Gets the center of the bounding sphere in world space
  6686. */
  6687. readonly centerWorld: Vector3;
  6688. /**
  6689. * Radius of the bounding sphere in world space
  6690. */
  6691. radiusWorld: number;
  6692. /**
  6693. * Gets the minimum vector in local space
  6694. */
  6695. readonly minimum: Vector3;
  6696. /**
  6697. * Gets the maximum vector in local space
  6698. */
  6699. readonly maximum: Vector3;
  6700. private _worldMatrix;
  6701. private static readonly TmpVector3;
  6702. /**
  6703. * Creates a new bounding sphere
  6704. * @param min defines the minimum vector (in local space)
  6705. * @param max defines the maximum vector (in local space)
  6706. * @param worldMatrix defines the new world matrix
  6707. */
  6708. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6709. /**
  6710. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6711. * @param min defines the new minimum vector (in local space)
  6712. * @param max defines the new maximum vector (in local space)
  6713. * @param worldMatrix defines the new world matrix
  6714. */
  6715. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6716. /**
  6717. * Scale the current bounding sphere by applying a scale factor
  6718. * @param factor defines the scale factor to apply
  6719. * @returns the current bounding box
  6720. */
  6721. scale(factor: number): BoundingSphere;
  6722. /**
  6723. * Gets the world matrix of the bounding box
  6724. * @returns a matrix
  6725. */
  6726. getWorldMatrix(): DeepImmutable<Matrix>;
  6727. /** @hidden */
  6728. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6729. /**
  6730. * Tests if the bounding sphere is intersecting the frustum planes
  6731. * @param frustumPlanes defines the frustum planes to test
  6732. * @returns true if there is an intersection
  6733. */
  6734. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6735. /**
  6736. * Tests if the bounding sphere center is in between the frustum planes.
  6737. * Used for optimistic fast inclusion.
  6738. * @param frustumPlanes defines the frustum planes to test
  6739. * @returns true if the sphere center is in between the frustum planes
  6740. */
  6741. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6742. /**
  6743. * Tests if a point is inside the bounding sphere
  6744. * @param point defines the point to test
  6745. * @returns true if the point is inside the bounding sphere
  6746. */
  6747. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6748. /**
  6749. * Checks if two sphere intersct
  6750. * @param sphere0 sphere 0
  6751. * @param sphere1 sphere 1
  6752. * @returns true if the speres intersect
  6753. */
  6754. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6755. }
  6756. }
  6757. declare module BABYLON {
  6758. /**
  6759. * Class used to store bounding box information
  6760. */
  6761. export class BoundingBox implements ICullable {
  6762. /**
  6763. * Gets the 8 vectors representing the bounding box in local space
  6764. */
  6765. readonly vectors: Vector3[];
  6766. /**
  6767. * Gets the center of the bounding box in local space
  6768. */
  6769. readonly center: Vector3;
  6770. /**
  6771. * Gets the center of the bounding box in world space
  6772. */
  6773. readonly centerWorld: Vector3;
  6774. /**
  6775. * Gets the extend size in local space
  6776. */
  6777. readonly extendSize: Vector3;
  6778. /**
  6779. * Gets the extend size in world space
  6780. */
  6781. readonly extendSizeWorld: Vector3;
  6782. /**
  6783. * Gets the OBB (object bounding box) directions
  6784. */
  6785. readonly directions: Vector3[];
  6786. /**
  6787. * Gets the 8 vectors representing the bounding box in world space
  6788. */
  6789. readonly vectorsWorld: Vector3[];
  6790. /**
  6791. * Gets the minimum vector in world space
  6792. */
  6793. readonly minimumWorld: Vector3;
  6794. /**
  6795. * Gets the maximum vector in world space
  6796. */
  6797. readonly maximumWorld: Vector3;
  6798. /**
  6799. * Gets the minimum vector in local space
  6800. */
  6801. readonly minimum: Vector3;
  6802. /**
  6803. * Gets the maximum vector in local space
  6804. */
  6805. readonly maximum: Vector3;
  6806. private _worldMatrix;
  6807. private static readonly TmpVector3;
  6808. /**
  6809. * @hidden
  6810. */
  6811. _tag: number;
  6812. /**
  6813. * Creates a new bounding box
  6814. * @param min defines the minimum vector (in local space)
  6815. * @param max defines the maximum vector (in local space)
  6816. * @param worldMatrix defines the new world matrix
  6817. */
  6818. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6819. /**
  6820. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6821. * @param min defines the new minimum vector (in local space)
  6822. * @param max defines the new maximum vector (in local space)
  6823. * @param worldMatrix defines the new world matrix
  6824. */
  6825. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6826. /**
  6827. * Scale the current bounding box by applying a scale factor
  6828. * @param factor defines the scale factor to apply
  6829. * @returns the current bounding box
  6830. */
  6831. scale(factor: number): BoundingBox;
  6832. /**
  6833. * Gets the world matrix of the bounding box
  6834. * @returns a matrix
  6835. */
  6836. getWorldMatrix(): DeepImmutable<Matrix>;
  6837. /** @hidden */
  6838. _update(world: DeepImmutable<Matrix>): void;
  6839. /**
  6840. * Tests if the bounding box is intersecting the frustum planes
  6841. * @param frustumPlanes defines the frustum planes to test
  6842. * @returns true if there is an intersection
  6843. */
  6844. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6845. /**
  6846. * Tests if the bounding box is entirely inside the frustum planes
  6847. * @param frustumPlanes defines the frustum planes to test
  6848. * @returns true if there is an inclusion
  6849. */
  6850. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6851. /**
  6852. * Tests if a point is inside the bounding box
  6853. * @param point defines the point to test
  6854. * @returns true if the point is inside the bounding box
  6855. */
  6856. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6857. /**
  6858. * Tests if the bounding box intersects with a bounding sphere
  6859. * @param sphere defines the sphere to test
  6860. * @returns true if there is an intersection
  6861. */
  6862. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6863. /**
  6864. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6865. * @param min defines the min vector to use
  6866. * @param max defines the max vector to use
  6867. * @returns true if there is an intersection
  6868. */
  6869. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6870. /**
  6871. * Tests if two bounding boxes are intersections
  6872. * @param box0 defines the first box to test
  6873. * @param box1 defines the second box to test
  6874. * @returns true if there is an intersection
  6875. */
  6876. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6877. /**
  6878. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6879. * @param minPoint defines the minimum vector of the bounding box
  6880. * @param maxPoint defines the maximum vector of the bounding box
  6881. * @param sphereCenter defines the sphere center
  6882. * @param sphereRadius defines the sphere radius
  6883. * @returns true if there is an intersection
  6884. */
  6885. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6886. /**
  6887. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6888. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6889. * @param frustumPlanes defines the frustum planes to test
  6890. * @return true if there is an inclusion
  6891. */
  6892. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6893. /**
  6894. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6895. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6896. * @param frustumPlanes defines the frustum planes to test
  6897. * @return true if there is an intersection
  6898. */
  6899. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6900. }
  6901. }
  6902. declare module BABYLON {
  6903. /** @hidden */
  6904. export class Collider {
  6905. /** Define if a collision was found */
  6906. collisionFound: boolean;
  6907. /**
  6908. * Define last intersection point in local space
  6909. */
  6910. intersectionPoint: Vector3;
  6911. /**
  6912. * Define last collided mesh
  6913. */
  6914. collidedMesh: Nullable<AbstractMesh>;
  6915. private _collisionPoint;
  6916. private _planeIntersectionPoint;
  6917. private _tempVector;
  6918. private _tempVector2;
  6919. private _tempVector3;
  6920. private _tempVector4;
  6921. private _edge;
  6922. private _baseToVertex;
  6923. private _destinationPoint;
  6924. private _slidePlaneNormal;
  6925. private _displacementVector;
  6926. /** @hidden */
  6927. _radius: Vector3;
  6928. /** @hidden */
  6929. _retry: number;
  6930. private _velocity;
  6931. private _basePoint;
  6932. private _epsilon;
  6933. /** @hidden */
  6934. _velocityWorldLength: number;
  6935. /** @hidden */
  6936. _basePointWorld: Vector3;
  6937. private _velocityWorld;
  6938. private _normalizedVelocity;
  6939. /** @hidden */
  6940. _initialVelocity: Vector3;
  6941. /** @hidden */
  6942. _initialPosition: Vector3;
  6943. private _nearestDistance;
  6944. private _collisionMask;
  6945. get collisionMask(): number;
  6946. set collisionMask(mask: number);
  6947. /**
  6948. * Gets the plane normal used to compute the sliding response (in local space)
  6949. */
  6950. get slidePlaneNormal(): Vector3;
  6951. /** @hidden */
  6952. _initialize(source: Vector3, dir: Vector3, e: number): void;
  6953. /** @hidden */
  6954. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  6955. /** @hidden */
  6956. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  6957. /** @hidden */
  6958. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6959. /** @hidden */
  6960. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6961. /** @hidden */
  6962. _getResponse(pos: Vector3, vel: Vector3): void;
  6963. }
  6964. }
  6965. declare module BABYLON {
  6966. /**
  6967. * Interface for cullable objects
  6968. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  6969. */
  6970. export interface ICullable {
  6971. /**
  6972. * Checks if the object or part of the object is in the frustum
  6973. * @param frustumPlanes Camera near/planes
  6974. * @returns true if the object is in frustum otherwise false
  6975. */
  6976. isInFrustum(frustumPlanes: Plane[]): boolean;
  6977. /**
  6978. * Checks if a cullable object (mesh...) is in the camera frustum
  6979. * Unlike isInFrustum this cheks the full bounding box
  6980. * @param frustumPlanes Camera near/planes
  6981. * @returns true if the object is in frustum otherwise false
  6982. */
  6983. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  6984. }
  6985. /**
  6986. * Info for a bounding data of a mesh
  6987. */
  6988. export class BoundingInfo implements ICullable {
  6989. /**
  6990. * Bounding box for the mesh
  6991. */
  6992. readonly boundingBox: BoundingBox;
  6993. /**
  6994. * Bounding sphere for the mesh
  6995. */
  6996. readonly boundingSphere: BoundingSphere;
  6997. private _isLocked;
  6998. private static readonly TmpVector3;
  6999. /**
  7000. * Constructs bounding info
  7001. * @param minimum min vector of the bounding box/sphere
  7002. * @param maximum max vector of the bounding box/sphere
  7003. * @param worldMatrix defines the new world matrix
  7004. */
  7005. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7006. /**
  7007. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7008. * @param min defines the new minimum vector (in local space)
  7009. * @param max defines the new maximum vector (in local space)
  7010. * @param worldMatrix defines the new world matrix
  7011. */
  7012. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7013. /**
  7014. * min vector of the bounding box/sphere
  7015. */
  7016. get minimum(): Vector3;
  7017. /**
  7018. * max vector of the bounding box/sphere
  7019. */
  7020. get maximum(): Vector3;
  7021. /**
  7022. * If the info is locked and won't be updated to avoid perf overhead
  7023. */
  7024. get isLocked(): boolean;
  7025. set isLocked(value: boolean);
  7026. /**
  7027. * Updates the bounding sphere and box
  7028. * @param world world matrix to be used to update
  7029. */
  7030. update(world: DeepImmutable<Matrix>): void;
  7031. /**
  7032. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7033. * @param center New center of the bounding info
  7034. * @param extend New extend of the bounding info
  7035. * @returns the current bounding info
  7036. */
  7037. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7038. /**
  7039. * Scale the current bounding info by applying a scale factor
  7040. * @param factor defines the scale factor to apply
  7041. * @returns the current bounding info
  7042. */
  7043. scale(factor: number): BoundingInfo;
  7044. /**
  7045. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7046. * @param frustumPlanes defines the frustum to test
  7047. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7048. * @returns true if the bounding info is in the frustum planes
  7049. */
  7050. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7051. /**
  7052. * Gets the world distance between the min and max points of the bounding box
  7053. */
  7054. get diagonalLength(): number;
  7055. /**
  7056. * Checks if a cullable object (mesh...) is in the camera frustum
  7057. * Unlike isInFrustum this cheks the full bounding box
  7058. * @param frustumPlanes Camera near/planes
  7059. * @returns true if the object is in frustum otherwise false
  7060. */
  7061. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7062. /** @hidden */
  7063. _checkCollision(collider: Collider): boolean;
  7064. /**
  7065. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7066. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7067. * @param point the point to check intersection with
  7068. * @returns if the point intersects
  7069. */
  7070. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7071. /**
  7072. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7073. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7074. * @param boundingInfo the bounding info to check intersection with
  7075. * @param precise if the intersection should be done using OBB
  7076. * @returns if the bounding info intersects
  7077. */
  7078. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7079. }
  7080. }
  7081. declare module BABYLON {
  7082. /**
  7083. * Extracts minimum and maximum values from a list of indexed positions
  7084. * @param positions defines the positions to use
  7085. * @param indices defines the indices to the positions
  7086. * @param indexStart defines the start index
  7087. * @param indexCount defines the end index
  7088. * @param bias defines bias value to add to the result
  7089. * @return minimum and maximum values
  7090. */
  7091. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7092. minimum: Vector3;
  7093. maximum: Vector3;
  7094. };
  7095. /**
  7096. * Extracts minimum and maximum values from a list of positions
  7097. * @param positions defines the positions to use
  7098. * @param start defines the start index in the positions array
  7099. * @param count defines the number of positions to handle
  7100. * @param bias defines bias value to add to the result
  7101. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7102. * @return minimum and maximum values
  7103. */
  7104. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7105. minimum: Vector3;
  7106. maximum: Vector3;
  7107. };
  7108. }
  7109. declare module BABYLON {
  7110. /** @hidden */
  7111. export class WebGLDataBuffer extends DataBuffer {
  7112. private _buffer;
  7113. constructor(resource: WebGLBuffer);
  7114. get underlyingResource(): any;
  7115. }
  7116. }
  7117. declare module BABYLON {
  7118. /** @hidden */
  7119. export class WebGLPipelineContext implements IPipelineContext {
  7120. engine: ThinEngine;
  7121. program: Nullable<WebGLProgram>;
  7122. context?: WebGLRenderingContext;
  7123. vertexShader?: WebGLShader;
  7124. fragmentShader?: WebGLShader;
  7125. isParallelCompiled: boolean;
  7126. onCompiled?: () => void;
  7127. transformFeedback?: WebGLTransformFeedback | null;
  7128. vertexCompilationError: Nullable<string>;
  7129. fragmentCompilationError: Nullable<string>;
  7130. programLinkError: Nullable<string>;
  7131. programValidationError: Nullable<string>;
  7132. get isAsync(): boolean;
  7133. get isReady(): boolean;
  7134. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7135. }
  7136. }
  7137. declare module BABYLON {
  7138. interface ThinEngine {
  7139. /**
  7140. * Create an uniform buffer
  7141. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7142. * @param elements defines the content of the uniform buffer
  7143. * @returns the webGL uniform buffer
  7144. */
  7145. createUniformBuffer(elements: FloatArray): DataBuffer;
  7146. /**
  7147. * Create a dynamic uniform buffer
  7148. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7149. * @param elements defines the content of the uniform buffer
  7150. * @returns the webGL uniform buffer
  7151. */
  7152. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7153. /**
  7154. * Update an existing uniform buffer
  7155. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7156. * @param uniformBuffer defines the target uniform buffer
  7157. * @param elements defines the content to update
  7158. * @param offset defines the offset in the uniform buffer where update should start
  7159. * @param count defines the size of the data to update
  7160. */
  7161. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7162. /**
  7163. * Bind an uniform buffer to the current webGL context
  7164. * @param buffer defines the buffer to bind
  7165. */
  7166. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7167. /**
  7168. * Bind a buffer to the current webGL context at a given location
  7169. * @param buffer defines the buffer to bind
  7170. * @param location defines the index where to bind the buffer
  7171. */
  7172. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7173. /**
  7174. * Bind a specific block at a given index in a specific shader program
  7175. * @param pipelineContext defines the pipeline context to use
  7176. * @param blockName defines the block name
  7177. * @param index defines the index where to bind the block
  7178. */
  7179. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7180. }
  7181. }
  7182. declare module BABYLON {
  7183. /**
  7184. * Uniform buffer objects.
  7185. *
  7186. * Handles blocks of uniform on the GPU.
  7187. *
  7188. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7189. *
  7190. * For more information, please refer to :
  7191. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7192. */
  7193. export class UniformBuffer {
  7194. private _engine;
  7195. private _buffer;
  7196. private _data;
  7197. private _bufferData;
  7198. private _dynamic?;
  7199. private _uniformLocations;
  7200. private _uniformSizes;
  7201. private _uniformLocationPointer;
  7202. private _needSync;
  7203. private _noUBO;
  7204. private _currentEffect;
  7205. /** @hidden */
  7206. _alreadyBound: boolean;
  7207. private static _MAX_UNIFORM_SIZE;
  7208. private static _tempBuffer;
  7209. /**
  7210. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7211. * This is dynamic to allow compat with webgl 1 and 2.
  7212. * You will need to pass the name of the uniform as well as the value.
  7213. */
  7214. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7215. /**
  7216. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7217. * This is dynamic to allow compat with webgl 1 and 2.
  7218. * You will need to pass the name of the uniform as well as the value.
  7219. */
  7220. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7221. /**
  7222. * Lambda to Update a single float in a uniform buffer.
  7223. * This is dynamic to allow compat with webgl 1 and 2.
  7224. * You will need to pass the name of the uniform as well as the value.
  7225. */
  7226. updateFloat: (name: string, x: number) => void;
  7227. /**
  7228. * Lambda to Update a vec2 of float in a uniform buffer.
  7229. * This is dynamic to allow compat with webgl 1 and 2.
  7230. * You will need to pass the name of the uniform as well as the value.
  7231. */
  7232. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7233. /**
  7234. * Lambda to Update a vec3 of float in a uniform buffer.
  7235. * This is dynamic to allow compat with webgl 1 and 2.
  7236. * You will need to pass the name of the uniform as well as the value.
  7237. */
  7238. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7239. /**
  7240. * Lambda to Update a vec4 of float in a uniform buffer.
  7241. * This is dynamic to allow compat with webgl 1 and 2.
  7242. * You will need to pass the name of the uniform as well as the value.
  7243. */
  7244. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7245. /**
  7246. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7247. * This is dynamic to allow compat with webgl 1 and 2.
  7248. * You will need to pass the name of the uniform as well as the value.
  7249. */
  7250. updateMatrix: (name: string, mat: Matrix) => void;
  7251. /**
  7252. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7253. * This is dynamic to allow compat with webgl 1 and 2.
  7254. * You will need to pass the name of the uniform as well as the value.
  7255. */
  7256. updateVector3: (name: string, vector: Vector3) => void;
  7257. /**
  7258. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7259. * This is dynamic to allow compat with webgl 1 and 2.
  7260. * You will need to pass the name of the uniform as well as the value.
  7261. */
  7262. updateVector4: (name: string, vector: Vector4) => void;
  7263. /**
  7264. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7265. * This is dynamic to allow compat with webgl 1 and 2.
  7266. * You will need to pass the name of the uniform as well as the value.
  7267. */
  7268. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7269. /**
  7270. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7271. * This is dynamic to allow compat with webgl 1 and 2.
  7272. * You will need to pass the name of the uniform as well as the value.
  7273. */
  7274. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7275. /**
  7276. * Instantiates a new Uniform buffer objects.
  7277. *
  7278. * Handles blocks of uniform on the GPU.
  7279. *
  7280. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7281. *
  7282. * For more information, please refer to :
  7283. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7284. * @param engine Define the engine the buffer is associated with
  7285. * @param data Define the data contained in the buffer
  7286. * @param dynamic Define if the buffer is updatable
  7287. */
  7288. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7289. /**
  7290. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7291. * or just falling back on setUniformXXX calls.
  7292. */
  7293. get useUbo(): boolean;
  7294. /**
  7295. * Indicates if the WebGL underlying uniform buffer is in sync
  7296. * with the javascript cache data.
  7297. */
  7298. get isSync(): boolean;
  7299. /**
  7300. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7301. * Also, a dynamic UniformBuffer will disable cache verification and always
  7302. * update the underlying WebGL uniform buffer to the GPU.
  7303. * @returns if Dynamic, otherwise false
  7304. */
  7305. isDynamic(): boolean;
  7306. /**
  7307. * The data cache on JS side.
  7308. * @returns the underlying data as a float array
  7309. */
  7310. getData(): Float32Array;
  7311. /**
  7312. * The underlying WebGL Uniform buffer.
  7313. * @returns the webgl buffer
  7314. */
  7315. getBuffer(): Nullable<DataBuffer>;
  7316. /**
  7317. * std140 layout specifies how to align data within an UBO structure.
  7318. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7319. * for specs.
  7320. */
  7321. private _fillAlignment;
  7322. /**
  7323. * Adds an uniform in the buffer.
  7324. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7325. * for the layout to be correct !
  7326. * @param name Name of the uniform, as used in the uniform block in the shader.
  7327. * @param size Data size, or data directly.
  7328. */
  7329. addUniform(name: string, size: number | number[]): void;
  7330. /**
  7331. * Adds a Matrix 4x4 to the uniform buffer.
  7332. * @param name Name of the uniform, as used in the uniform block in the shader.
  7333. * @param mat A 4x4 matrix.
  7334. */
  7335. addMatrix(name: string, mat: Matrix): void;
  7336. /**
  7337. * Adds a vec2 to the uniform buffer.
  7338. * @param name Name of the uniform, as used in the uniform block in the shader.
  7339. * @param x Define the x component value of the vec2
  7340. * @param y Define the y component value of the vec2
  7341. */
  7342. addFloat2(name: string, x: number, y: number): void;
  7343. /**
  7344. * Adds a vec3 to the uniform buffer.
  7345. * @param name Name of the uniform, as used in the uniform block in the shader.
  7346. * @param x Define the x component value of the vec3
  7347. * @param y Define the y component value of the vec3
  7348. * @param z Define the z component value of the vec3
  7349. */
  7350. addFloat3(name: string, x: number, y: number, z: number): void;
  7351. /**
  7352. * Adds a vec3 to the uniform buffer.
  7353. * @param name Name of the uniform, as used in the uniform block in the shader.
  7354. * @param color Define the vec3 from a Color
  7355. */
  7356. addColor3(name: string, color: Color3): void;
  7357. /**
  7358. * Adds a vec4 to the uniform buffer.
  7359. * @param name Name of the uniform, as used in the uniform block in the shader.
  7360. * @param color Define the rgb components from a Color
  7361. * @param alpha Define the a component of the vec4
  7362. */
  7363. addColor4(name: string, color: Color3, alpha: number): void;
  7364. /**
  7365. * Adds a vec3 to the uniform buffer.
  7366. * @param name Name of the uniform, as used in the uniform block in the shader.
  7367. * @param vector Define the vec3 components from a Vector
  7368. */
  7369. addVector3(name: string, vector: Vector3): void;
  7370. /**
  7371. * Adds a Matrix 3x3 to the uniform buffer.
  7372. * @param name Name of the uniform, as used in the uniform block in the shader.
  7373. */
  7374. addMatrix3x3(name: string): void;
  7375. /**
  7376. * Adds a Matrix 2x2 to the uniform buffer.
  7377. * @param name Name of the uniform, as used in the uniform block in the shader.
  7378. */
  7379. addMatrix2x2(name: string): void;
  7380. /**
  7381. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7382. */
  7383. create(): void;
  7384. /** @hidden */
  7385. _rebuild(): void;
  7386. /**
  7387. * Updates the WebGL Uniform Buffer on the GPU.
  7388. * If the `dynamic` flag is set to true, no cache comparison is done.
  7389. * Otherwise, the buffer will be updated only if the cache differs.
  7390. */
  7391. update(): void;
  7392. /**
  7393. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7394. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7395. * @param data Define the flattened data
  7396. * @param size Define the size of the data.
  7397. */
  7398. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7399. private _valueCache;
  7400. private _cacheMatrix;
  7401. private _updateMatrix3x3ForUniform;
  7402. private _updateMatrix3x3ForEffect;
  7403. private _updateMatrix2x2ForEffect;
  7404. private _updateMatrix2x2ForUniform;
  7405. private _updateFloatForEffect;
  7406. private _updateFloatForUniform;
  7407. private _updateFloat2ForEffect;
  7408. private _updateFloat2ForUniform;
  7409. private _updateFloat3ForEffect;
  7410. private _updateFloat3ForUniform;
  7411. private _updateFloat4ForEffect;
  7412. private _updateFloat4ForUniform;
  7413. private _updateMatrixForEffect;
  7414. private _updateMatrixForUniform;
  7415. private _updateVector3ForEffect;
  7416. private _updateVector3ForUniform;
  7417. private _updateVector4ForEffect;
  7418. private _updateVector4ForUniform;
  7419. private _updateColor3ForEffect;
  7420. private _updateColor3ForUniform;
  7421. private _updateColor4ForEffect;
  7422. private _updateColor4ForUniform;
  7423. /**
  7424. * Sets a sampler uniform on the effect.
  7425. * @param name Define the name of the sampler.
  7426. * @param texture Define the texture to set in the sampler
  7427. */
  7428. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7429. /**
  7430. * Directly updates the value of the uniform in the cache AND on the GPU.
  7431. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7432. * @param data Define the flattened data
  7433. */
  7434. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7435. /**
  7436. * Binds this uniform buffer to an effect.
  7437. * @param effect Define the effect to bind the buffer to
  7438. * @param name Name of the uniform block in the shader.
  7439. */
  7440. bindToEffect(effect: Effect, name: string): void;
  7441. /**
  7442. * Disposes the uniform buffer.
  7443. */
  7444. dispose(): void;
  7445. }
  7446. }
  7447. declare module BABYLON {
  7448. /**
  7449. * Enum that determines the text-wrapping mode to use.
  7450. */
  7451. export enum InspectableType {
  7452. /**
  7453. * Checkbox for booleans
  7454. */
  7455. Checkbox = 0,
  7456. /**
  7457. * Sliders for numbers
  7458. */
  7459. Slider = 1,
  7460. /**
  7461. * Vector3
  7462. */
  7463. Vector3 = 2,
  7464. /**
  7465. * Quaternions
  7466. */
  7467. Quaternion = 3,
  7468. /**
  7469. * Color3
  7470. */
  7471. Color3 = 4,
  7472. /**
  7473. * String
  7474. */
  7475. String = 5
  7476. }
  7477. /**
  7478. * Interface used to define custom inspectable properties.
  7479. * This interface is used by the inspector to display custom property grids
  7480. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7481. */
  7482. export interface IInspectable {
  7483. /**
  7484. * Gets the label to display
  7485. */
  7486. label: string;
  7487. /**
  7488. * Gets the name of the property to edit
  7489. */
  7490. propertyName: string;
  7491. /**
  7492. * Gets the type of the editor to use
  7493. */
  7494. type: InspectableType;
  7495. /**
  7496. * Gets the minimum value of the property when using in "slider" mode
  7497. */
  7498. min?: number;
  7499. /**
  7500. * Gets the maximum value of the property when using in "slider" mode
  7501. */
  7502. max?: number;
  7503. /**
  7504. * Gets the setp to use when using in "slider" mode
  7505. */
  7506. step?: number;
  7507. }
  7508. }
  7509. declare module BABYLON {
  7510. /**
  7511. * Class used to provide helper for timing
  7512. */
  7513. export class TimingTools {
  7514. /**
  7515. * Polyfill for setImmediate
  7516. * @param action defines the action to execute after the current execution block
  7517. */
  7518. static SetImmediate(action: () => void): void;
  7519. }
  7520. }
  7521. declare module BABYLON {
  7522. /**
  7523. * Class used to enable instatition of objects by class name
  7524. */
  7525. export class InstantiationTools {
  7526. /**
  7527. * Use this object to register external classes like custom textures or material
  7528. * to allow the laoders to instantiate them
  7529. */
  7530. static RegisteredExternalClasses: {
  7531. [key: string]: Object;
  7532. };
  7533. /**
  7534. * Tries to instantiate a new object from a given class name
  7535. * @param className defines the class name to instantiate
  7536. * @returns the new object or null if the system was not able to do the instantiation
  7537. */
  7538. static Instantiate(className: string): any;
  7539. }
  7540. }
  7541. declare module BABYLON {
  7542. /**
  7543. * Define options used to create a depth texture
  7544. */
  7545. export class DepthTextureCreationOptions {
  7546. /** Specifies whether or not a stencil should be allocated in the texture */
  7547. generateStencil?: boolean;
  7548. /** Specifies whether or not bilinear filtering is enable on the texture */
  7549. bilinearFiltering?: boolean;
  7550. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7551. comparisonFunction?: number;
  7552. /** Specifies if the created texture is a cube texture */
  7553. isCube?: boolean;
  7554. }
  7555. }
  7556. declare module BABYLON {
  7557. interface ThinEngine {
  7558. /**
  7559. * Creates a depth stencil cube texture.
  7560. * This is only available in WebGL 2.
  7561. * @param size The size of face edge in the cube texture.
  7562. * @param options The options defining the cube texture.
  7563. * @returns The cube texture
  7564. */
  7565. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7566. /**
  7567. * Creates a cube texture
  7568. * @param rootUrl defines the url where the files to load is located
  7569. * @param scene defines the current scene
  7570. * @param files defines the list of files to load (1 per face)
  7571. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7572. * @param onLoad defines an optional callback raised when the texture is loaded
  7573. * @param onError defines an optional callback raised if there is an issue to load the texture
  7574. * @param format defines the format of the data
  7575. * @param forcedExtension defines the extension to use to pick the right loader
  7576. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7577. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7578. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7579. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7580. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7581. * @returns the cube texture as an InternalTexture
  7582. */
  7583. 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;
  7584. /**
  7585. * Creates a cube texture
  7586. * @param rootUrl defines the url where the files to load is located
  7587. * @param scene defines the current scene
  7588. * @param files defines the list of files to load (1 per face)
  7589. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7590. * @param onLoad defines an optional callback raised when the texture is loaded
  7591. * @param onError defines an optional callback raised if there is an issue to load the texture
  7592. * @param format defines the format of the data
  7593. * @param forcedExtension defines the extension to use to pick the right loader
  7594. * @returns the cube texture as an InternalTexture
  7595. */
  7596. 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;
  7597. /**
  7598. * Creates a cube texture
  7599. * @param rootUrl defines the url where the files to load is located
  7600. * @param scene defines the current scene
  7601. * @param files defines the list of files to load (1 per face)
  7602. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7603. * @param onLoad defines an optional callback raised when the texture is loaded
  7604. * @param onError defines an optional callback raised if there is an issue to load the texture
  7605. * @param format defines the format of the data
  7606. * @param forcedExtension defines the extension to use to pick the right loader
  7607. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7608. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7609. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7610. * @returns the cube texture as an InternalTexture
  7611. */
  7612. 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;
  7613. /** @hidden */
  7614. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7615. /** @hidden */
  7616. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7617. /** @hidden */
  7618. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7619. /** @hidden */
  7620. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7621. /**
  7622. * @hidden
  7623. */
  7624. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7625. }
  7626. }
  7627. declare module BABYLON {
  7628. /**
  7629. * Class for creating a cube texture
  7630. */
  7631. export class CubeTexture extends BaseTexture {
  7632. private _delayedOnLoad;
  7633. /**
  7634. * The url of the texture
  7635. */
  7636. url: string;
  7637. /**
  7638. * Gets or sets the center of the bounding box associated with the cube texture.
  7639. * It must define where the camera used to render the texture was set
  7640. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7641. */
  7642. boundingBoxPosition: Vector3;
  7643. private _boundingBoxSize;
  7644. /**
  7645. * Gets or sets the size of the bounding box associated with the cube texture
  7646. * When defined, the cubemap will switch to local mode
  7647. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7648. * @example https://www.babylonjs-playground.com/#RNASML
  7649. */
  7650. set boundingBoxSize(value: Vector3);
  7651. /**
  7652. * Returns the bounding box size
  7653. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7654. */
  7655. get boundingBoxSize(): Vector3;
  7656. protected _rotationY: number;
  7657. /**
  7658. * Sets texture matrix rotation angle around Y axis in radians.
  7659. */
  7660. set rotationY(value: number);
  7661. /**
  7662. * Gets texture matrix rotation angle around Y axis radians.
  7663. */
  7664. get rotationY(): number;
  7665. /**
  7666. * Are mip maps generated for this texture or not.
  7667. */
  7668. get noMipmap(): boolean;
  7669. private _noMipmap;
  7670. private _files;
  7671. protected _forcedExtension: Nullable<string>;
  7672. private _extensions;
  7673. private _textureMatrix;
  7674. private _format;
  7675. private _createPolynomials;
  7676. /** @hidden */
  7677. _prefiltered: boolean;
  7678. /**
  7679. * Creates a cube texture from an array of image urls
  7680. * @param files defines an array of image urls
  7681. * @param scene defines the hosting scene
  7682. * @param noMipmap specifies if mip maps are not used
  7683. * @returns a cube texture
  7684. */
  7685. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7686. /**
  7687. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7688. * @param url defines the url of the prefiltered texture
  7689. * @param scene defines the scene the texture is attached to
  7690. * @param forcedExtension defines the extension of the file if different from the url
  7691. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7692. * @return the prefiltered texture
  7693. */
  7694. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7695. /**
  7696. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7697. * as prefiltered data.
  7698. * @param rootUrl defines the url of the texture or the root name of the six images
  7699. * @param scene defines the scene the texture is attached to
  7700. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7701. * @param noMipmap defines if mipmaps should be created or not
  7702. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7703. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7704. * @param onError defines a callback triggered in case of error during load
  7705. * @param format defines the internal format to use for the texture once loaded
  7706. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7707. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7708. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7709. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7710. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7711. * @return the cube texture
  7712. */
  7713. 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);
  7714. /**
  7715. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7716. */
  7717. get isPrefiltered(): boolean;
  7718. /**
  7719. * Get the current class name of the texture useful for serialization or dynamic coding.
  7720. * @returns "CubeTexture"
  7721. */
  7722. getClassName(): string;
  7723. /**
  7724. * Update the url (and optional buffer) of this texture if url was null during construction.
  7725. * @param url the url of the texture
  7726. * @param forcedExtension defines the extension to use
  7727. * @param onLoad callback called when the texture is loaded (defaults to null)
  7728. */
  7729. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7730. /**
  7731. * Delays loading of the cube texture
  7732. * @param forcedExtension defines the extension to use
  7733. */
  7734. delayLoad(forcedExtension?: string): void;
  7735. /**
  7736. * Returns the reflection texture matrix
  7737. * @returns the reflection texture matrix
  7738. */
  7739. getReflectionTextureMatrix(): Matrix;
  7740. /**
  7741. * Sets the reflection texture matrix
  7742. * @param value Reflection texture matrix
  7743. */
  7744. setReflectionTextureMatrix(value: Matrix): void;
  7745. /**
  7746. * Parses text to create a cube texture
  7747. * @param parsedTexture define the serialized text to read from
  7748. * @param scene defines the hosting scene
  7749. * @param rootUrl defines the root url of the cube texture
  7750. * @returns a cube texture
  7751. */
  7752. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7753. /**
  7754. * Makes a clone, or deep copy, of the cube texture
  7755. * @returns a new cube texture
  7756. */
  7757. clone(): CubeTexture;
  7758. }
  7759. }
  7760. declare module BABYLON {
  7761. /**
  7762. * Manages the defines for the Material
  7763. */
  7764. export class MaterialDefines {
  7765. /** @hidden */
  7766. protected _keys: string[];
  7767. private _isDirty;
  7768. /** @hidden */
  7769. _renderId: number;
  7770. /** @hidden */
  7771. _areLightsDirty: boolean;
  7772. /** @hidden */
  7773. _areLightsDisposed: boolean;
  7774. /** @hidden */
  7775. _areAttributesDirty: boolean;
  7776. /** @hidden */
  7777. _areTexturesDirty: boolean;
  7778. /** @hidden */
  7779. _areFresnelDirty: boolean;
  7780. /** @hidden */
  7781. _areMiscDirty: boolean;
  7782. /** @hidden */
  7783. _areImageProcessingDirty: boolean;
  7784. /** @hidden */
  7785. _normals: boolean;
  7786. /** @hidden */
  7787. _uvs: boolean;
  7788. /** @hidden */
  7789. _needNormals: boolean;
  7790. /** @hidden */
  7791. _needUVs: boolean;
  7792. [id: string]: any;
  7793. /**
  7794. * Specifies if the material needs to be re-calculated
  7795. */
  7796. get isDirty(): boolean;
  7797. /**
  7798. * Marks the material to indicate that it has been re-calculated
  7799. */
  7800. markAsProcessed(): void;
  7801. /**
  7802. * Marks the material to indicate that it needs to be re-calculated
  7803. */
  7804. markAsUnprocessed(): void;
  7805. /**
  7806. * Marks the material to indicate all of its defines need to be re-calculated
  7807. */
  7808. markAllAsDirty(): void;
  7809. /**
  7810. * Marks the material to indicate that image processing needs to be re-calculated
  7811. */
  7812. markAsImageProcessingDirty(): void;
  7813. /**
  7814. * Marks the material to indicate the lights need to be re-calculated
  7815. * @param disposed Defines whether the light is dirty due to dispose or not
  7816. */
  7817. markAsLightDirty(disposed?: boolean): void;
  7818. /**
  7819. * Marks the attribute state as changed
  7820. */
  7821. markAsAttributesDirty(): void;
  7822. /**
  7823. * Marks the texture state as changed
  7824. */
  7825. markAsTexturesDirty(): void;
  7826. /**
  7827. * Marks the fresnel state as changed
  7828. */
  7829. markAsFresnelDirty(): void;
  7830. /**
  7831. * Marks the misc state as changed
  7832. */
  7833. markAsMiscDirty(): void;
  7834. /**
  7835. * Rebuilds the material defines
  7836. */
  7837. rebuild(): void;
  7838. /**
  7839. * Specifies if two material defines are equal
  7840. * @param other - A material define instance to compare to
  7841. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7842. */
  7843. isEqual(other: MaterialDefines): boolean;
  7844. /**
  7845. * Clones this instance's defines to another instance
  7846. * @param other - material defines to clone values to
  7847. */
  7848. cloneTo(other: MaterialDefines): void;
  7849. /**
  7850. * Resets the material define values
  7851. */
  7852. reset(): void;
  7853. /**
  7854. * Converts the material define values to a string
  7855. * @returns - String of material define information
  7856. */
  7857. toString(): string;
  7858. }
  7859. }
  7860. declare module BABYLON {
  7861. /**
  7862. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7863. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7864. * 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;
  7865. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7866. */
  7867. export class ColorCurves {
  7868. private _dirty;
  7869. private _tempColor;
  7870. private _globalCurve;
  7871. private _highlightsCurve;
  7872. private _midtonesCurve;
  7873. private _shadowsCurve;
  7874. private _positiveCurve;
  7875. private _negativeCurve;
  7876. private _globalHue;
  7877. private _globalDensity;
  7878. private _globalSaturation;
  7879. private _globalExposure;
  7880. /**
  7881. * Gets the global Hue value.
  7882. * 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).
  7883. */
  7884. get globalHue(): number;
  7885. /**
  7886. * Sets the global Hue value.
  7887. * 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).
  7888. */
  7889. set globalHue(value: number);
  7890. /**
  7891. * Gets the global Density value.
  7892. * 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.
  7893. * Values less than zero provide a filter of opposite hue.
  7894. */
  7895. get globalDensity(): number;
  7896. /**
  7897. * Sets the global Density value.
  7898. * 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.
  7899. * Values less than zero provide a filter of opposite hue.
  7900. */
  7901. set globalDensity(value: number);
  7902. /**
  7903. * Gets the global Saturation value.
  7904. * 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.
  7905. */
  7906. get globalSaturation(): number;
  7907. /**
  7908. * Sets the global Saturation value.
  7909. * 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.
  7910. */
  7911. set globalSaturation(value: number);
  7912. /**
  7913. * Gets the global Exposure value.
  7914. * 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.
  7915. */
  7916. get globalExposure(): number;
  7917. /**
  7918. * Sets the global Exposure value.
  7919. * 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.
  7920. */
  7921. set globalExposure(value: number);
  7922. private _highlightsHue;
  7923. private _highlightsDensity;
  7924. private _highlightsSaturation;
  7925. private _highlightsExposure;
  7926. /**
  7927. * Gets the highlights Hue value.
  7928. * 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).
  7929. */
  7930. get highlightsHue(): number;
  7931. /**
  7932. * Sets the highlights Hue value.
  7933. * 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).
  7934. */
  7935. set highlightsHue(value: number);
  7936. /**
  7937. * Gets the highlights Density value.
  7938. * 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.
  7939. * Values less than zero provide a filter of opposite hue.
  7940. */
  7941. get highlightsDensity(): number;
  7942. /**
  7943. * Sets the highlights Density value.
  7944. * 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.
  7945. * Values less than zero provide a filter of opposite hue.
  7946. */
  7947. set highlightsDensity(value: number);
  7948. /**
  7949. * Gets the highlights Saturation value.
  7950. * 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.
  7951. */
  7952. get highlightsSaturation(): number;
  7953. /**
  7954. * Sets the highlights Saturation value.
  7955. * 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.
  7956. */
  7957. set highlightsSaturation(value: number);
  7958. /**
  7959. * Gets the highlights Exposure value.
  7960. * 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.
  7961. */
  7962. get highlightsExposure(): number;
  7963. /**
  7964. * Sets the highlights Exposure value.
  7965. * 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.
  7966. */
  7967. set highlightsExposure(value: number);
  7968. private _midtonesHue;
  7969. private _midtonesDensity;
  7970. private _midtonesSaturation;
  7971. private _midtonesExposure;
  7972. /**
  7973. * Gets the midtones Hue value.
  7974. * 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).
  7975. */
  7976. get midtonesHue(): number;
  7977. /**
  7978. * Sets the midtones Hue value.
  7979. * 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).
  7980. */
  7981. set midtonesHue(value: number);
  7982. /**
  7983. * Gets the midtones Density value.
  7984. * 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.
  7985. * Values less than zero provide a filter of opposite hue.
  7986. */
  7987. get midtonesDensity(): number;
  7988. /**
  7989. * Sets the midtones Density value.
  7990. * 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.
  7991. * Values less than zero provide a filter of opposite hue.
  7992. */
  7993. set midtonesDensity(value: number);
  7994. /**
  7995. * Gets the midtones Saturation value.
  7996. * 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.
  7997. */
  7998. get midtonesSaturation(): number;
  7999. /**
  8000. * Sets the midtones Saturation value.
  8001. * 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.
  8002. */
  8003. set midtonesSaturation(value: number);
  8004. /**
  8005. * Gets the midtones Exposure value.
  8006. * 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.
  8007. */
  8008. get midtonesExposure(): number;
  8009. /**
  8010. * Sets the midtones Exposure value.
  8011. * 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.
  8012. */
  8013. set midtonesExposure(value: number);
  8014. private _shadowsHue;
  8015. private _shadowsDensity;
  8016. private _shadowsSaturation;
  8017. private _shadowsExposure;
  8018. /**
  8019. * Gets the shadows Hue value.
  8020. * 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).
  8021. */
  8022. get shadowsHue(): number;
  8023. /**
  8024. * Sets the shadows Hue value.
  8025. * 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).
  8026. */
  8027. set shadowsHue(value: number);
  8028. /**
  8029. * Gets the shadows Density value.
  8030. * 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.
  8031. * Values less than zero provide a filter of opposite hue.
  8032. */
  8033. get shadowsDensity(): number;
  8034. /**
  8035. * Sets the shadows Density value.
  8036. * 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.
  8037. * Values less than zero provide a filter of opposite hue.
  8038. */
  8039. set shadowsDensity(value: number);
  8040. /**
  8041. * Gets the shadows Saturation value.
  8042. * 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.
  8043. */
  8044. get shadowsSaturation(): number;
  8045. /**
  8046. * Sets the shadows Saturation value.
  8047. * 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.
  8048. */
  8049. set shadowsSaturation(value: number);
  8050. /**
  8051. * Gets the shadows Exposure value.
  8052. * 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.
  8053. */
  8054. get shadowsExposure(): number;
  8055. /**
  8056. * Sets the shadows Exposure value.
  8057. * 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.
  8058. */
  8059. set shadowsExposure(value: number);
  8060. /**
  8061. * Returns the class name
  8062. * @returns The class name
  8063. */
  8064. getClassName(): string;
  8065. /**
  8066. * Binds the color curves to the shader.
  8067. * @param colorCurves The color curve to bind
  8068. * @param effect The effect to bind to
  8069. * @param positiveUniform The positive uniform shader parameter
  8070. * @param neutralUniform The neutral uniform shader parameter
  8071. * @param negativeUniform The negative uniform shader parameter
  8072. */
  8073. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8074. /**
  8075. * Prepare the list of uniforms associated with the ColorCurves effects.
  8076. * @param uniformsList The list of uniforms used in the effect
  8077. */
  8078. static PrepareUniforms(uniformsList: string[]): void;
  8079. /**
  8080. * Returns color grading data based on a hue, density, saturation and exposure value.
  8081. * @param filterHue The hue of the color filter.
  8082. * @param filterDensity The density of the color filter.
  8083. * @param saturation The saturation.
  8084. * @param exposure The exposure.
  8085. * @param result The result data container.
  8086. */
  8087. private getColorGradingDataToRef;
  8088. /**
  8089. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8090. * @param value The input slider value in range [-100,100].
  8091. * @returns Adjusted value.
  8092. */
  8093. private static applyColorGradingSliderNonlinear;
  8094. /**
  8095. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8096. * @param hue The hue (H) input.
  8097. * @param saturation The saturation (S) input.
  8098. * @param brightness The brightness (B) input.
  8099. * @result An RGBA color represented as Vector4.
  8100. */
  8101. private static fromHSBToRef;
  8102. /**
  8103. * Returns a value clamped between min and max
  8104. * @param value The value to clamp
  8105. * @param min The minimum of value
  8106. * @param max The maximum of value
  8107. * @returns The clamped value.
  8108. */
  8109. private static clamp;
  8110. /**
  8111. * Clones the current color curve instance.
  8112. * @return The cloned curves
  8113. */
  8114. clone(): ColorCurves;
  8115. /**
  8116. * Serializes the current color curve instance to a json representation.
  8117. * @return a JSON representation
  8118. */
  8119. serialize(): any;
  8120. /**
  8121. * Parses the color curve from a json representation.
  8122. * @param source the JSON source to parse
  8123. * @return The parsed curves
  8124. */
  8125. static Parse(source: any): ColorCurves;
  8126. }
  8127. }
  8128. declare module BABYLON {
  8129. /**
  8130. * Interface to follow in your material defines to integrate easily the
  8131. * Image proccessing functions.
  8132. * @hidden
  8133. */
  8134. export interface IImageProcessingConfigurationDefines {
  8135. IMAGEPROCESSING: boolean;
  8136. VIGNETTE: boolean;
  8137. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8138. VIGNETTEBLENDMODEOPAQUE: boolean;
  8139. TONEMAPPING: boolean;
  8140. TONEMAPPING_ACES: boolean;
  8141. CONTRAST: boolean;
  8142. EXPOSURE: boolean;
  8143. COLORCURVES: boolean;
  8144. COLORGRADING: boolean;
  8145. COLORGRADING3D: boolean;
  8146. SAMPLER3DGREENDEPTH: boolean;
  8147. SAMPLER3DBGRMAP: boolean;
  8148. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8149. }
  8150. /**
  8151. * @hidden
  8152. */
  8153. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8154. IMAGEPROCESSING: boolean;
  8155. VIGNETTE: boolean;
  8156. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8157. VIGNETTEBLENDMODEOPAQUE: boolean;
  8158. TONEMAPPING: boolean;
  8159. TONEMAPPING_ACES: boolean;
  8160. CONTRAST: boolean;
  8161. COLORCURVES: boolean;
  8162. COLORGRADING: boolean;
  8163. COLORGRADING3D: boolean;
  8164. SAMPLER3DGREENDEPTH: boolean;
  8165. SAMPLER3DBGRMAP: boolean;
  8166. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8167. EXPOSURE: boolean;
  8168. constructor();
  8169. }
  8170. /**
  8171. * This groups together the common properties used for image processing either in direct forward pass
  8172. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8173. * or not.
  8174. */
  8175. export class ImageProcessingConfiguration {
  8176. /**
  8177. * Default tone mapping applied in BabylonJS.
  8178. */
  8179. static readonly TONEMAPPING_STANDARD: number;
  8180. /**
  8181. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8182. * to other engines rendering to increase portability.
  8183. */
  8184. static readonly TONEMAPPING_ACES: number;
  8185. /**
  8186. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8187. */
  8188. colorCurves: Nullable<ColorCurves>;
  8189. private _colorCurvesEnabled;
  8190. /**
  8191. * Gets wether the color curves effect is enabled.
  8192. */
  8193. get colorCurvesEnabled(): boolean;
  8194. /**
  8195. * Sets wether the color curves effect is enabled.
  8196. */
  8197. set colorCurvesEnabled(value: boolean);
  8198. private _colorGradingTexture;
  8199. /**
  8200. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8201. */
  8202. get colorGradingTexture(): Nullable<BaseTexture>;
  8203. /**
  8204. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8205. */
  8206. set colorGradingTexture(value: Nullable<BaseTexture>);
  8207. private _colorGradingEnabled;
  8208. /**
  8209. * Gets wether the color grading effect is enabled.
  8210. */
  8211. get colorGradingEnabled(): boolean;
  8212. /**
  8213. * Sets wether the color grading effect is enabled.
  8214. */
  8215. set colorGradingEnabled(value: boolean);
  8216. private _colorGradingWithGreenDepth;
  8217. /**
  8218. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8219. */
  8220. get colorGradingWithGreenDepth(): boolean;
  8221. /**
  8222. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8223. */
  8224. set colorGradingWithGreenDepth(value: boolean);
  8225. private _colorGradingBGR;
  8226. /**
  8227. * Gets wether the color grading texture contains BGR values.
  8228. */
  8229. get colorGradingBGR(): boolean;
  8230. /**
  8231. * Sets wether the color grading texture contains BGR values.
  8232. */
  8233. set colorGradingBGR(value: boolean);
  8234. /** @hidden */
  8235. _exposure: number;
  8236. /**
  8237. * Gets the Exposure used in the effect.
  8238. */
  8239. get exposure(): number;
  8240. /**
  8241. * Sets the Exposure used in the effect.
  8242. */
  8243. set exposure(value: number);
  8244. private _toneMappingEnabled;
  8245. /**
  8246. * Gets wether the tone mapping effect is enabled.
  8247. */
  8248. get toneMappingEnabled(): boolean;
  8249. /**
  8250. * Sets wether the tone mapping effect is enabled.
  8251. */
  8252. set toneMappingEnabled(value: boolean);
  8253. private _toneMappingType;
  8254. /**
  8255. * Gets the type of tone mapping effect.
  8256. */
  8257. get toneMappingType(): number;
  8258. /**
  8259. * Sets the type of tone mapping effect used in BabylonJS.
  8260. */
  8261. set toneMappingType(value: number);
  8262. protected _contrast: number;
  8263. /**
  8264. * Gets the contrast used in the effect.
  8265. */
  8266. get contrast(): number;
  8267. /**
  8268. * Sets the contrast used in the effect.
  8269. */
  8270. set contrast(value: number);
  8271. /**
  8272. * Vignette stretch size.
  8273. */
  8274. vignetteStretch: number;
  8275. /**
  8276. * Vignette centre X Offset.
  8277. */
  8278. vignetteCentreX: number;
  8279. /**
  8280. * Vignette centre Y Offset.
  8281. */
  8282. vignetteCentreY: number;
  8283. /**
  8284. * Vignette weight or intensity of the vignette effect.
  8285. */
  8286. vignetteWeight: number;
  8287. /**
  8288. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8289. * if vignetteEnabled is set to true.
  8290. */
  8291. vignetteColor: Color4;
  8292. /**
  8293. * Camera field of view used by the Vignette effect.
  8294. */
  8295. vignetteCameraFov: number;
  8296. private _vignetteBlendMode;
  8297. /**
  8298. * Gets the vignette blend mode allowing different kind of effect.
  8299. */
  8300. get vignetteBlendMode(): number;
  8301. /**
  8302. * Sets the vignette blend mode allowing different kind of effect.
  8303. */
  8304. set vignetteBlendMode(value: number);
  8305. private _vignetteEnabled;
  8306. /**
  8307. * Gets wether the vignette effect is enabled.
  8308. */
  8309. get vignetteEnabled(): boolean;
  8310. /**
  8311. * Sets wether the vignette effect is enabled.
  8312. */
  8313. set vignetteEnabled(value: boolean);
  8314. private _applyByPostProcess;
  8315. /**
  8316. * Gets wether the image processing is applied through a post process or not.
  8317. */
  8318. get applyByPostProcess(): boolean;
  8319. /**
  8320. * Sets wether the image processing is applied through a post process or not.
  8321. */
  8322. set applyByPostProcess(value: boolean);
  8323. private _isEnabled;
  8324. /**
  8325. * Gets wether the image processing is enabled or not.
  8326. */
  8327. get isEnabled(): boolean;
  8328. /**
  8329. * Sets wether the image processing is enabled or not.
  8330. */
  8331. set isEnabled(value: boolean);
  8332. /**
  8333. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8334. */
  8335. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8336. /**
  8337. * Method called each time the image processing information changes requires to recompile the effect.
  8338. */
  8339. protected _updateParameters(): void;
  8340. /**
  8341. * Gets the current class name.
  8342. * @return "ImageProcessingConfiguration"
  8343. */
  8344. getClassName(): string;
  8345. /**
  8346. * Prepare the list of uniforms associated with the Image Processing effects.
  8347. * @param uniforms The list of uniforms used in the effect
  8348. * @param defines the list of defines currently in use
  8349. */
  8350. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8351. /**
  8352. * Prepare the list of samplers associated with the Image Processing effects.
  8353. * @param samplersList The list of uniforms used in the effect
  8354. * @param defines the list of defines currently in use
  8355. */
  8356. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8357. /**
  8358. * Prepare the list of defines associated to the shader.
  8359. * @param defines the list of defines to complete
  8360. * @param forPostProcess Define if we are currently in post process mode or not
  8361. */
  8362. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8363. /**
  8364. * Returns true if all the image processing information are ready.
  8365. * @returns True if ready, otherwise, false
  8366. */
  8367. isReady(): boolean;
  8368. /**
  8369. * Binds the image processing to the shader.
  8370. * @param effect The effect to bind to
  8371. * @param overrideAspectRatio Override the aspect ratio of the effect
  8372. */
  8373. bind(effect: Effect, overrideAspectRatio?: number): void;
  8374. /**
  8375. * Clones the current image processing instance.
  8376. * @return The cloned image processing
  8377. */
  8378. clone(): ImageProcessingConfiguration;
  8379. /**
  8380. * Serializes the current image processing instance to a json representation.
  8381. * @return a JSON representation
  8382. */
  8383. serialize(): any;
  8384. /**
  8385. * Parses the image processing from a json representation.
  8386. * @param source the JSON source to parse
  8387. * @return The parsed image processing
  8388. */
  8389. static Parse(source: any): ImageProcessingConfiguration;
  8390. private static _VIGNETTEMODE_MULTIPLY;
  8391. private static _VIGNETTEMODE_OPAQUE;
  8392. /**
  8393. * Used to apply the vignette as a mix with the pixel color.
  8394. */
  8395. static get VIGNETTEMODE_MULTIPLY(): number;
  8396. /**
  8397. * Used to apply the vignette as a replacement of the pixel color.
  8398. */
  8399. static get VIGNETTEMODE_OPAQUE(): number;
  8400. }
  8401. }
  8402. declare module BABYLON {
  8403. /** @hidden */
  8404. export var postprocessVertexShader: {
  8405. name: string;
  8406. shader: string;
  8407. };
  8408. }
  8409. declare module BABYLON {
  8410. interface ThinEngine {
  8411. /**
  8412. * Creates a new render target texture
  8413. * @param size defines the size of the texture
  8414. * @param options defines the options used to create the texture
  8415. * @returns a new render target texture stored in an InternalTexture
  8416. */
  8417. createRenderTargetTexture(size: number | {
  8418. width: number;
  8419. height: number;
  8420. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8421. /**
  8422. * Creates a depth stencil texture.
  8423. * This is only available in WebGL 2 or with the depth texture extension available.
  8424. * @param size The size of face edge in the texture.
  8425. * @param options The options defining the texture.
  8426. * @returns The texture
  8427. */
  8428. createDepthStencilTexture(size: number | {
  8429. width: number;
  8430. height: number;
  8431. }, options: DepthTextureCreationOptions): InternalTexture;
  8432. /** @hidden */
  8433. _createDepthStencilTexture(size: number | {
  8434. width: number;
  8435. height: number;
  8436. }, options: DepthTextureCreationOptions): InternalTexture;
  8437. }
  8438. }
  8439. declare module BABYLON {
  8440. /** Defines supported spaces */
  8441. export enum Space {
  8442. /** Local (object) space */
  8443. LOCAL = 0,
  8444. /** World space */
  8445. WORLD = 1,
  8446. /** Bone space */
  8447. BONE = 2
  8448. }
  8449. /** Defines the 3 main axes */
  8450. export class Axis {
  8451. /** X axis */
  8452. static X: Vector3;
  8453. /** Y axis */
  8454. static Y: Vector3;
  8455. /** Z axis */
  8456. static Z: Vector3;
  8457. }
  8458. }
  8459. declare module BABYLON {
  8460. /**
  8461. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8462. * This is the base of the follow, arc rotate cameras and Free camera
  8463. * @see http://doc.babylonjs.com/features/cameras
  8464. */
  8465. export class TargetCamera extends Camera {
  8466. private static _RigCamTransformMatrix;
  8467. private static _TargetTransformMatrix;
  8468. private static _TargetFocalPoint;
  8469. /**
  8470. * Define the current direction the camera is moving to
  8471. */
  8472. cameraDirection: Vector3;
  8473. /**
  8474. * Define the current rotation the camera is rotating to
  8475. */
  8476. cameraRotation: Vector2;
  8477. /**
  8478. * When set, the up vector of the camera will be updated by the rotation of the camera
  8479. */
  8480. updateUpVectorFromRotation: boolean;
  8481. private _tmpQuaternion;
  8482. /**
  8483. * Define the current rotation of the camera
  8484. */
  8485. rotation: Vector3;
  8486. /**
  8487. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8488. */
  8489. rotationQuaternion: Quaternion;
  8490. /**
  8491. * Define the current speed of the camera
  8492. */
  8493. speed: number;
  8494. /**
  8495. * Add constraint to the camera to prevent it to move freely in all directions and
  8496. * around all axis.
  8497. */
  8498. noRotationConstraint: boolean;
  8499. /**
  8500. * Define the current target of the camera as an object or a position.
  8501. */
  8502. lockedTarget: any;
  8503. /** @hidden */
  8504. _currentTarget: Vector3;
  8505. /** @hidden */
  8506. _initialFocalDistance: number;
  8507. /** @hidden */
  8508. _viewMatrix: Matrix;
  8509. /** @hidden */
  8510. _camMatrix: Matrix;
  8511. /** @hidden */
  8512. _cameraTransformMatrix: Matrix;
  8513. /** @hidden */
  8514. _cameraRotationMatrix: Matrix;
  8515. /** @hidden */
  8516. _referencePoint: Vector3;
  8517. /** @hidden */
  8518. _transformedReferencePoint: Vector3;
  8519. protected _globalCurrentTarget: Vector3;
  8520. protected _globalCurrentUpVector: Vector3;
  8521. /** @hidden */
  8522. _reset: () => void;
  8523. private _defaultUp;
  8524. /**
  8525. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8526. * This is the base of the follow, arc rotate cameras and Free camera
  8527. * @see http://doc.babylonjs.com/features/cameras
  8528. * @param name Defines the name of the camera in the scene
  8529. * @param position Defines the start position of the camera in the scene
  8530. * @param scene Defines the scene the camera belongs to
  8531. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8532. */
  8533. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8534. /**
  8535. * Gets the position in front of the camera at a given distance.
  8536. * @param distance The distance from the camera we want the position to be
  8537. * @returns the position
  8538. */
  8539. getFrontPosition(distance: number): Vector3;
  8540. /** @hidden */
  8541. _getLockedTargetPosition(): Nullable<Vector3>;
  8542. private _storedPosition;
  8543. private _storedRotation;
  8544. private _storedRotationQuaternion;
  8545. /**
  8546. * Store current camera state of the camera (fov, position, rotation, etc..)
  8547. * @returns the camera
  8548. */
  8549. storeState(): Camera;
  8550. /**
  8551. * Restored camera state. You must call storeState() first
  8552. * @returns whether it was successful or not
  8553. * @hidden
  8554. */
  8555. _restoreStateValues(): boolean;
  8556. /** @hidden */
  8557. _initCache(): void;
  8558. /** @hidden */
  8559. _updateCache(ignoreParentClass?: boolean): void;
  8560. /** @hidden */
  8561. _isSynchronizedViewMatrix(): boolean;
  8562. /** @hidden */
  8563. _computeLocalCameraSpeed(): number;
  8564. /**
  8565. * Defines the target the camera should look at.
  8566. * @param target Defines the new target as a Vector or a mesh
  8567. */
  8568. setTarget(target: Vector3): void;
  8569. /**
  8570. * Return the current target position of the camera. This value is expressed in local space.
  8571. * @returns the target position
  8572. */
  8573. getTarget(): Vector3;
  8574. /** @hidden */
  8575. _decideIfNeedsToMove(): boolean;
  8576. /** @hidden */
  8577. _updatePosition(): void;
  8578. /** @hidden */
  8579. _checkInputs(): void;
  8580. protected _updateCameraRotationMatrix(): void;
  8581. /**
  8582. * 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)
  8583. * @returns the current camera
  8584. */
  8585. private _rotateUpVectorWithCameraRotationMatrix;
  8586. private _cachedRotationZ;
  8587. private _cachedQuaternionRotationZ;
  8588. /** @hidden */
  8589. _getViewMatrix(): Matrix;
  8590. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8591. /**
  8592. * @hidden
  8593. */
  8594. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8595. /**
  8596. * @hidden
  8597. */
  8598. _updateRigCameras(): void;
  8599. private _getRigCamPositionAndTarget;
  8600. /**
  8601. * Gets the current object class name.
  8602. * @return the class name
  8603. */
  8604. getClassName(): string;
  8605. }
  8606. }
  8607. declare module BABYLON {
  8608. /**
  8609. * Gather the list of keyboard event types as constants.
  8610. */
  8611. export class KeyboardEventTypes {
  8612. /**
  8613. * The keydown event is fired when a key becomes active (pressed).
  8614. */
  8615. static readonly KEYDOWN: number;
  8616. /**
  8617. * The keyup event is fired when a key has been released.
  8618. */
  8619. static readonly KEYUP: number;
  8620. }
  8621. /**
  8622. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8623. */
  8624. export class KeyboardInfo {
  8625. /**
  8626. * Defines the type of event (KeyboardEventTypes)
  8627. */
  8628. type: number;
  8629. /**
  8630. * Defines the related dom event
  8631. */
  8632. event: KeyboardEvent;
  8633. /**
  8634. * Instantiates a new keyboard info.
  8635. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8636. * @param type Defines the type of event (KeyboardEventTypes)
  8637. * @param event Defines the related dom event
  8638. */
  8639. constructor(
  8640. /**
  8641. * Defines the type of event (KeyboardEventTypes)
  8642. */
  8643. type: number,
  8644. /**
  8645. * Defines the related dom event
  8646. */
  8647. event: KeyboardEvent);
  8648. }
  8649. /**
  8650. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8651. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8652. */
  8653. export class KeyboardInfoPre extends KeyboardInfo {
  8654. /**
  8655. * Defines the type of event (KeyboardEventTypes)
  8656. */
  8657. type: number;
  8658. /**
  8659. * Defines the related dom event
  8660. */
  8661. event: KeyboardEvent;
  8662. /**
  8663. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8664. */
  8665. skipOnPointerObservable: boolean;
  8666. /**
  8667. * Instantiates a new keyboard pre info.
  8668. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8669. * @param type Defines the type of event (KeyboardEventTypes)
  8670. * @param event Defines the related dom event
  8671. */
  8672. constructor(
  8673. /**
  8674. * Defines the type of event (KeyboardEventTypes)
  8675. */
  8676. type: number,
  8677. /**
  8678. * Defines the related dom event
  8679. */
  8680. event: KeyboardEvent);
  8681. }
  8682. }
  8683. declare module BABYLON {
  8684. /**
  8685. * Manage the keyboard inputs to control the movement of a free camera.
  8686. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8687. */
  8688. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8689. /**
  8690. * Defines the camera the input is attached to.
  8691. */
  8692. camera: FreeCamera;
  8693. /**
  8694. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8695. */
  8696. keysUp: number[];
  8697. /**
  8698. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8699. */
  8700. keysDown: number[];
  8701. /**
  8702. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8703. */
  8704. keysLeft: number[];
  8705. /**
  8706. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8707. */
  8708. keysRight: number[];
  8709. private _keys;
  8710. private _onCanvasBlurObserver;
  8711. private _onKeyboardObserver;
  8712. private _engine;
  8713. private _scene;
  8714. /**
  8715. * Attach the input controls to a specific dom element to get the input from.
  8716. * @param element Defines the element the controls should be listened from
  8717. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8718. */
  8719. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8720. /**
  8721. * Detach the current controls from the specified dom element.
  8722. * @param element Defines the element to stop listening the inputs from
  8723. */
  8724. detachControl(element: Nullable<HTMLElement>): void;
  8725. /**
  8726. * Update the current camera state depending on the inputs that have been used this frame.
  8727. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8728. */
  8729. checkInputs(): void;
  8730. /**
  8731. * Gets the class name of the current intput.
  8732. * @returns the class name
  8733. */
  8734. getClassName(): string;
  8735. /** @hidden */
  8736. _onLostFocus(): void;
  8737. /**
  8738. * Get the friendly name associated with the input class.
  8739. * @returns the input friendly name
  8740. */
  8741. getSimpleName(): string;
  8742. }
  8743. }
  8744. declare module BABYLON {
  8745. /**
  8746. * Interface describing all the common properties and methods a shadow light needs to implement.
  8747. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8748. * as well as binding the different shadow properties to the effects.
  8749. */
  8750. export interface IShadowLight extends Light {
  8751. /**
  8752. * The light id in the scene (used in scene.findLighById for instance)
  8753. */
  8754. id: string;
  8755. /**
  8756. * The position the shdow will be casted from.
  8757. */
  8758. position: Vector3;
  8759. /**
  8760. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8761. */
  8762. direction: Vector3;
  8763. /**
  8764. * The transformed position. Position of the light in world space taking parenting in account.
  8765. */
  8766. transformedPosition: Vector3;
  8767. /**
  8768. * The transformed direction. Direction of the light in world space taking parenting in account.
  8769. */
  8770. transformedDirection: Vector3;
  8771. /**
  8772. * The friendly name of the light in the scene.
  8773. */
  8774. name: string;
  8775. /**
  8776. * Defines the shadow projection clipping minimum z value.
  8777. */
  8778. shadowMinZ: number;
  8779. /**
  8780. * Defines the shadow projection clipping maximum z value.
  8781. */
  8782. shadowMaxZ: number;
  8783. /**
  8784. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8785. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8786. */
  8787. computeTransformedInformation(): boolean;
  8788. /**
  8789. * Gets the scene the light belongs to.
  8790. * @returns The scene
  8791. */
  8792. getScene(): Scene;
  8793. /**
  8794. * Callback defining a custom Projection Matrix Builder.
  8795. * This can be used to override the default projection matrix computation.
  8796. */
  8797. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8798. /**
  8799. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8800. * @param matrix The materix to updated with the projection information
  8801. * @param viewMatrix The transform matrix of the light
  8802. * @param renderList The list of mesh to render in the map
  8803. * @returns The current light
  8804. */
  8805. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8806. /**
  8807. * Gets the current depth scale used in ESM.
  8808. * @returns The scale
  8809. */
  8810. getDepthScale(): number;
  8811. /**
  8812. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8813. * @returns true if a cube texture needs to be use
  8814. */
  8815. needCube(): boolean;
  8816. /**
  8817. * Detects if the projection matrix requires to be recomputed this frame.
  8818. * @returns true if it requires to be recomputed otherwise, false.
  8819. */
  8820. needProjectionMatrixCompute(): boolean;
  8821. /**
  8822. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8823. */
  8824. forceProjectionMatrixCompute(): void;
  8825. /**
  8826. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8827. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8828. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8829. */
  8830. getShadowDirection(faceIndex?: number): Vector3;
  8831. /**
  8832. * Gets the minZ used for shadow according to both the scene and the light.
  8833. * @param activeCamera The camera we are returning the min for
  8834. * @returns the depth min z
  8835. */
  8836. getDepthMinZ(activeCamera: Camera): number;
  8837. /**
  8838. * Gets the maxZ used for shadow according to both the scene and the light.
  8839. * @param activeCamera The camera we are returning the max for
  8840. * @returns the depth max z
  8841. */
  8842. getDepthMaxZ(activeCamera: Camera): number;
  8843. }
  8844. /**
  8845. * Base implementation IShadowLight
  8846. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8847. */
  8848. export abstract class ShadowLight extends Light implements IShadowLight {
  8849. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8850. protected _position: Vector3;
  8851. protected _setPosition(value: Vector3): void;
  8852. /**
  8853. * Sets the position the shadow will be casted from. Also use as the light position for both
  8854. * point and spot lights.
  8855. */
  8856. get position(): Vector3;
  8857. /**
  8858. * Sets the position the shadow will be casted from. Also use as the light position for both
  8859. * point and spot lights.
  8860. */
  8861. set position(value: Vector3);
  8862. protected _direction: Vector3;
  8863. protected _setDirection(value: Vector3): void;
  8864. /**
  8865. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8866. * Also use as the light direction on spot and directional lights.
  8867. */
  8868. get direction(): Vector3;
  8869. /**
  8870. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8871. * Also use as the light direction on spot and directional lights.
  8872. */
  8873. set direction(value: Vector3);
  8874. private _shadowMinZ;
  8875. /**
  8876. * Gets the shadow projection clipping minimum z value.
  8877. */
  8878. get shadowMinZ(): number;
  8879. /**
  8880. * Sets the shadow projection clipping minimum z value.
  8881. */
  8882. set shadowMinZ(value: number);
  8883. private _shadowMaxZ;
  8884. /**
  8885. * Sets the shadow projection clipping maximum z value.
  8886. */
  8887. get shadowMaxZ(): number;
  8888. /**
  8889. * Gets the shadow projection clipping maximum z value.
  8890. */
  8891. set shadowMaxZ(value: number);
  8892. /**
  8893. * Callback defining a custom Projection Matrix Builder.
  8894. * This can be used to override the default projection matrix computation.
  8895. */
  8896. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8897. /**
  8898. * The transformed position. Position of the light in world space taking parenting in account.
  8899. */
  8900. transformedPosition: Vector3;
  8901. /**
  8902. * The transformed direction. Direction of the light in world space taking parenting in account.
  8903. */
  8904. transformedDirection: Vector3;
  8905. private _needProjectionMatrixCompute;
  8906. /**
  8907. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8908. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8909. */
  8910. computeTransformedInformation(): boolean;
  8911. /**
  8912. * Return the depth scale used for the shadow map.
  8913. * @returns the depth scale.
  8914. */
  8915. getDepthScale(): number;
  8916. /**
  8917. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8918. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8919. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8920. */
  8921. getShadowDirection(faceIndex?: number): Vector3;
  8922. /**
  8923. * Returns the ShadowLight absolute position in the World.
  8924. * @returns the position vector in world space
  8925. */
  8926. getAbsolutePosition(): Vector3;
  8927. /**
  8928. * Sets the ShadowLight direction toward the passed target.
  8929. * @param target The point to target in local space
  8930. * @returns the updated ShadowLight direction
  8931. */
  8932. setDirectionToTarget(target: Vector3): Vector3;
  8933. /**
  8934. * Returns the light rotation in euler definition.
  8935. * @returns the x y z rotation in local space.
  8936. */
  8937. getRotation(): Vector3;
  8938. /**
  8939. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8940. * @returns true if a cube texture needs to be use
  8941. */
  8942. needCube(): boolean;
  8943. /**
  8944. * Detects if the projection matrix requires to be recomputed this frame.
  8945. * @returns true if it requires to be recomputed otherwise, false.
  8946. */
  8947. needProjectionMatrixCompute(): boolean;
  8948. /**
  8949. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8950. */
  8951. forceProjectionMatrixCompute(): void;
  8952. /** @hidden */
  8953. _initCache(): void;
  8954. /** @hidden */
  8955. _isSynchronized(): boolean;
  8956. /**
  8957. * Computes the world matrix of the node
  8958. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8959. * @returns the world matrix
  8960. */
  8961. computeWorldMatrix(force?: boolean): Matrix;
  8962. /**
  8963. * Gets the minZ used for shadow according to both the scene and the light.
  8964. * @param activeCamera The camera we are returning the min for
  8965. * @returns the depth min z
  8966. */
  8967. getDepthMinZ(activeCamera: Camera): number;
  8968. /**
  8969. * Gets the maxZ used for shadow according to both the scene and the light.
  8970. * @param activeCamera The camera we are returning the max for
  8971. * @returns the depth max z
  8972. */
  8973. getDepthMaxZ(activeCamera: Camera): number;
  8974. /**
  8975. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8976. * @param matrix The materix to updated with the projection information
  8977. * @param viewMatrix The transform matrix of the light
  8978. * @param renderList The list of mesh to render in the map
  8979. * @returns The current light
  8980. */
  8981. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8982. }
  8983. }
  8984. declare module BABYLON {
  8985. /**
  8986. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  8987. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  8988. */
  8989. export class EffectFallbacks implements IEffectFallbacks {
  8990. private _defines;
  8991. private _currentRank;
  8992. private _maxRank;
  8993. private _mesh;
  8994. /**
  8995. * Removes the fallback from the bound mesh.
  8996. */
  8997. unBindMesh(): void;
  8998. /**
  8999. * Adds a fallback on the specified property.
  9000. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9001. * @param define The name of the define in the shader
  9002. */
  9003. addFallback(rank: number, define: string): void;
  9004. /**
  9005. * Sets the mesh to use CPU skinning when needing to fallback.
  9006. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9007. * @param mesh The mesh to use the fallbacks.
  9008. */
  9009. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9010. /**
  9011. * Checks to see if more fallbacks are still availible.
  9012. */
  9013. get hasMoreFallbacks(): boolean;
  9014. /**
  9015. * Removes the defines that should be removed when falling back.
  9016. * @param currentDefines defines the current define statements for the shader.
  9017. * @param effect defines the current effect we try to compile
  9018. * @returns The resulting defines with defines of the current rank removed.
  9019. */
  9020. reduce(currentDefines: string, effect: Effect): string;
  9021. }
  9022. }
  9023. declare module BABYLON {
  9024. /**
  9025. * "Static Class" containing the most commonly used helper while dealing with material for
  9026. * rendering purpose.
  9027. *
  9028. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9029. *
  9030. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9031. */
  9032. export class MaterialHelper {
  9033. /**
  9034. * Bind the current view position to an effect.
  9035. * @param effect The effect to be bound
  9036. * @param scene The scene the eyes position is used from
  9037. */
  9038. static BindEyePosition(effect: Effect, scene: Scene): void;
  9039. /**
  9040. * Helps preparing the defines values about the UVs in used in the effect.
  9041. * UVs are shared as much as we can accross channels in the shaders.
  9042. * @param texture The texture we are preparing the UVs for
  9043. * @param defines The defines to update
  9044. * @param key The channel key "diffuse", "specular"... used in the shader
  9045. */
  9046. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9047. /**
  9048. * Binds a texture matrix value to its corrsponding uniform
  9049. * @param texture The texture to bind the matrix for
  9050. * @param uniformBuffer The uniform buffer receivin the data
  9051. * @param key The channel key "diffuse", "specular"... used in the shader
  9052. */
  9053. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9054. /**
  9055. * Gets the current status of the fog (should it be enabled?)
  9056. * @param mesh defines the mesh to evaluate for fog support
  9057. * @param scene defines the hosting scene
  9058. * @returns true if fog must be enabled
  9059. */
  9060. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9061. /**
  9062. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9063. * @param mesh defines the current mesh
  9064. * @param scene defines the current scene
  9065. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9066. * @param pointsCloud defines if point cloud rendering has to be turned on
  9067. * @param fogEnabled defines if fog has to be turned on
  9068. * @param alphaTest defines if alpha testing has to be turned on
  9069. * @param defines defines the current list of defines
  9070. */
  9071. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9072. /**
  9073. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9074. * @param scene defines the current scene
  9075. * @param engine defines the current engine
  9076. * @param defines specifies the list of active defines
  9077. * @param useInstances defines if instances have to be turned on
  9078. * @param useClipPlane defines if clip plane have to be turned on
  9079. */
  9080. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9081. /**
  9082. * Prepares the defines for bones
  9083. * @param mesh The mesh containing the geometry data we will draw
  9084. * @param defines The defines to update
  9085. */
  9086. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9087. /**
  9088. * Prepares the defines for morph targets
  9089. * @param mesh The mesh containing the geometry data we will draw
  9090. * @param defines The defines to update
  9091. */
  9092. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9093. /**
  9094. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9095. * @param mesh The mesh containing the geometry data we will draw
  9096. * @param defines The defines to update
  9097. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9098. * @param useBones Precise whether bones should be used or not (override mesh info)
  9099. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9100. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9101. * @returns false if defines are considered not dirty and have not been checked
  9102. */
  9103. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9104. /**
  9105. * Prepares the defines related to multiview
  9106. * @param scene The scene we are intending to draw
  9107. * @param defines The defines to update
  9108. */
  9109. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9110. /**
  9111. * Prepares the defines related to the light information passed in parameter
  9112. * @param scene The scene we are intending to draw
  9113. * @param mesh The mesh the effect is compiling for
  9114. * @param light The light the effect is compiling for
  9115. * @param lightIndex The index of the light
  9116. * @param defines The defines to update
  9117. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9118. * @param state Defines the current state regarding what is needed (normals, etc...)
  9119. */
  9120. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9121. needNormals: boolean;
  9122. needRebuild: boolean;
  9123. shadowEnabled: boolean;
  9124. specularEnabled: boolean;
  9125. lightmapMode: boolean;
  9126. }): void;
  9127. /**
  9128. * Prepares the defines related to the light information passed in parameter
  9129. * @param scene The scene we are intending to draw
  9130. * @param mesh The mesh the effect is compiling for
  9131. * @param defines The defines to update
  9132. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9133. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9134. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9135. * @returns true if normals will be required for the rest of the effect
  9136. */
  9137. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9138. /**
  9139. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9140. * @param lightIndex defines the light index
  9141. * @param uniformsList The uniform list
  9142. * @param samplersList The sampler list
  9143. * @param projectedLightTexture defines if projected texture must be used
  9144. * @param uniformBuffersList defines an optional list of uniform buffers
  9145. */
  9146. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9147. /**
  9148. * Prepares the uniforms and samplers list to be used in the effect
  9149. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9150. * @param samplersList The sampler list
  9151. * @param defines The defines helping in the list generation
  9152. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9153. */
  9154. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9155. /**
  9156. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9157. * @param defines The defines to update while falling back
  9158. * @param fallbacks The authorized effect fallbacks
  9159. * @param maxSimultaneousLights The maximum number of lights allowed
  9160. * @param rank the current rank of the Effect
  9161. * @returns The newly affected rank
  9162. */
  9163. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9164. private static _TmpMorphInfluencers;
  9165. /**
  9166. * Prepares the list of attributes required for morph targets according to the effect defines.
  9167. * @param attribs The current list of supported attribs
  9168. * @param mesh The mesh to prepare the morph targets attributes for
  9169. * @param influencers The number of influencers
  9170. */
  9171. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9172. /**
  9173. * Prepares the list of attributes required for morph targets according to the effect defines.
  9174. * @param attribs The current list of supported attribs
  9175. * @param mesh The mesh to prepare the morph targets attributes for
  9176. * @param defines The current Defines of the effect
  9177. */
  9178. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9179. /**
  9180. * Prepares the list of attributes required for bones according to the effect defines.
  9181. * @param attribs The current list of supported attribs
  9182. * @param mesh The mesh to prepare the bones attributes for
  9183. * @param defines The current Defines of the effect
  9184. * @param fallbacks The current efffect fallback strategy
  9185. */
  9186. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9187. /**
  9188. * Check and prepare the list of attributes required for instances according to the effect defines.
  9189. * @param attribs The current list of supported attribs
  9190. * @param defines The current MaterialDefines of the effect
  9191. */
  9192. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9193. /**
  9194. * Add the list of attributes required for instances to the attribs array.
  9195. * @param attribs The current list of supported attribs
  9196. */
  9197. static PushAttributesForInstances(attribs: string[]): void;
  9198. /**
  9199. * Binds the light information to the effect.
  9200. * @param light The light containing the generator
  9201. * @param effect The effect we are binding the data to
  9202. * @param lightIndex The light index in the effect used to render
  9203. */
  9204. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9205. /**
  9206. * Binds the lights information from the scene to the effect for the given mesh.
  9207. * @param light Light to bind
  9208. * @param lightIndex Light index
  9209. * @param scene The scene where the light belongs to
  9210. * @param effect The effect we are binding the data to
  9211. * @param useSpecular Defines if specular is supported
  9212. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9213. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9214. */
  9215. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9216. /**
  9217. * Binds the lights information from the scene to the effect for the given mesh.
  9218. * @param scene The scene the lights belongs to
  9219. * @param mesh The mesh we are binding the information to render
  9220. * @param effect The effect we are binding the data to
  9221. * @param defines The generated defines for the effect
  9222. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9223. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9224. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9225. */
  9226. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9227. private static _tempFogColor;
  9228. /**
  9229. * Binds the fog information from the scene to the effect for the given mesh.
  9230. * @param scene The scene the lights belongs to
  9231. * @param mesh The mesh we are binding the information to render
  9232. * @param effect The effect we are binding the data to
  9233. * @param linearSpace Defines if the fog effect is applied in linear space
  9234. */
  9235. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9236. /**
  9237. * Binds the bones information from the mesh to the effect.
  9238. * @param mesh The mesh we are binding the information to render
  9239. * @param effect The effect we are binding the data to
  9240. */
  9241. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9242. /**
  9243. * Binds the morph targets information from the mesh to the effect.
  9244. * @param abstractMesh The mesh we are binding the information to render
  9245. * @param effect The effect we are binding the data to
  9246. */
  9247. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9248. /**
  9249. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9250. * @param defines The generated defines used in the effect
  9251. * @param effect The effect we are binding the data to
  9252. * @param scene The scene we are willing to render with logarithmic scale for
  9253. */
  9254. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9255. /**
  9256. * Binds the clip plane information from the scene to the effect.
  9257. * @param scene The scene the clip plane information are extracted from
  9258. * @param effect The effect we are binding the data to
  9259. */
  9260. static BindClipPlane(effect: Effect, scene: Scene): void;
  9261. }
  9262. }
  9263. declare module BABYLON {
  9264. /** @hidden */
  9265. export var packingFunctions: {
  9266. name: string;
  9267. shader: string;
  9268. };
  9269. }
  9270. declare module BABYLON {
  9271. /** @hidden */
  9272. export var shadowMapPixelShader: {
  9273. name: string;
  9274. shader: string;
  9275. };
  9276. }
  9277. declare module BABYLON {
  9278. /** @hidden */
  9279. export var bonesDeclaration: {
  9280. name: string;
  9281. shader: string;
  9282. };
  9283. }
  9284. declare module BABYLON {
  9285. /** @hidden */
  9286. export var morphTargetsVertexGlobalDeclaration: {
  9287. name: string;
  9288. shader: string;
  9289. };
  9290. }
  9291. declare module BABYLON {
  9292. /** @hidden */
  9293. export var morphTargetsVertexDeclaration: {
  9294. name: string;
  9295. shader: string;
  9296. };
  9297. }
  9298. declare module BABYLON {
  9299. /** @hidden */
  9300. export var instancesDeclaration: {
  9301. name: string;
  9302. shader: string;
  9303. };
  9304. }
  9305. declare module BABYLON {
  9306. /** @hidden */
  9307. export var helperFunctions: {
  9308. name: string;
  9309. shader: string;
  9310. };
  9311. }
  9312. declare module BABYLON {
  9313. /** @hidden */
  9314. export var morphTargetsVertex: {
  9315. name: string;
  9316. shader: string;
  9317. };
  9318. }
  9319. declare module BABYLON {
  9320. /** @hidden */
  9321. export var instancesVertex: {
  9322. name: string;
  9323. shader: string;
  9324. };
  9325. }
  9326. declare module BABYLON {
  9327. /** @hidden */
  9328. export var bonesVertex: {
  9329. name: string;
  9330. shader: string;
  9331. };
  9332. }
  9333. declare module BABYLON {
  9334. /** @hidden */
  9335. export var shadowMapVertexShader: {
  9336. name: string;
  9337. shader: string;
  9338. };
  9339. }
  9340. declare module BABYLON {
  9341. /** @hidden */
  9342. export var depthBoxBlurPixelShader: {
  9343. name: string;
  9344. shader: string;
  9345. };
  9346. }
  9347. declare module BABYLON {
  9348. /**
  9349. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9350. */
  9351. export interface ICustomShaderOptions {
  9352. /**
  9353. * Gets or sets the custom shader name to use
  9354. */
  9355. shaderName: string;
  9356. /**
  9357. * The list of attribute names used in the shader
  9358. */
  9359. attributes?: string[];
  9360. /**
  9361. * The list of unifrom names used in the shader
  9362. */
  9363. uniforms?: string[];
  9364. /**
  9365. * The list of sampler names used in the shader
  9366. */
  9367. samplers?: string[];
  9368. /**
  9369. * The list of defines used in the shader
  9370. */
  9371. defines?: string[];
  9372. }
  9373. /**
  9374. * Interface to implement to create a shadow generator compatible with BJS.
  9375. */
  9376. export interface IShadowGenerator {
  9377. /**
  9378. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9379. * @returns The render target texture if present otherwise, null
  9380. */
  9381. getShadowMap(): Nullable<RenderTargetTexture>;
  9382. /**
  9383. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9384. * @returns The render target texture if the shadow map is present otherwise, null
  9385. */
  9386. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9387. /**
  9388. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9389. * @param subMesh The submesh we want to render in the shadow map
  9390. * @param useInstances Defines wether will draw in the map using instances
  9391. * @returns true if ready otherwise, false
  9392. */
  9393. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9394. /**
  9395. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9396. * @param defines Defines of the material we want to update
  9397. * @param lightIndex Index of the light in the enabled light list of the material
  9398. */
  9399. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9400. /**
  9401. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9402. * defined in the generator but impacting the effect).
  9403. * It implies the unifroms available on the materials are the standard BJS ones.
  9404. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9405. * @param effect The effect we are binfing the information for
  9406. */
  9407. bindShadowLight(lightIndex: string, effect: Effect): void;
  9408. /**
  9409. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9410. * (eq to shadow prjection matrix * light transform matrix)
  9411. * @returns The transform matrix used to create the shadow map
  9412. */
  9413. getTransformMatrix(): Matrix;
  9414. /**
  9415. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9416. * Cube and 2D textures for instance.
  9417. */
  9418. recreateShadowMap(): void;
  9419. /**
  9420. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9421. * @param onCompiled Callback triggered at the and of the effects compilation
  9422. * @param options Sets of optional options forcing the compilation with different modes
  9423. */
  9424. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9425. useInstances: boolean;
  9426. }>): void;
  9427. /**
  9428. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9429. * @param options Sets of optional options forcing the compilation with different modes
  9430. * @returns A promise that resolves when the compilation completes
  9431. */
  9432. forceCompilationAsync(options?: Partial<{
  9433. useInstances: boolean;
  9434. }>): Promise<void>;
  9435. /**
  9436. * Serializes the shadow generator setup to a json object.
  9437. * @returns The serialized JSON object
  9438. */
  9439. serialize(): any;
  9440. /**
  9441. * Disposes the Shadow map and related Textures and effects.
  9442. */
  9443. dispose(): void;
  9444. }
  9445. /**
  9446. * Default implementation IShadowGenerator.
  9447. * This is the main object responsible of generating shadows in the framework.
  9448. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9449. */
  9450. export class ShadowGenerator implements IShadowGenerator {
  9451. /**
  9452. * Shadow generator mode None: no filtering applied.
  9453. */
  9454. static readonly FILTER_NONE: number;
  9455. /**
  9456. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9457. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9458. */
  9459. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9460. /**
  9461. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9462. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9463. */
  9464. static readonly FILTER_POISSONSAMPLING: number;
  9465. /**
  9466. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9467. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9468. */
  9469. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9470. /**
  9471. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9472. * edge artifacts on steep falloff.
  9473. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9474. */
  9475. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9476. /**
  9477. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9478. * edge artifacts on steep falloff.
  9479. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9480. */
  9481. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9482. /**
  9483. * Shadow generator mode PCF: Percentage Closer Filtering
  9484. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9485. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9486. */
  9487. static readonly FILTER_PCF: number;
  9488. /**
  9489. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9490. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9491. * Contact Hardening
  9492. */
  9493. static readonly FILTER_PCSS: number;
  9494. /**
  9495. * Reserved for PCF and PCSS
  9496. * Highest Quality.
  9497. *
  9498. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9499. *
  9500. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9501. */
  9502. static readonly QUALITY_HIGH: number;
  9503. /**
  9504. * Reserved for PCF and PCSS
  9505. * Good tradeoff for quality/perf cross devices
  9506. *
  9507. * Execute PCF on a 3*3 kernel.
  9508. *
  9509. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9510. */
  9511. static readonly QUALITY_MEDIUM: number;
  9512. /**
  9513. * Reserved for PCF and PCSS
  9514. * The lowest quality but the fastest.
  9515. *
  9516. * Execute PCF on a 1*1 kernel.
  9517. *
  9518. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9519. */
  9520. static readonly QUALITY_LOW: number;
  9521. /** Gets or sets the custom shader name to use */
  9522. customShaderOptions: ICustomShaderOptions;
  9523. /**
  9524. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9525. */
  9526. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9527. /**
  9528. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9529. */
  9530. onAfterShadowMapRenderObservable: Observable<Effect>;
  9531. /**
  9532. * Observable triggered before a mesh is rendered in the shadow map.
  9533. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9534. */
  9535. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9536. /**
  9537. * Observable triggered after a mesh is rendered in the shadow map.
  9538. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9539. */
  9540. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9541. private _bias;
  9542. /**
  9543. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9544. */
  9545. get bias(): number;
  9546. /**
  9547. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9548. */
  9549. set bias(bias: number);
  9550. private _normalBias;
  9551. /**
  9552. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9553. */
  9554. get normalBias(): number;
  9555. /**
  9556. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9557. */
  9558. set normalBias(normalBias: number);
  9559. private _blurBoxOffset;
  9560. /**
  9561. * Gets the blur box offset: offset applied during the blur pass.
  9562. * Only useful if useKernelBlur = false
  9563. */
  9564. get blurBoxOffset(): number;
  9565. /**
  9566. * Sets the blur box offset: offset applied during the blur pass.
  9567. * Only useful if useKernelBlur = false
  9568. */
  9569. set blurBoxOffset(value: number);
  9570. private _blurScale;
  9571. /**
  9572. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9573. * 2 means half of the size.
  9574. */
  9575. get blurScale(): number;
  9576. /**
  9577. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9578. * 2 means half of the size.
  9579. */
  9580. set blurScale(value: number);
  9581. private _blurKernel;
  9582. /**
  9583. * Gets the blur kernel: kernel size of the blur pass.
  9584. * Only useful if useKernelBlur = true
  9585. */
  9586. get blurKernel(): number;
  9587. /**
  9588. * Sets the blur kernel: kernel size of the blur pass.
  9589. * Only useful if useKernelBlur = true
  9590. */
  9591. set blurKernel(value: number);
  9592. private _useKernelBlur;
  9593. /**
  9594. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9595. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9596. */
  9597. get useKernelBlur(): boolean;
  9598. /**
  9599. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9600. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9601. */
  9602. set useKernelBlur(value: boolean);
  9603. private _depthScale;
  9604. /**
  9605. * Gets the depth scale used in ESM mode.
  9606. */
  9607. get depthScale(): number;
  9608. /**
  9609. * Sets the depth scale used in ESM mode.
  9610. * This can override the scale stored on the light.
  9611. */
  9612. set depthScale(value: number);
  9613. private _filter;
  9614. /**
  9615. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9616. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9617. */
  9618. get filter(): number;
  9619. /**
  9620. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9621. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9622. */
  9623. set filter(value: number);
  9624. /**
  9625. * Gets if the current filter is set to Poisson Sampling.
  9626. */
  9627. get usePoissonSampling(): boolean;
  9628. /**
  9629. * Sets the current filter to Poisson Sampling.
  9630. */
  9631. set usePoissonSampling(value: boolean);
  9632. /**
  9633. * Gets if the current filter is set to ESM.
  9634. */
  9635. get useExponentialShadowMap(): boolean;
  9636. /**
  9637. * Sets the current filter is to ESM.
  9638. */
  9639. set useExponentialShadowMap(value: boolean);
  9640. /**
  9641. * Gets if the current filter is set to filtered ESM.
  9642. */
  9643. get useBlurExponentialShadowMap(): boolean;
  9644. /**
  9645. * Gets if the current filter is set to filtered ESM.
  9646. */
  9647. set useBlurExponentialShadowMap(value: boolean);
  9648. /**
  9649. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9650. * exponential to prevent steep falloff artifacts).
  9651. */
  9652. get useCloseExponentialShadowMap(): boolean;
  9653. /**
  9654. * Sets the current filter to "close ESM" (using the inverse of the
  9655. * exponential to prevent steep falloff artifacts).
  9656. */
  9657. set useCloseExponentialShadowMap(value: boolean);
  9658. /**
  9659. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9660. * exponential to prevent steep falloff artifacts).
  9661. */
  9662. get useBlurCloseExponentialShadowMap(): boolean;
  9663. /**
  9664. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9665. * exponential to prevent steep falloff artifacts).
  9666. */
  9667. set useBlurCloseExponentialShadowMap(value: boolean);
  9668. /**
  9669. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9670. */
  9671. get usePercentageCloserFiltering(): boolean;
  9672. /**
  9673. * Sets the current filter to "PCF" (percentage closer filtering).
  9674. */
  9675. set usePercentageCloserFiltering(value: boolean);
  9676. private _filteringQuality;
  9677. /**
  9678. * Gets the PCF or PCSS Quality.
  9679. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9680. */
  9681. get filteringQuality(): number;
  9682. /**
  9683. * Sets the PCF or PCSS Quality.
  9684. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9685. */
  9686. set filteringQuality(filteringQuality: number);
  9687. /**
  9688. * Gets if the current filter is set to "PCSS" (contact hardening).
  9689. */
  9690. get useContactHardeningShadow(): boolean;
  9691. /**
  9692. * Sets the current filter to "PCSS" (contact hardening).
  9693. */
  9694. set useContactHardeningShadow(value: boolean);
  9695. private _contactHardeningLightSizeUVRatio;
  9696. /**
  9697. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9698. * Using a ratio helps keeping shape stability independently of the map size.
  9699. *
  9700. * It does not account for the light projection as it was having too much
  9701. * instability during the light setup or during light position changes.
  9702. *
  9703. * Only valid if useContactHardeningShadow is true.
  9704. */
  9705. get contactHardeningLightSizeUVRatio(): number;
  9706. /**
  9707. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9708. * Using a ratio helps keeping shape stability independently of the map size.
  9709. *
  9710. * It does not account for the light projection as it was having too much
  9711. * instability during the light setup or during light position changes.
  9712. *
  9713. * Only valid if useContactHardeningShadow is true.
  9714. */
  9715. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  9716. private _darkness;
  9717. /** Gets or sets the actual darkness of a shadow */
  9718. get darkness(): number;
  9719. set darkness(value: number);
  9720. /**
  9721. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9722. * 0 means strongest and 1 would means no shadow.
  9723. * @returns the darkness.
  9724. */
  9725. getDarkness(): number;
  9726. /**
  9727. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9728. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9729. * @returns the shadow generator allowing fluent coding.
  9730. */
  9731. setDarkness(darkness: number): ShadowGenerator;
  9732. private _transparencyShadow;
  9733. /** Gets or sets the ability to have transparent shadow */
  9734. get transparencyShadow(): boolean;
  9735. set transparencyShadow(value: boolean);
  9736. /**
  9737. * Sets the ability to have transparent shadow (boolean).
  9738. * @param transparent True if transparent else False
  9739. * @returns the shadow generator allowing fluent coding
  9740. */
  9741. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9742. private _shadowMap;
  9743. private _shadowMap2;
  9744. /**
  9745. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9746. * @returns The render target texture if present otherwise, null
  9747. */
  9748. getShadowMap(): Nullable<RenderTargetTexture>;
  9749. /**
  9750. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9751. * @returns The render target texture if the shadow map is present otherwise, null
  9752. */
  9753. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9754. /**
  9755. * Gets the class name of that object
  9756. * @returns "ShadowGenerator"
  9757. */
  9758. getClassName(): string;
  9759. /**
  9760. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9761. * @param mesh Mesh to add
  9762. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9763. * @returns the Shadow Generator itself
  9764. */
  9765. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9766. /**
  9767. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9768. * @param mesh Mesh to remove
  9769. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9770. * @returns the Shadow Generator itself
  9771. */
  9772. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9773. /**
  9774. * Controls the extent to which the shadows fade out at the edge of the frustum
  9775. * Used only by directionals and spots
  9776. */
  9777. frustumEdgeFalloff: number;
  9778. private _light;
  9779. /**
  9780. * Returns the associated light object.
  9781. * @returns the light generating the shadow
  9782. */
  9783. getLight(): IShadowLight;
  9784. /**
  9785. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9786. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9787. * It might on the other hand introduce peter panning.
  9788. */
  9789. forceBackFacesOnly: boolean;
  9790. private _scene;
  9791. private _lightDirection;
  9792. private _effect;
  9793. private _viewMatrix;
  9794. private _projectionMatrix;
  9795. private _transformMatrix;
  9796. private _cachedPosition;
  9797. private _cachedDirection;
  9798. private _cachedDefines;
  9799. private _currentRenderID;
  9800. private _boxBlurPostprocess;
  9801. private _kernelBlurXPostprocess;
  9802. private _kernelBlurYPostprocess;
  9803. private _blurPostProcesses;
  9804. private _mapSize;
  9805. private _currentFaceIndex;
  9806. private _currentFaceIndexCache;
  9807. private _textureType;
  9808. private _defaultTextureMatrix;
  9809. private _storedUniqueId;
  9810. /** @hidden */
  9811. static _SceneComponentInitialization: (scene: Scene) => void;
  9812. /**
  9813. * Creates a ShadowGenerator object.
  9814. * A ShadowGenerator is the required tool to use the shadows.
  9815. * Each light casting shadows needs to use its own ShadowGenerator.
  9816. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9817. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9818. * @param light The light object generating the shadows.
  9819. * @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.
  9820. */
  9821. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9822. private _initializeGenerator;
  9823. private _initializeShadowMap;
  9824. private _initializeBlurRTTAndPostProcesses;
  9825. private _renderForShadowMap;
  9826. private _renderSubMeshForShadowMap;
  9827. private _applyFilterValues;
  9828. /**
  9829. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9830. * @param onCompiled Callback triggered at the and of the effects compilation
  9831. * @param options Sets of optional options forcing the compilation with different modes
  9832. */
  9833. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9834. useInstances: boolean;
  9835. }>): void;
  9836. /**
  9837. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9838. * @param options Sets of optional options forcing the compilation with different modes
  9839. * @returns A promise that resolves when the compilation completes
  9840. */
  9841. forceCompilationAsync(options?: Partial<{
  9842. useInstances: boolean;
  9843. }>): Promise<void>;
  9844. /**
  9845. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9846. * @param subMesh The submesh we want to render in the shadow map
  9847. * @param useInstances Defines wether will draw in the map using instances
  9848. * @returns true if ready otherwise, false
  9849. */
  9850. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9851. /**
  9852. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9853. * @param defines Defines of the material we want to update
  9854. * @param lightIndex Index of the light in the enabled light list of the material
  9855. */
  9856. prepareDefines(defines: any, lightIndex: number): void;
  9857. /**
  9858. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9859. * defined in the generator but impacting the effect).
  9860. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9861. * @param effect The effect we are binfing the information for
  9862. */
  9863. bindShadowLight(lightIndex: string, effect: Effect): void;
  9864. /**
  9865. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9866. * (eq to shadow prjection matrix * light transform matrix)
  9867. * @returns The transform matrix used to create the shadow map
  9868. */
  9869. getTransformMatrix(): Matrix;
  9870. /**
  9871. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9872. * Cube and 2D textures for instance.
  9873. */
  9874. recreateShadowMap(): void;
  9875. private _disposeBlurPostProcesses;
  9876. private _disposeRTTandPostProcesses;
  9877. /**
  9878. * Disposes the ShadowGenerator.
  9879. * Returns nothing.
  9880. */
  9881. dispose(): void;
  9882. /**
  9883. * Serializes the shadow generator setup to a json object.
  9884. * @returns The serialized JSON object
  9885. */
  9886. serialize(): any;
  9887. /**
  9888. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9889. * @param parsedShadowGenerator The JSON object to parse
  9890. * @param scene The scene to create the shadow map for
  9891. * @returns The parsed shadow generator
  9892. */
  9893. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9894. }
  9895. }
  9896. declare module BABYLON {
  9897. /**
  9898. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9899. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9900. * 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.
  9901. */
  9902. export abstract class Light extends Node {
  9903. /**
  9904. * Falloff Default: light is falling off following the material specification:
  9905. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9906. */
  9907. static readonly FALLOFF_DEFAULT: number;
  9908. /**
  9909. * Falloff Physical: light is falling off following the inverse squared distance law.
  9910. */
  9911. static readonly FALLOFF_PHYSICAL: number;
  9912. /**
  9913. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9914. * to enhance interoperability with other engines.
  9915. */
  9916. static readonly FALLOFF_GLTF: number;
  9917. /**
  9918. * Falloff Standard: light is falling off like in the standard material
  9919. * to enhance interoperability with other materials.
  9920. */
  9921. static readonly FALLOFF_STANDARD: number;
  9922. /**
  9923. * If every light affecting the material is in this lightmapMode,
  9924. * material.lightmapTexture adds or multiplies
  9925. * (depends on material.useLightmapAsShadowmap)
  9926. * after every other light calculations.
  9927. */
  9928. static readonly LIGHTMAP_DEFAULT: number;
  9929. /**
  9930. * material.lightmapTexture as only diffuse lighting from this light
  9931. * adds only specular lighting from this light
  9932. * adds dynamic shadows
  9933. */
  9934. static readonly LIGHTMAP_SPECULAR: number;
  9935. /**
  9936. * material.lightmapTexture as only lighting
  9937. * no light calculation from this light
  9938. * only adds dynamic shadows from this light
  9939. */
  9940. static readonly LIGHTMAP_SHADOWSONLY: number;
  9941. /**
  9942. * Each light type uses the default quantity according to its type:
  9943. * point/spot lights use luminous intensity
  9944. * directional lights use illuminance
  9945. */
  9946. static readonly INTENSITYMODE_AUTOMATIC: number;
  9947. /**
  9948. * lumen (lm)
  9949. */
  9950. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9951. /**
  9952. * candela (lm/sr)
  9953. */
  9954. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9955. /**
  9956. * lux (lm/m^2)
  9957. */
  9958. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9959. /**
  9960. * nit (cd/m^2)
  9961. */
  9962. static readonly INTENSITYMODE_LUMINANCE: number;
  9963. /**
  9964. * Light type const id of the point light.
  9965. */
  9966. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9967. /**
  9968. * Light type const id of the directional light.
  9969. */
  9970. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9971. /**
  9972. * Light type const id of the spot light.
  9973. */
  9974. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9975. /**
  9976. * Light type const id of the hemispheric light.
  9977. */
  9978. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9979. /**
  9980. * Diffuse gives the basic color to an object.
  9981. */
  9982. diffuse: Color3;
  9983. /**
  9984. * Specular produces a highlight color on an object.
  9985. * Note: This is note affecting PBR materials.
  9986. */
  9987. specular: Color3;
  9988. /**
  9989. * Defines the falloff type for this light. This lets overrriding how punctual light are
  9990. * falling off base on range or angle.
  9991. * This can be set to any values in Light.FALLOFF_x.
  9992. *
  9993. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  9994. * other types of materials.
  9995. */
  9996. falloffType: number;
  9997. /**
  9998. * Strength of the light.
  9999. * Note: By default it is define in the framework own unit.
  10000. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10001. */
  10002. intensity: number;
  10003. private _range;
  10004. protected _inverseSquaredRange: number;
  10005. /**
  10006. * Defines how far from the source the light is impacting in scene units.
  10007. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10008. */
  10009. get range(): number;
  10010. /**
  10011. * Defines how far from the source the light is impacting in scene units.
  10012. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10013. */
  10014. set range(value: number);
  10015. /**
  10016. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10017. * of light.
  10018. */
  10019. private _photometricScale;
  10020. private _intensityMode;
  10021. /**
  10022. * Gets the photometric scale used to interpret the intensity.
  10023. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10024. */
  10025. get intensityMode(): number;
  10026. /**
  10027. * Sets the photometric scale used to interpret the intensity.
  10028. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10029. */
  10030. set intensityMode(value: number);
  10031. private _radius;
  10032. /**
  10033. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10034. */
  10035. get radius(): number;
  10036. /**
  10037. * sets the light radius used by PBR Materials to simulate soft area lights.
  10038. */
  10039. set radius(value: number);
  10040. private _renderPriority;
  10041. /**
  10042. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10043. * exceeding the number allowed of the materials.
  10044. */
  10045. renderPriority: number;
  10046. private _shadowEnabled;
  10047. /**
  10048. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10049. * the current shadow generator.
  10050. */
  10051. get shadowEnabled(): boolean;
  10052. /**
  10053. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10054. * the current shadow generator.
  10055. */
  10056. set shadowEnabled(value: boolean);
  10057. private _includedOnlyMeshes;
  10058. /**
  10059. * Gets the only meshes impacted by this light.
  10060. */
  10061. get includedOnlyMeshes(): AbstractMesh[];
  10062. /**
  10063. * Sets the only meshes impacted by this light.
  10064. */
  10065. set includedOnlyMeshes(value: AbstractMesh[]);
  10066. private _excludedMeshes;
  10067. /**
  10068. * Gets the meshes not impacted by this light.
  10069. */
  10070. get excludedMeshes(): AbstractMesh[];
  10071. /**
  10072. * Sets the meshes not impacted by this light.
  10073. */
  10074. set excludedMeshes(value: AbstractMesh[]);
  10075. private _excludeWithLayerMask;
  10076. /**
  10077. * Gets the layer id use to find what meshes are not impacted by the light.
  10078. * Inactive if 0
  10079. */
  10080. get excludeWithLayerMask(): number;
  10081. /**
  10082. * Sets the layer id use to find what meshes are not impacted by the light.
  10083. * Inactive if 0
  10084. */
  10085. set excludeWithLayerMask(value: number);
  10086. private _includeOnlyWithLayerMask;
  10087. /**
  10088. * Gets the layer id use to find what meshes are impacted by the light.
  10089. * Inactive if 0
  10090. */
  10091. get includeOnlyWithLayerMask(): number;
  10092. /**
  10093. * Sets the layer id use to find what meshes are impacted by the light.
  10094. * Inactive if 0
  10095. */
  10096. set includeOnlyWithLayerMask(value: number);
  10097. private _lightmapMode;
  10098. /**
  10099. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10100. */
  10101. get lightmapMode(): number;
  10102. /**
  10103. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10104. */
  10105. set lightmapMode(value: number);
  10106. /**
  10107. * Shadow generator associted to the light.
  10108. * @hidden Internal use only.
  10109. */
  10110. _shadowGenerator: Nullable<IShadowGenerator>;
  10111. /**
  10112. * @hidden Internal use only.
  10113. */
  10114. _excludedMeshesIds: string[];
  10115. /**
  10116. * @hidden Internal use only.
  10117. */
  10118. _includedOnlyMeshesIds: string[];
  10119. /**
  10120. * The current light unifom buffer.
  10121. * @hidden Internal use only.
  10122. */
  10123. _uniformBuffer: UniformBuffer;
  10124. /** @hidden */
  10125. _renderId: number;
  10126. /**
  10127. * Creates a Light object in the scene.
  10128. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10129. * @param name The firendly name of the light
  10130. * @param scene The scene the light belongs too
  10131. */
  10132. constructor(name: string, scene: Scene);
  10133. protected abstract _buildUniformLayout(): void;
  10134. /**
  10135. * Sets the passed Effect "effect" with the Light information.
  10136. * @param effect The effect to update
  10137. * @param lightIndex The index of the light in the effect to update
  10138. * @returns The light
  10139. */
  10140. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10141. /**
  10142. * Sets the passed Effect "effect" with the Light textures.
  10143. * @param effect The effect to update
  10144. * @param lightIndex The index of the light in the effect to update
  10145. * @returns The light
  10146. */
  10147. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  10148. /**
  10149. * Binds the lights information from the scene to the effect for the given mesh.
  10150. * @param lightIndex Light index
  10151. * @param scene The scene where the light belongs to
  10152. * @param effect The effect we are binding the data to
  10153. * @param useSpecular Defines if specular is supported
  10154. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  10155. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  10156. */
  10157. bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  10158. /**
  10159. * Sets the passed Effect "effect" with the Light information.
  10160. * @param effect The effect to update
  10161. * @param lightDataUniformName The uniform used to store light data (position or direction)
  10162. * @returns The light
  10163. */
  10164. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  10165. /**
  10166. * Returns the string "Light".
  10167. * @returns the class name
  10168. */
  10169. getClassName(): string;
  10170. /** @hidden */
  10171. readonly _isLight: boolean;
  10172. /**
  10173. * Converts the light information to a readable string for debug purpose.
  10174. * @param fullDetails Supports for multiple levels of logging within scene loading
  10175. * @returns the human readable light info
  10176. */
  10177. toString(fullDetails?: boolean): string;
  10178. /** @hidden */
  10179. protected _syncParentEnabledState(): void;
  10180. /**
  10181. * Set the enabled state of this node.
  10182. * @param value - the new enabled state
  10183. */
  10184. setEnabled(value: boolean): void;
  10185. /**
  10186. * Returns the Light associated shadow generator if any.
  10187. * @return the associated shadow generator.
  10188. */
  10189. getShadowGenerator(): Nullable<IShadowGenerator>;
  10190. /**
  10191. * Returns a Vector3, the absolute light position in the World.
  10192. * @returns the world space position of the light
  10193. */
  10194. getAbsolutePosition(): Vector3;
  10195. /**
  10196. * Specifies if the light will affect the passed mesh.
  10197. * @param mesh The mesh to test against the light
  10198. * @return true the mesh is affected otherwise, false.
  10199. */
  10200. canAffectMesh(mesh: AbstractMesh): boolean;
  10201. /**
  10202. * Sort function to order lights for rendering.
  10203. * @param a First Light object to compare to second.
  10204. * @param b Second Light object to compare first.
  10205. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10206. */
  10207. static CompareLightsPriority(a: Light, b: Light): number;
  10208. /**
  10209. * Releases resources associated with this node.
  10210. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10211. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10212. */
  10213. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10214. /**
  10215. * Returns the light type ID (integer).
  10216. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10217. */
  10218. getTypeID(): number;
  10219. /**
  10220. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10221. * @returns the scaled intensity in intensity mode unit
  10222. */
  10223. getScaledIntensity(): number;
  10224. /**
  10225. * Returns a new Light object, named "name", from the current one.
  10226. * @param name The name of the cloned light
  10227. * @returns the new created light
  10228. */
  10229. clone(name: string): Nullable<Light>;
  10230. /**
  10231. * Serializes the current light into a Serialization object.
  10232. * @returns the serialized object.
  10233. */
  10234. serialize(): any;
  10235. /**
  10236. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10237. * This new light is named "name" and added to the passed scene.
  10238. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10239. * @param name The friendly name of the light
  10240. * @param scene The scene the new light will belong to
  10241. * @returns the constructor function
  10242. */
  10243. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10244. /**
  10245. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10246. * @param parsedLight The JSON representation of the light
  10247. * @param scene The scene to create the parsed light in
  10248. * @returns the created light after parsing
  10249. */
  10250. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10251. private _hookArrayForExcluded;
  10252. private _hookArrayForIncludedOnly;
  10253. private _resyncMeshes;
  10254. /**
  10255. * Forces the meshes to update their light related information in their rendering used effects
  10256. * @hidden Internal Use Only
  10257. */
  10258. _markMeshesAsLightDirty(): void;
  10259. /**
  10260. * Recomputes the cached photometric scale if needed.
  10261. */
  10262. private _computePhotometricScale;
  10263. /**
  10264. * Returns the Photometric Scale according to the light type and intensity mode.
  10265. */
  10266. private _getPhotometricScale;
  10267. /**
  10268. * Reorder the light in the scene according to their defined priority.
  10269. * @hidden Internal Use Only
  10270. */
  10271. _reorderLightsInScene(): void;
  10272. /**
  10273. * Prepares the list of defines specific to the light type.
  10274. * @param defines the list of defines
  10275. * @param lightIndex defines the index of the light for the effect
  10276. */
  10277. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10278. }
  10279. }
  10280. declare module BABYLON {
  10281. /**
  10282. * Interface used to define Action
  10283. */
  10284. export interface IAction {
  10285. /**
  10286. * Trigger for the action
  10287. */
  10288. trigger: number;
  10289. /** Options of the trigger */
  10290. triggerOptions: any;
  10291. /**
  10292. * Gets the trigger parameters
  10293. * @returns the trigger parameters
  10294. */
  10295. getTriggerParameter(): any;
  10296. /**
  10297. * Internal only - executes current action event
  10298. * @hidden
  10299. */
  10300. _executeCurrent(evt?: ActionEvent): void;
  10301. /**
  10302. * Serialize placeholder for child classes
  10303. * @param parent of child
  10304. * @returns the serialized object
  10305. */
  10306. serialize(parent: any): any;
  10307. /**
  10308. * Internal only
  10309. * @hidden
  10310. */
  10311. _prepare(): void;
  10312. /**
  10313. * Internal only - manager for action
  10314. * @hidden
  10315. */
  10316. _actionManager: AbstractActionManager;
  10317. /**
  10318. * Adds action to chain of actions, may be a DoNothingAction
  10319. * @param action defines the next action to execute
  10320. * @returns The action passed in
  10321. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10322. */
  10323. then(action: IAction): IAction;
  10324. }
  10325. /**
  10326. * The action to be carried out following a trigger
  10327. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10328. */
  10329. export class Action implements IAction {
  10330. /** the trigger, with or without parameters, for the action */
  10331. triggerOptions: any;
  10332. /**
  10333. * Trigger for the action
  10334. */
  10335. trigger: number;
  10336. /**
  10337. * Internal only - manager for action
  10338. * @hidden
  10339. */
  10340. _actionManager: ActionManager;
  10341. private _nextActiveAction;
  10342. private _child;
  10343. private _condition?;
  10344. private _triggerParameter;
  10345. /**
  10346. * An event triggered prior to action being executed.
  10347. */
  10348. onBeforeExecuteObservable: Observable<Action>;
  10349. /**
  10350. * Creates a new Action
  10351. * @param triggerOptions the trigger, with or without parameters, for the action
  10352. * @param condition an optional determinant of action
  10353. */
  10354. constructor(
  10355. /** the trigger, with or without parameters, for the action */
  10356. triggerOptions: any, condition?: Condition);
  10357. /**
  10358. * Internal only
  10359. * @hidden
  10360. */
  10361. _prepare(): void;
  10362. /**
  10363. * Gets the trigger parameters
  10364. * @returns the trigger parameters
  10365. */
  10366. getTriggerParameter(): any;
  10367. /**
  10368. * Internal only - executes current action event
  10369. * @hidden
  10370. */
  10371. _executeCurrent(evt?: ActionEvent): void;
  10372. /**
  10373. * Execute placeholder for child classes
  10374. * @param evt optional action event
  10375. */
  10376. execute(evt?: ActionEvent): void;
  10377. /**
  10378. * Skips to next active action
  10379. */
  10380. skipToNextActiveAction(): void;
  10381. /**
  10382. * Adds action to chain of actions, may be a DoNothingAction
  10383. * @param action defines the next action to execute
  10384. * @returns The action passed in
  10385. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10386. */
  10387. then(action: Action): Action;
  10388. /**
  10389. * Internal only
  10390. * @hidden
  10391. */
  10392. _getProperty(propertyPath: string): string;
  10393. /**
  10394. * Internal only
  10395. * @hidden
  10396. */
  10397. _getEffectiveTarget(target: any, propertyPath: string): any;
  10398. /**
  10399. * Serialize placeholder for child classes
  10400. * @param parent of child
  10401. * @returns the serialized object
  10402. */
  10403. serialize(parent: any): any;
  10404. /**
  10405. * Internal only called by serialize
  10406. * @hidden
  10407. */
  10408. protected _serialize(serializedAction: any, parent?: any): any;
  10409. /**
  10410. * Internal only
  10411. * @hidden
  10412. */
  10413. static _SerializeValueAsString: (value: any) => string;
  10414. /**
  10415. * Internal only
  10416. * @hidden
  10417. */
  10418. static _GetTargetProperty: (target: Node | Scene) => {
  10419. name: string;
  10420. targetType: string;
  10421. value: string;
  10422. };
  10423. }
  10424. }
  10425. declare module BABYLON {
  10426. /**
  10427. * A Condition applied to an Action
  10428. */
  10429. export class Condition {
  10430. /**
  10431. * Internal only - manager for action
  10432. * @hidden
  10433. */
  10434. _actionManager: ActionManager;
  10435. /**
  10436. * Internal only
  10437. * @hidden
  10438. */
  10439. _evaluationId: number;
  10440. /**
  10441. * Internal only
  10442. * @hidden
  10443. */
  10444. _currentResult: boolean;
  10445. /**
  10446. * Creates a new Condition
  10447. * @param actionManager the manager of the action the condition is applied to
  10448. */
  10449. constructor(actionManager: ActionManager);
  10450. /**
  10451. * Check if the current condition is valid
  10452. * @returns a boolean
  10453. */
  10454. isValid(): boolean;
  10455. /**
  10456. * Internal only
  10457. * @hidden
  10458. */
  10459. _getProperty(propertyPath: string): string;
  10460. /**
  10461. * Internal only
  10462. * @hidden
  10463. */
  10464. _getEffectiveTarget(target: any, propertyPath: string): any;
  10465. /**
  10466. * Serialize placeholder for child classes
  10467. * @returns the serialized object
  10468. */
  10469. serialize(): any;
  10470. /**
  10471. * Internal only
  10472. * @hidden
  10473. */
  10474. protected _serialize(serializedCondition: any): any;
  10475. }
  10476. /**
  10477. * Defines specific conditional operators as extensions of Condition
  10478. */
  10479. export class ValueCondition extends Condition {
  10480. /** path to specify the property of the target the conditional operator uses */
  10481. propertyPath: string;
  10482. /** the value compared by the conditional operator against the current value of the property */
  10483. value: any;
  10484. /** the conditional operator, default ValueCondition.IsEqual */
  10485. operator: number;
  10486. /**
  10487. * Internal only
  10488. * @hidden
  10489. */
  10490. private static _IsEqual;
  10491. /**
  10492. * Internal only
  10493. * @hidden
  10494. */
  10495. private static _IsDifferent;
  10496. /**
  10497. * Internal only
  10498. * @hidden
  10499. */
  10500. private static _IsGreater;
  10501. /**
  10502. * Internal only
  10503. * @hidden
  10504. */
  10505. private static _IsLesser;
  10506. /**
  10507. * returns the number for IsEqual
  10508. */
  10509. static get IsEqual(): number;
  10510. /**
  10511. * Returns the number for IsDifferent
  10512. */
  10513. static get IsDifferent(): number;
  10514. /**
  10515. * Returns the number for IsGreater
  10516. */
  10517. static get IsGreater(): number;
  10518. /**
  10519. * Returns the number for IsLesser
  10520. */
  10521. static get IsLesser(): number;
  10522. /**
  10523. * Internal only The action manager for the condition
  10524. * @hidden
  10525. */
  10526. _actionManager: ActionManager;
  10527. /**
  10528. * Internal only
  10529. * @hidden
  10530. */
  10531. private _target;
  10532. /**
  10533. * Internal only
  10534. * @hidden
  10535. */
  10536. private _effectiveTarget;
  10537. /**
  10538. * Internal only
  10539. * @hidden
  10540. */
  10541. private _property;
  10542. /**
  10543. * Creates a new ValueCondition
  10544. * @param actionManager manager for the action the condition applies to
  10545. * @param target for the action
  10546. * @param propertyPath path to specify the property of the target the conditional operator uses
  10547. * @param value the value compared by the conditional operator against the current value of the property
  10548. * @param operator the conditional operator, default ValueCondition.IsEqual
  10549. */
  10550. constructor(actionManager: ActionManager, target: any,
  10551. /** path to specify the property of the target the conditional operator uses */
  10552. propertyPath: string,
  10553. /** the value compared by the conditional operator against the current value of the property */
  10554. value: any,
  10555. /** the conditional operator, default ValueCondition.IsEqual */
  10556. operator?: number);
  10557. /**
  10558. * Compares the given value with the property value for the specified conditional operator
  10559. * @returns the result of the comparison
  10560. */
  10561. isValid(): boolean;
  10562. /**
  10563. * Serialize the ValueCondition into a JSON compatible object
  10564. * @returns serialization object
  10565. */
  10566. serialize(): any;
  10567. /**
  10568. * Gets the name of the conditional operator for the ValueCondition
  10569. * @param operator the conditional operator
  10570. * @returns the name
  10571. */
  10572. static GetOperatorName(operator: number): string;
  10573. }
  10574. /**
  10575. * Defines a predicate condition as an extension of Condition
  10576. */
  10577. export class PredicateCondition extends Condition {
  10578. /** defines the predicate function used to validate the condition */
  10579. predicate: () => boolean;
  10580. /**
  10581. * Internal only - manager for action
  10582. * @hidden
  10583. */
  10584. _actionManager: ActionManager;
  10585. /**
  10586. * Creates a new PredicateCondition
  10587. * @param actionManager manager for the action the condition applies to
  10588. * @param predicate defines the predicate function used to validate the condition
  10589. */
  10590. constructor(actionManager: ActionManager,
  10591. /** defines the predicate function used to validate the condition */
  10592. predicate: () => boolean);
  10593. /**
  10594. * @returns the validity of the predicate condition
  10595. */
  10596. isValid(): boolean;
  10597. }
  10598. /**
  10599. * Defines a state condition as an extension of Condition
  10600. */
  10601. export class StateCondition extends Condition {
  10602. /** Value to compare with target state */
  10603. value: string;
  10604. /**
  10605. * Internal only - manager for action
  10606. * @hidden
  10607. */
  10608. _actionManager: ActionManager;
  10609. /**
  10610. * Internal only
  10611. * @hidden
  10612. */
  10613. private _target;
  10614. /**
  10615. * Creates a new StateCondition
  10616. * @param actionManager manager for the action the condition applies to
  10617. * @param target of the condition
  10618. * @param value to compare with target state
  10619. */
  10620. constructor(actionManager: ActionManager, target: any,
  10621. /** Value to compare with target state */
  10622. value: string);
  10623. /**
  10624. * Gets a boolean indicating if the current condition is met
  10625. * @returns the validity of the state
  10626. */
  10627. isValid(): boolean;
  10628. /**
  10629. * Serialize the StateCondition into a JSON compatible object
  10630. * @returns serialization object
  10631. */
  10632. serialize(): any;
  10633. }
  10634. }
  10635. declare module BABYLON {
  10636. /**
  10637. * This defines an action responsible to toggle a boolean once triggered.
  10638. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10639. */
  10640. export class SwitchBooleanAction extends Action {
  10641. /**
  10642. * The path to the boolean property in the target object
  10643. */
  10644. propertyPath: string;
  10645. private _target;
  10646. private _effectiveTarget;
  10647. private _property;
  10648. /**
  10649. * Instantiate the action
  10650. * @param triggerOptions defines the trigger options
  10651. * @param target defines the object containing the boolean
  10652. * @param propertyPath defines the path to the boolean property in the target object
  10653. * @param condition defines the trigger related conditions
  10654. */
  10655. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10656. /** @hidden */
  10657. _prepare(): void;
  10658. /**
  10659. * Execute the action toggle the boolean value.
  10660. */
  10661. execute(): void;
  10662. /**
  10663. * Serializes the actions and its related information.
  10664. * @param parent defines the object to serialize in
  10665. * @returns the serialized object
  10666. */
  10667. serialize(parent: any): any;
  10668. }
  10669. /**
  10670. * This defines an action responsible to set a the state field of the target
  10671. * to a desired value once triggered.
  10672. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10673. */
  10674. export class SetStateAction extends Action {
  10675. /**
  10676. * The value to store in the state field.
  10677. */
  10678. value: string;
  10679. private _target;
  10680. /**
  10681. * Instantiate the action
  10682. * @param triggerOptions defines the trigger options
  10683. * @param target defines the object containing the state property
  10684. * @param value defines the value to store in the state field
  10685. * @param condition defines the trigger related conditions
  10686. */
  10687. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10688. /**
  10689. * Execute the action and store the value on the target state property.
  10690. */
  10691. execute(): void;
  10692. /**
  10693. * Serializes the actions and its related information.
  10694. * @param parent defines the object to serialize in
  10695. * @returns the serialized object
  10696. */
  10697. serialize(parent: any): any;
  10698. }
  10699. /**
  10700. * This defines an action responsible to set a property of the target
  10701. * to a desired value once triggered.
  10702. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10703. */
  10704. export class SetValueAction extends Action {
  10705. /**
  10706. * The path of the property to set in the target.
  10707. */
  10708. propertyPath: string;
  10709. /**
  10710. * The value to set in the property
  10711. */
  10712. value: any;
  10713. private _target;
  10714. private _effectiveTarget;
  10715. private _property;
  10716. /**
  10717. * Instantiate the action
  10718. * @param triggerOptions defines the trigger options
  10719. * @param target defines the object containing the property
  10720. * @param propertyPath defines the path of the property to set in the target
  10721. * @param value defines the value to set in the property
  10722. * @param condition defines the trigger related conditions
  10723. */
  10724. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10725. /** @hidden */
  10726. _prepare(): void;
  10727. /**
  10728. * Execute the action and set the targetted property to the desired value.
  10729. */
  10730. execute(): void;
  10731. /**
  10732. * Serializes the actions and its related information.
  10733. * @param parent defines the object to serialize in
  10734. * @returns the serialized object
  10735. */
  10736. serialize(parent: any): any;
  10737. }
  10738. /**
  10739. * This defines an action responsible to increment the target value
  10740. * to a desired value once triggered.
  10741. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10742. */
  10743. export class IncrementValueAction extends Action {
  10744. /**
  10745. * The path of the property to increment in the target.
  10746. */
  10747. propertyPath: string;
  10748. /**
  10749. * The value we should increment the property by.
  10750. */
  10751. value: any;
  10752. private _target;
  10753. private _effectiveTarget;
  10754. private _property;
  10755. /**
  10756. * Instantiate the action
  10757. * @param triggerOptions defines the trigger options
  10758. * @param target defines the object containing the property
  10759. * @param propertyPath defines the path of the property to increment in the target
  10760. * @param value defines the value value we should increment the property by
  10761. * @param condition defines the trigger related conditions
  10762. */
  10763. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10764. /** @hidden */
  10765. _prepare(): void;
  10766. /**
  10767. * Execute the action and increment the target of the value amount.
  10768. */
  10769. execute(): void;
  10770. /**
  10771. * Serializes the actions and its related information.
  10772. * @param parent defines the object to serialize in
  10773. * @returns the serialized object
  10774. */
  10775. serialize(parent: any): any;
  10776. }
  10777. /**
  10778. * This defines an action responsible to start an animation once triggered.
  10779. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10780. */
  10781. export class PlayAnimationAction extends Action {
  10782. /**
  10783. * Where the animation should start (animation frame)
  10784. */
  10785. from: number;
  10786. /**
  10787. * Where the animation should stop (animation frame)
  10788. */
  10789. to: number;
  10790. /**
  10791. * Define if the animation should loop or stop after the first play.
  10792. */
  10793. loop?: boolean;
  10794. private _target;
  10795. /**
  10796. * Instantiate the action
  10797. * @param triggerOptions defines the trigger options
  10798. * @param target defines the target animation or animation name
  10799. * @param from defines from where the animation should start (animation frame)
  10800. * @param end defines where the animation should stop (animation frame)
  10801. * @param loop defines if the animation should loop or stop after the first play
  10802. * @param condition defines the trigger related conditions
  10803. */
  10804. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10805. /** @hidden */
  10806. _prepare(): void;
  10807. /**
  10808. * Execute the action and play the animation.
  10809. */
  10810. execute(): void;
  10811. /**
  10812. * Serializes the actions and its related information.
  10813. * @param parent defines the object to serialize in
  10814. * @returns the serialized object
  10815. */
  10816. serialize(parent: any): any;
  10817. }
  10818. /**
  10819. * This defines an action responsible to stop an animation once triggered.
  10820. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10821. */
  10822. export class StopAnimationAction extends Action {
  10823. private _target;
  10824. /**
  10825. * Instantiate the action
  10826. * @param triggerOptions defines the trigger options
  10827. * @param target defines the target animation or animation name
  10828. * @param condition defines the trigger related conditions
  10829. */
  10830. constructor(triggerOptions: any, target: any, condition?: Condition);
  10831. /** @hidden */
  10832. _prepare(): void;
  10833. /**
  10834. * Execute the action and stop the animation.
  10835. */
  10836. execute(): void;
  10837. /**
  10838. * Serializes the actions and its related information.
  10839. * @param parent defines the object to serialize in
  10840. * @returns the serialized object
  10841. */
  10842. serialize(parent: any): any;
  10843. }
  10844. /**
  10845. * This defines an action responsible that does nothing once triggered.
  10846. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10847. */
  10848. export class DoNothingAction extends Action {
  10849. /**
  10850. * Instantiate the action
  10851. * @param triggerOptions defines the trigger options
  10852. * @param condition defines the trigger related conditions
  10853. */
  10854. constructor(triggerOptions?: any, condition?: Condition);
  10855. /**
  10856. * Execute the action and do nothing.
  10857. */
  10858. execute(): void;
  10859. /**
  10860. * Serializes the actions and its related information.
  10861. * @param parent defines the object to serialize in
  10862. * @returns the serialized object
  10863. */
  10864. serialize(parent: any): any;
  10865. }
  10866. /**
  10867. * This defines an action responsible to trigger several actions once triggered.
  10868. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10869. */
  10870. export class CombineAction extends Action {
  10871. /**
  10872. * The list of aggregated animations to run.
  10873. */
  10874. children: Action[];
  10875. /**
  10876. * Instantiate the action
  10877. * @param triggerOptions defines the trigger options
  10878. * @param children defines the list of aggregated animations to run
  10879. * @param condition defines the trigger related conditions
  10880. */
  10881. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10882. /** @hidden */
  10883. _prepare(): void;
  10884. /**
  10885. * Execute the action and executes all the aggregated actions.
  10886. */
  10887. execute(evt: ActionEvent): void;
  10888. /**
  10889. * Serializes the actions and its related information.
  10890. * @param parent defines the object to serialize in
  10891. * @returns the serialized object
  10892. */
  10893. serialize(parent: any): any;
  10894. }
  10895. /**
  10896. * This defines an action responsible to run code (external event) once triggered.
  10897. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10898. */
  10899. export class ExecuteCodeAction extends Action {
  10900. /**
  10901. * The callback function to run.
  10902. */
  10903. func: (evt: ActionEvent) => void;
  10904. /**
  10905. * Instantiate the action
  10906. * @param triggerOptions defines the trigger options
  10907. * @param func defines the callback function to run
  10908. * @param condition defines the trigger related conditions
  10909. */
  10910. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10911. /**
  10912. * Execute the action and run the attached code.
  10913. */
  10914. execute(evt: ActionEvent): void;
  10915. }
  10916. /**
  10917. * This defines an action responsible to set the parent property of the target once triggered.
  10918. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10919. */
  10920. export class SetParentAction extends Action {
  10921. private _parent;
  10922. private _target;
  10923. /**
  10924. * Instantiate the action
  10925. * @param triggerOptions defines the trigger options
  10926. * @param target defines the target containing the parent property
  10927. * @param parent defines from where the animation should start (animation frame)
  10928. * @param condition defines the trigger related conditions
  10929. */
  10930. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10931. /** @hidden */
  10932. _prepare(): void;
  10933. /**
  10934. * Execute the action and set the parent property.
  10935. */
  10936. execute(): void;
  10937. /**
  10938. * Serializes the actions and its related information.
  10939. * @param parent defines the object to serialize in
  10940. * @returns the serialized object
  10941. */
  10942. serialize(parent: any): any;
  10943. }
  10944. }
  10945. declare module BABYLON {
  10946. /**
  10947. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10948. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10949. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10950. */
  10951. export class ActionManager extends AbstractActionManager {
  10952. /**
  10953. * Nothing
  10954. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10955. */
  10956. static readonly NothingTrigger: number;
  10957. /**
  10958. * On pick
  10959. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10960. */
  10961. static readonly OnPickTrigger: number;
  10962. /**
  10963. * On left pick
  10964. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10965. */
  10966. static readonly OnLeftPickTrigger: number;
  10967. /**
  10968. * On right pick
  10969. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10970. */
  10971. static readonly OnRightPickTrigger: number;
  10972. /**
  10973. * On center pick
  10974. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10975. */
  10976. static readonly OnCenterPickTrigger: number;
  10977. /**
  10978. * On pick down
  10979. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10980. */
  10981. static readonly OnPickDownTrigger: number;
  10982. /**
  10983. * On double pick
  10984. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10985. */
  10986. static readonly OnDoublePickTrigger: number;
  10987. /**
  10988. * On pick up
  10989. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10990. */
  10991. static readonly OnPickUpTrigger: number;
  10992. /**
  10993. * On pick out.
  10994. * This trigger will only be raised if you also declared a OnPickDown
  10995. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10996. */
  10997. static readonly OnPickOutTrigger: number;
  10998. /**
  10999. * On long press
  11000. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11001. */
  11002. static readonly OnLongPressTrigger: number;
  11003. /**
  11004. * On pointer over
  11005. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11006. */
  11007. static readonly OnPointerOverTrigger: number;
  11008. /**
  11009. * On pointer out
  11010. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11011. */
  11012. static readonly OnPointerOutTrigger: number;
  11013. /**
  11014. * On every frame
  11015. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11016. */
  11017. static readonly OnEveryFrameTrigger: number;
  11018. /**
  11019. * On intersection enter
  11020. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11021. */
  11022. static readonly OnIntersectionEnterTrigger: number;
  11023. /**
  11024. * On intersection exit
  11025. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11026. */
  11027. static readonly OnIntersectionExitTrigger: number;
  11028. /**
  11029. * On key down
  11030. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11031. */
  11032. static readonly OnKeyDownTrigger: number;
  11033. /**
  11034. * On key up
  11035. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11036. */
  11037. static readonly OnKeyUpTrigger: number;
  11038. private _scene;
  11039. /**
  11040. * Creates a new action manager
  11041. * @param scene defines the hosting scene
  11042. */
  11043. constructor(scene: Scene);
  11044. /**
  11045. * Releases all associated resources
  11046. */
  11047. dispose(): void;
  11048. /**
  11049. * Gets hosting scene
  11050. * @returns the hosting scene
  11051. */
  11052. getScene(): Scene;
  11053. /**
  11054. * Does this action manager handles actions of any of the given triggers
  11055. * @param triggers defines the triggers to be tested
  11056. * @return a boolean indicating whether one (or more) of the triggers is handled
  11057. */
  11058. hasSpecificTriggers(triggers: number[]): boolean;
  11059. /**
  11060. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11061. * speed.
  11062. * @param triggerA defines the trigger to be tested
  11063. * @param triggerB defines the trigger to be tested
  11064. * @return a boolean indicating whether one (or more) of the triggers is handled
  11065. */
  11066. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11067. /**
  11068. * Does this action manager handles actions of a given trigger
  11069. * @param trigger defines the trigger to be tested
  11070. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11071. * @return whether the trigger is handled
  11072. */
  11073. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11074. /**
  11075. * Does this action manager has pointer triggers
  11076. */
  11077. get hasPointerTriggers(): boolean;
  11078. /**
  11079. * Does this action manager has pick triggers
  11080. */
  11081. get hasPickTriggers(): boolean;
  11082. /**
  11083. * Registers an action to this action manager
  11084. * @param action defines the action to be registered
  11085. * @return the action amended (prepared) after registration
  11086. */
  11087. registerAction(action: IAction): Nullable<IAction>;
  11088. /**
  11089. * Unregisters an action to this action manager
  11090. * @param action defines the action to be unregistered
  11091. * @return a boolean indicating whether the action has been unregistered
  11092. */
  11093. unregisterAction(action: IAction): Boolean;
  11094. /**
  11095. * Process a specific trigger
  11096. * @param trigger defines the trigger to process
  11097. * @param evt defines the event details to be processed
  11098. */
  11099. processTrigger(trigger: number, evt?: IActionEvent): void;
  11100. /** @hidden */
  11101. _getEffectiveTarget(target: any, propertyPath: string): any;
  11102. /** @hidden */
  11103. _getProperty(propertyPath: string): string;
  11104. /**
  11105. * Serialize this manager to a JSON object
  11106. * @param name defines the property name to store this manager
  11107. * @returns a JSON representation of this manager
  11108. */
  11109. serialize(name: string): any;
  11110. /**
  11111. * Creates a new ActionManager from a JSON data
  11112. * @param parsedActions defines the JSON data to read from
  11113. * @param object defines the hosting mesh
  11114. * @param scene defines the hosting scene
  11115. */
  11116. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11117. /**
  11118. * Get a trigger name by index
  11119. * @param trigger defines the trigger index
  11120. * @returns a trigger name
  11121. */
  11122. static GetTriggerName(trigger: number): string;
  11123. }
  11124. }
  11125. declare module BABYLON {
  11126. /**
  11127. * Class representing a ray with position and direction
  11128. */
  11129. export class Ray {
  11130. /** origin point */
  11131. origin: Vector3;
  11132. /** direction */
  11133. direction: Vector3;
  11134. /** length of the ray */
  11135. length: number;
  11136. private static readonly TmpVector3;
  11137. private _tmpRay;
  11138. /**
  11139. * Creates a new ray
  11140. * @param origin origin point
  11141. * @param direction direction
  11142. * @param length length of the ray
  11143. */
  11144. constructor(
  11145. /** origin point */
  11146. origin: Vector3,
  11147. /** direction */
  11148. direction: Vector3,
  11149. /** length of the ray */
  11150. length?: number);
  11151. /**
  11152. * Checks if the ray intersects a box
  11153. * @param minimum bound of the box
  11154. * @param maximum bound of the box
  11155. * @param intersectionTreshold extra extend to be added to the box in all direction
  11156. * @returns if the box was hit
  11157. */
  11158. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11159. /**
  11160. * Checks if the ray intersects a box
  11161. * @param box the bounding box to check
  11162. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11163. * @returns if the box was hit
  11164. */
  11165. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11166. /**
  11167. * If the ray hits a sphere
  11168. * @param sphere the bounding sphere to check
  11169. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11170. * @returns true if it hits the sphere
  11171. */
  11172. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11173. /**
  11174. * If the ray hits a triange
  11175. * @param vertex0 triangle vertex
  11176. * @param vertex1 triangle vertex
  11177. * @param vertex2 triangle vertex
  11178. * @returns intersection information if hit
  11179. */
  11180. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11181. /**
  11182. * Checks if ray intersects a plane
  11183. * @param plane the plane to check
  11184. * @returns the distance away it was hit
  11185. */
  11186. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11187. /**
  11188. * Calculate the intercept of a ray on a given axis
  11189. * @param axis to check 'x' | 'y' | 'z'
  11190. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  11191. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  11192. */
  11193. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  11194. /**
  11195. * Checks if ray intersects a mesh
  11196. * @param mesh the mesh to check
  11197. * @param fastCheck if only the bounding box should checked
  11198. * @returns picking info of the intersecton
  11199. */
  11200. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11201. /**
  11202. * Checks if ray intersects a mesh
  11203. * @param meshes the meshes to check
  11204. * @param fastCheck if only the bounding box should checked
  11205. * @param results array to store result in
  11206. * @returns Array of picking infos
  11207. */
  11208. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11209. private _comparePickingInfo;
  11210. private static smallnum;
  11211. private static rayl;
  11212. /**
  11213. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11214. * @param sega the first point of the segment to test the intersection against
  11215. * @param segb the second point of the segment to test the intersection against
  11216. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11217. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11218. */
  11219. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11220. /**
  11221. * Update the ray from viewport position
  11222. * @param x position
  11223. * @param y y position
  11224. * @param viewportWidth viewport width
  11225. * @param viewportHeight viewport height
  11226. * @param world world matrix
  11227. * @param view view matrix
  11228. * @param projection projection matrix
  11229. * @returns this ray updated
  11230. */
  11231. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11232. /**
  11233. * Creates a ray with origin and direction of 0,0,0
  11234. * @returns the new ray
  11235. */
  11236. static Zero(): Ray;
  11237. /**
  11238. * Creates a new ray from screen space and viewport
  11239. * @param x position
  11240. * @param y y position
  11241. * @param viewportWidth viewport width
  11242. * @param viewportHeight viewport height
  11243. * @param world world matrix
  11244. * @param view view matrix
  11245. * @param projection projection matrix
  11246. * @returns new ray
  11247. */
  11248. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11249. /**
  11250. * 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
  11251. * transformed to the given world matrix.
  11252. * @param origin The origin point
  11253. * @param end The end point
  11254. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11255. * @returns the new ray
  11256. */
  11257. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11258. /**
  11259. * Transforms a ray by a matrix
  11260. * @param ray ray to transform
  11261. * @param matrix matrix to apply
  11262. * @returns the resulting new ray
  11263. */
  11264. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11265. /**
  11266. * Transforms a ray by a matrix
  11267. * @param ray ray to transform
  11268. * @param matrix matrix to apply
  11269. * @param result ray to store result in
  11270. */
  11271. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11272. /**
  11273. * Unproject a ray from screen space to object space
  11274. * @param sourceX defines the screen space x coordinate to use
  11275. * @param sourceY defines the screen space y coordinate to use
  11276. * @param viewportWidth defines the current width of the viewport
  11277. * @param viewportHeight defines the current height of the viewport
  11278. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11279. * @param view defines the view matrix to use
  11280. * @param projection defines the projection matrix to use
  11281. */
  11282. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11283. }
  11284. /**
  11285. * Type used to define predicate used to select faces when a mesh intersection is detected
  11286. */
  11287. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11288. interface Scene {
  11289. /** @hidden */
  11290. _tempPickingRay: Nullable<Ray>;
  11291. /** @hidden */
  11292. _cachedRayForTransform: Ray;
  11293. /** @hidden */
  11294. _pickWithRayInverseMatrix: Matrix;
  11295. /** @hidden */
  11296. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11297. /** @hidden */
  11298. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11299. }
  11300. }
  11301. declare module BABYLON {
  11302. /**
  11303. * Groups all the scene component constants in one place to ease maintenance.
  11304. * @hidden
  11305. */
  11306. export class SceneComponentConstants {
  11307. static readonly NAME_EFFECTLAYER: string;
  11308. static readonly NAME_LAYER: string;
  11309. static readonly NAME_LENSFLARESYSTEM: string;
  11310. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11311. static readonly NAME_PARTICLESYSTEM: string;
  11312. static readonly NAME_GAMEPAD: string;
  11313. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11314. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11315. static readonly NAME_DEPTHRENDERER: string;
  11316. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11317. static readonly NAME_SPRITE: string;
  11318. static readonly NAME_OUTLINERENDERER: string;
  11319. static readonly NAME_PROCEDURALTEXTURE: string;
  11320. static readonly NAME_SHADOWGENERATOR: string;
  11321. static readonly NAME_OCTREE: string;
  11322. static readonly NAME_PHYSICSENGINE: string;
  11323. static readonly NAME_AUDIO: string;
  11324. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11325. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11326. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11327. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11328. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11329. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11330. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11331. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11332. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11333. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11334. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11335. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11336. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11337. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11338. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11339. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11340. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11341. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11342. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11343. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11344. static readonly STEP_AFTERRENDER_AUDIO: number;
  11345. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11346. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11347. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11348. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11349. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11350. static readonly STEP_POINTERMOVE_SPRITE: number;
  11351. static readonly STEP_POINTERDOWN_SPRITE: number;
  11352. static readonly STEP_POINTERUP_SPRITE: number;
  11353. }
  11354. /**
  11355. * This represents a scene component.
  11356. *
  11357. * This is used to decouple the dependency the scene is having on the different workloads like
  11358. * layers, post processes...
  11359. */
  11360. export interface ISceneComponent {
  11361. /**
  11362. * The name of the component. Each component must have a unique name.
  11363. */
  11364. name: string;
  11365. /**
  11366. * The scene the component belongs to.
  11367. */
  11368. scene: Scene;
  11369. /**
  11370. * Register the component to one instance of a scene.
  11371. */
  11372. register(): void;
  11373. /**
  11374. * Rebuilds the elements related to this component in case of
  11375. * context lost for instance.
  11376. */
  11377. rebuild(): void;
  11378. /**
  11379. * Disposes the component and the associated ressources.
  11380. */
  11381. dispose(): void;
  11382. }
  11383. /**
  11384. * This represents a SERIALIZABLE scene component.
  11385. *
  11386. * This extends Scene Component to add Serialization methods on top.
  11387. */
  11388. export interface ISceneSerializableComponent extends ISceneComponent {
  11389. /**
  11390. * Adds all the elements from the container to the scene
  11391. * @param container the container holding the elements
  11392. */
  11393. addFromContainer(container: AbstractScene): void;
  11394. /**
  11395. * Removes all the elements in the container from the scene
  11396. * @param container contains the elements to remove
  11397. * @param dispose if the removed element should be disposed (default: false)
  11398. */
  11399. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11400. /**
  11401. * Serializes the component data to the specified json object
  11402. * @param serializationObject The object to serialize to
  11403. */
  11404. serialize(serializationObject: any): void;
  11405. }
  11406. /**
  11407. * Strong typing of a Mesh related stage step action
  11408. */
  11409. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11410. /**
  11411. * Strong typing of a Evaluate Sub Mesh related stage step action
  11412. */
  11413. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11414. /**
  11415. * Strong typing of a Active Mesh related stage step action
  11416. */
  11417. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11418. /**
  11419. * Strong typing of a Camera related stage step action
  11420. */
  11421. export type CameraStageAction = (camera: Camera) => void;
  11422. /**
  11423. * Strong typing of a Camera Frame buffer related stage step action
  11424. */
  11425. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11426. /**
  11427. * Strong typing of a Render Target related stage step action
  11428. */
  11429. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11430. /**
  11431. * Strong typing of a RenderingGroup related stage step action
  11432. */
  11433. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11434. /**
  11435. * Strong typing of a Mesh Render related stage step action
  11436. */
  11437. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11438. /**
  11439. * Strong typing of a simple stage step action
  11440. */
  11441. export type SimpleStageAction = () => void;
  11442. /**
  11443. * Strong typing of a render target action.
  11444. */
  11445. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11446. /**
  11447. * Strong typing of a pointer move action.
  11448. */
  11449. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  11450. /**
  11451. * Strong typing of a pointer up/down action.
  11452. */
  11453. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11454. /**
  11455. * Representation of a stage in the scene (Basically a list of ordered steps)
  11456. * @hidden
  11457. */
  11458. export class Stage<T extends Function> extends Array<{
  11459. index: number;
  11460. component: ISceneComponent;
  11461. action: T;
  11462. }> {
  11463. /**
  11464. * Hide ctor from the rest of the world.
  11465. * @param items The items to add.
  11466. */
  11467. private constructor();
  11468. /**
  11469. * Creates a new Stage.
  11470. * @returns A new instance of a Stage
  11471. */
  11472. static Create<T extends Function>(): Stage<T>;
  11473. /**
  11474. * Registers a step in an ordered way in the targeted stage.
  11475. * @param index Defines the position to register the step in
  11476. * @param component Defines the component attached to the step
  11477. * @param action Defines the action to launch during the step
  11478. */
  11479. registerStep(index: number, component: ISceneComponent, action: T): void;
  11480. /**
  11481. * Clears all the steps from the stage.
  11482. */
  11483. clear(): void;
  11484. }
  11485. }
  11486. declare module BABYLON {
  11487. interface Scene {
  11488. /** @hidden */
  11489. _pointerOverSprite: Nullable<Sprite>;
  11490. /** @hidden */
  11491. _pickedDownSprite: Nullable<Sprite>;
  11492. /** @hidden */
  11493. _tempSpritePickingRay: Nullable<Ray>;
  11494. /**
  11495. * All of the sprite managers added to this scene
  11496. * @see http://doc.babylonjs.com/babylon101/sprites
  11497. */
  11498. spriteManagers: Array<ISpriteManager>;
  11499. /**
  11500. * An event triggered when sprites rendering is about to start
  11501. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11502. */
  11503. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11504. /**
  11505. * An event triggered when sprites rendering is done
  11506. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11507. */
  11508. onAfterSpritesRenderingObservable: Observable<Scene>;
  11509. /** @hidden */
  11510. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11511. /** Launch a ray to try to pick a sprite in the scene
  11512. * @param x position on screen
  11513. * @param y position on screen
  11514. * @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
  11515. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11516. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11517. * @returns a PickingInfo
  11518. */
  11519. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11520. /** Use the given ray to pick a sprite in the scene
  11521. * @param ray The ray (in world space) to use to pick meshes
  11522. * @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
  11523. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11524. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11525. * @returns a PickingInfo
  11526. */
  11527. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11528. /** @hidden */
  11529. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11530. /** Launch a ray to try to pick sprites in the scene
  11531. * @param x position on screen
  11532. * @param y position on screen
  11533. * @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
  11534. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11535. * @returns a PickingInfo array
  11536. */
  11537. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11538. /** Use the given ray to pick sprites in the scene
  11539. * @param ray The ray (in world space) to use to pick meshes
  11540. * @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
  11541. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11542. * @returns a PickingInfo array
  11543. */
  11544. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11545. /**
  11546. * Force the sprite under the pointer
  11547. * @param sprite defines the sprite to use
  11548. */
  11549. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11550. /**
  11551. * Gets the sprite under the pointer
  11552. * @returns a Sprite or null if no sprite is under the pointer
  11553. */
  11554. getPointerOverSprite(): Nullable<Sprite>;
  11555. }
  11556. /**
  11557. * Defines the sprite scene component responsible to manage sprites
  11558. * in a given scene.
  11559. */
  11560. export class SpriteSceneComponent implements ISceneComponent {
  11561. /**
  11562. * The component name helpfull to identify the component in the list of scene components.
  11563. */
  11564. readonly name: string;
  11565. /**
  11566. * The scene the component belongs to.
  11567. */
  11568. scene: Scene;
  11569. /** @hidden */
  11570. private _spritePredicate;
  11571. /**
  11572. * Creates a new instance of the component for the given scene
  11573. * @param scene Defines the scene to register the component in
  11574. */
  11575. constructor(scene: Scene);
  11576. /**
  11577. * Registers the component in a given scene
  11578. */
  11579. register(): void;
  11580. /**
  11581. * Rebuilds the elements related to this component in case of
  11582. * context lost for instance.
  11583. */
  11584. rebuild(): void;
  11585. /**
  11586. * Disposes the component and the associated ressources.
  11587. */
  11588. dispose(): void;
  11589. private _pickSpriteButKeepRay;
  11590. private _pointerMove;
  11591. private _pointerDown;
  11592. private _pointerUp;
  11593. }
  11594. }
  11595. declare module BABYLON {
  11596. /** @hidden */
  11597. export var fogFragmentDeclaration: {
  11598. name: string;
  11599. shader: string;
  11600. };
  11601. }
  11602. declare module BABYLON {
  11603. /** @hidden */
  11604. export var fogFragment: {
  11605. name: string;
  11606. shader: string;
  11607. };
  11608. }
  11609. declare module BABYLON {
  11610. /** @hidden */
  11611. export var spritesPixelShader: {
  11612. name: string;
  11613. shader: string;
  11614. };
  11615. }
  11616. declare module BABYLON {
  11617. /** @hidden */
  11618. export var fogVertexDeclaration: {
  11619. name: string;
  11620. shader: string;
  11621. };
  11622. }
  11623. declare module BABYLON {
  11624. /** @hidden */
  11625. export var spritesVertexShader: {
  11626. name: string;
  11627. shader: string;
  11628. };
  11629. }
  11630. declare module BABYLON {
  11631. /**
  11632. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11633. */
  11634. export interface ISpriteManager extends IDisposable {
  11635. /**
  11636. * Restricts the camera to viewing objects with the same layerMask.
  11637. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11638. */
  11639. layerMask: number;
  11640. /**
  11641. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11642. */
  11643. isPickable: boolean;
  11644. /**
  11645. * Specifies the rendering group id for this mesh (0 by default)
  11646. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11647. */
  11648. renderingGroupId: number;
  11649. /**
  11650. * Defines the list of sprites managed by the manager.
  11651. */
  11652. sprites: Array<Sprite>;
  11653. /**
  11654. * Tests the intersection of a sprite with a specific ray.
  11655. * @param ray The ray we are sending to test the collision
  11656. * @param camera The camera space we are sending rays in
  11657. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11658. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11659. * @returns picking info or null.
  11660. */
  11661. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11662. /**
  11663. * Intersects the sprites with a ray
  11664. * @param ray defines the ray to intersect with
  11665. * @param camera defines the current active camera
  11666. * @param predicate defines a predicate used to select candidate sprites
  11667. * @returns null if no hit or a PickingInfo array
  11668. */
  11669. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11670. /**
  11671. * Renders the list of sprites on screen.
  11672. */
  11673. render(): void;
  11674. }
  11675. /**
  11676. * Class used to manage multiple sprites on the same spritesheet
  11677. * @see http://doc.babylonjs.com/babylon101/sprites
  11678. */
  11679. export class SpriteManager implements ISpriteManager {
  11680. /** defines the manager's name */
  11681. name: string;
  11682. /** Gets the list of sprites */
  11683. sprites: Sprite[];
  11684. /** Gets or sets the rendering group id (0 by default) */
  11685. renderingGroupId: number;
  11686. /** Gets or sets camera layer mask */
  11687. layerMask: number;
  11688. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11689. fogEnabled: boolean;
  11690. /** Gets or sets a boolean indicating if the sprites are pickable */
  11691. isPickable: boolean;
  11692. /** Defines the default width of a cell in the spritesheet */
  11693. cellWidth: number;
  11694. /** Defines the default height of a cell in the spritesheet */
  11695. cellHeight: number;
  11696. /** Associative array from JSON sprite data file */
  11697. private _cellData;
  11698. /** Array of sprite names from JSON sprite data file */
  11699. private _spriteMap;
  11700. /** True when packed cell data from JSON file is ready*/
  11701. private _packedAndReady;
  11702. /**
  11703. * An event triggered when the manager is disposed.
  11704. */
  11705. onDisposeObservable: Observable<SpriteManager>;
  11706. private _onDisposeObserver;
  11707. /**
  11708. * Callback called when the manager is disposed
  11709. */
  11710. set onDispose(callback: () => void);
  11711. private _capacity;
  11712. private _fromPacked;
  11713. private _spriteTexture;
  11714. private _epsilon;
  11715. private _scene;
  11716. private _vertexData;
  11717. private _buffer;
  11718. private _vertexBuffers;
  11719. private _indexBuffer;
  11720. private _effectBase;
  11721. private _effectFog;
  11722. /**
  11723. * Gets or sets the spritesheet texture
  11724. */
  11725. get texture(): Texture;
  11726. set texture(value: Texture);
  11727. /**
  11728. * Creates a new sprite manager
  11729. * @param name defines the manager's name
  11730. * @param imgUrl defines the sprite sheet url
  11731. * @param capacity defines the maximum allowed number of sprites
  11732. * @param cellSize defines the size of a sprite cell
  11733. * @param scene defines the hosting scene
  11734. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11735. * @param samplingMode defines the smapling mode to use with spritesheet
  11736. * @param fromPacked set to false; do not alter
  11737. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11738. */
  11739. constructor(
  11740. /** defines the manager's name */
  11741. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11742. private _makePacked;
  11743. private _appendSpriteVertex;
  11744. /**
  11745. * Intersects the sprites with a ray
  11746. * @param ray defines the ray to intersect with
  11747. * @param camera defines the current active camera
  11748. * @param predicate defines a predicate used to select candidate sprites
  11749. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11750. * @returns null if no hit or a PickingInfo
  11751. */
  11752. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11753. /**
  11754. * Intersects the sprites with a ray
  11755. * @param ray defines the ray to intersect with
  11756. * @param camera defines the current active camera
  11757. * @param predicate defines a predicate used to select candidate sprites
  11758. * @returns null if no hit or a PickingInfo array
  11759. */
  11760. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11761. /**
  11762. * Render all child sprites
  11763. */
  11764. render(): void;
  11765. /**
  11766. * Release associated resources
  11767. */
  11768. dispose(): void;
  11769. }
  11770. }
  11771. declare module BABYLON {
  11772. /**
  11773. * Class used to represent a sprite
  11774. * @see http://doc.babylonjs.com/babylon101/sprites
  11775. */
  11776. export class Sprite {
  11777. /** defines the name */
  11778. name: string;
  11779. /** Gets or sets the current world position */
  11780. position: Vector3;
  11781. /** Gets or sets the main color */
  11782. color: Color4;
  11783. /** Gets or sets the width */
  11784. width: number;
  11785. /** Gets or sets the height */
  11786. height: number;
  11787. /** Gets or sets rotation angle */
  11788. angle: number;
  11789. /** Gets or sets the cell index in the sprite sheet */
  11790. cellIndex: number;
  11791. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11792. cellRef: string;
  11793. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11794. invertU: number;
  11795. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11796. invertV: number;
  11797. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11798. disposeWhenFinishedAnimating: boolean;
  11799. /** Gets the list of attached animations */
  11800. animations: Animation[];
  11801. /** Gets or sets a boolean indicating if the sprite can be picked */
  11802. isPickable: boolean;
  11803. /**
  11804. * Gets or sets the associated action manager
  11805. */
  11806. actionManager: Nullable<ActionManager>;
  11807. private _animationStarted;
  11808. private _loopAnimation;
  11809. private _fromIndex;
  11810. private _toIndex;
  11811. private _delay;
  11812. private _direction;
  11813. private _manager;
  11814. private _time;
  11815. private _onAnimationEnd;
  11816. /**
  11817. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11818. */
  11819. isVisible: boolean;
  11820. /**
  11821. * Gets or sets the sprite size
  11822. */
  11823. get size(): number;
  11824. set size(value: number);
  11825. /**
  11826. * Creates a new Sprite
  11827. * @param name defines the name
  11828. * @param manager defines the manager
  11829. */
  11830. constructor(
  11831. /** defines the name */
  11832. name: string, manager: ISpriteManager);
  11833. /**
  11834. * Starts an animation
  11835. * @param from defines the initial key
  11836. * @param to defines the end key
  11837. * @param loop defines if the animation must loop
  11838. * @param delay defines the start delay (in ms)
  11839. * @param onAnimationEnd defines a callback to call when animation ends
  11840. */
  11841. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11842. /** Stops current animation (if any) */
  11843. stopAnimation(): void;
  11844. /** @hidden */
  11845. _animate(deltaTime: number): void;
  11846. /** Release associated resources */
  11847. dispose(): void;
  11848. }
  11849. }
  11850. declare module BABYLON {
  11851. /**
  11852. * Information about the result of picking within a scene
  11853. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11854. */
  11855. export class PickingInfo {
  11856. /** @hidden */
  11857. _pickingUnavailable: boolean;
  11858. /**
  11859. * If the pick collided with an object
  11860. */
  11861. hit: boolean;
  11862. /**
  11863. * Distance away where the pick collided
  11864. */
  11865. distance: number;
  11866. /**
  11867. * The location of pick collision
  11868. */
  11869. pickedPoint: Nullable<Vector3>;
  11870. /**
  11871. * The mesh corresponding the the pick collision
  11872. */
  11873. pickedMesh: Nullable<AbstractMesh>;
  11874. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11875. bu: number;
  11876. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11877. bv: number;
  11878. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11879. faceId: number;
  11880. /** Id of the the submesh that was picked */
  11881. subMeshId: number;
  11882. /** If a sprite was picked, this will be the sprite the pick collided with */
  11883. pickedSprite: Nullable<Sprite>;
  11884. /**
  11885. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11886. */
  11887. originMesh: Nullable<AbstractMesh>;
  11888. /**
  11889. * The ray that was used to perform the picking.
  11890. */
  11891. ray: Nullable<Ray>;
  11892. /**
  11893. * Gets the normal correspodning to the face the pick collided with
  11894. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11895. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11896. * @returns The normal correspodning to the face the pick collided with
  11897. */
  11898. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11899. /**
  11900. * Gets the texture coordinates of where the pick occured
  11901. * @returns the vector containing the coordnates of the texture
  11902. */
  11903. getTextureCoordinates(): Nullable<Vector2>;
  11904. }
  11905. }
  11906. declare module BABYLON {
  11907. /**
  11908. * Gather the list of pointer event types as constants.
  11909. */
  11910. export class PointerEventTypes {
  11911. /**
  11912. * 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.
  11913. */
  11914. static readonly POINTERDOWN: number;
  11915. /**
  11916. * The pointerup event is fired when a pointer is no longer active.
  11917. */
  11918. static readonly POINTERUP: number;
  11919. /**
  11920. * The pointermove event is fired when a pointer changes coordinates.
  11921. */
  11922. static readonly POINTERMOVE: number;
  11923. /**
  11924. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11925. */
  11926. static readonly POINTERWHEEL: number;
  11927. /**
  11928. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11929. */
  11930. static readonly POINTERPICK: number;
  11931. /**
  11932. * The pointertap event is fired when a the object has been touched and released without drag.
  11933. */
  11934. static readonly POINTERTAP: number;
  11935. /**
  11936. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11937. */
  11938. static readonly POINTERDOUBLETAP: number;
  11939. }
  11940. /**
  11941. * Base class of pointer info types.
  11942. */
  11943. export class PointerInfoBase {
  11944. /**
  11945. * Defines the type of event (PointerEventTypes)
  11946. */
  11947. type: number;
  11948. /**
  11949. * Defines the related dom event
  11950. */
  11951. event: PointerEvent | MouseWheelEvent;
  11952. /**
  11953. * Instantiates the base class of pointers info.
  11954. * @param type Defines the type of event (PointerEventTypes)
  11955. * @param event Defines the related dom event
  11956. */
  11957. constructor(
  11958. /**
  11959. * Defines the type of event (PointerEventTypes)
  11960. */
  11961. type: number,
  11962. /**
  11963. * Defines the related dom event
  11964. */
  11965. event: PointerEvent | MouseWheelEvent);
  11966. }
  11967. /**
  11968. * This class is used to store pointer related info for the onPrePointerObservable event.
  11969. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11970. */
  11971. export class PointerInfoPre extends PointerInfoBase {
  11972. /**
  11973. * Ray from a pointer if availible (eg. 6dof controller)
  11974. */
  11975. ray: Nullable<Ray>;
  11976. /**
  11977. * Defines the local position of the pointer on the canvas.
  11978. */
  11979. localPosition: Vector2;
  11980. /**
  11981. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11982. */
  11983. skipOnPointerObservable: boolean;
  11984. /**
  11985. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11986. * @param type Defines the type of event (PointerEventTypes)
  11987. * @param event Defines the related dom event
  11988. * @param localX Defines the local x coordinates of the pointer when the event occured
  11989. * @param localY Defines the local y coordinates of the pointer when the event occured
  11990. */
  11991. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  11992. }
  11993. /**
  11994. * This type contains all the data related to a pointer event in Babylon.js.
  11995. * 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.
  11996. */
  11997. export class PointerInfo extends PointerInfoBase {
  11998. /**
  11999. * Defines the picking info associated to the info (if any)\
  12000. */
  12001. pickInfo: Nullable<PickingInfo>;
  12002. /**
  12003. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12004. * @param type Defines the type of event (PointerEventTypes)
  12005. * @param event Defines the related dom event
  12006. * @param pickInfo Defines the picking info associated to the info (if any)\
  12007. */
  12008. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12009. /**
  12010. * Defines the picking info associated to the info (if any)\
  12011. */
  12012. pickInfo: Nullable<PickingInfo>);
  12013. }
  12014. /**
  12015. * Data relating to a touch event on the screen.
  12016. */
  12017. export interface PointerTouch {
  12018. /**
  12019. * X coordinate of touch.
  12020. */
  12021. x: number;
  12022. /**
  12023. * Y coordinate of touch.
  12024. */
  12025. y: number;
  12026. /**
  12027. * Id of touch. Unique for each finger.
  12028. */
  12029. pointerId: number;
  12030. /**
  12031. * Event type passed from DOM.
  12032. */
  12033. type: any;
  12034. }
  12035. }
  12036. declare module BABYLON {
  12037. /**
  12038. * Manage the mouse inputs to control the movement of a free camera.
  12039. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12040. */
  12041. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12042. /**
  12043. * Define if touch is enabled in the mouse input
  12044. */
  12045. touchEnabled: boolean;
  12046. /**
  12047. * Defines the camera the input is attached to.
  12048. */
  12049. camera: FreeCamera;
  12050. /**
  12051. * Defines the buttons associated with the input to handle camera move.
  12052. */
  12053. buttons: number[];
  12054. /**
  12055. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12056. */
  12057. angularSensibility: number;
  12058. private _pointerInput;
  12059. private _onMouseMove;
  12060. private _observer;
  12061. private previousPosition;
  12062. /**
  12063. * Observable for when a pointer move event occurs containing the move offset
  12064. */
  12065. onPointerMovedObservable: Observable<{
  12066. offsetX: number;
  12067. offsetY: number;
  12068. }>;
  12069. /**
  12070. * @hidden
  12071. * If the camera should be rotated automatically based on pointer movement
  12072. */
  12073. _allowCameraRotation: boolean;
  12074. /**
  12075. * Manage the mouse inputs to control the movement of a free camera.
  12076. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12077. * @param touchEnabled Defines if touch is enabled or not
  12078. */
  12079. constructor(
  12080. /**
  12081. * Define if touch is enabled in the mouse input
  12082. */
  12083. touchEnabled?: boolean);
  12084. /**
  12085. * Attach the input controls to a specific dom element to get the input from.
  12086. * @param element Defines the element the controls should be listened from
  12087. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12088. */
  12089. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12090. /**
  12091. * Called on JS contextmenu event.
  12092. * Override this method to provide functionality.
  12093. */
  12094. protected onContextMenu(evt: PointerEvent): void;
  12095. /**
  12096. * Detach the current controls from the specified dom element.
  12097. * @param element Defines the element to stop listening the inputs from
  12098. */
  12099. detachControl(element: Nullable<HTMLElement>): void;
  12100. /**
  12101. * Gets the class name of the current intput.
  12102. * @returns the class name
  12103. */
  12104. getClassName(): string;
  12105. /**
  12106. * Get the friendly name associated with the input class.
  12107. * @returns the input friendly name
  12108. */
  12109. getSimpleName(): string;
  12110. }
  12111. }
  12112. declare module BABYLON {
  12113. /**
  12114. * Manage the touch inputs to control the movement of a free camera.
  12115. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12116. */
  12117. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12118. /**
  12119. * Defines the camera the input is attached to.
  12120. */
  12121. camera: FreeCamera;
  12122. /**
  12123. * Defines the touch sensibility for rotation.
  12124. * The higher the faster.
  12125. */
  12126. touchAngularSensibility: number;
  12127. /**
  12128. * Defines the touch sensibility for move.
  12129. * The higher the faster.
  12130. */
  12131. touchMoveSensibility: number;
  12132. private _offsetX;
  12133. private _offsetY;
  12134. private _pointerPressed;
  12135. private _pointerInput;
  12136. private _observer;
  12137. private _onLostFocus;
  12138. /**
  12139. * Attach the input controls to a specific dom element to get the input from.
  12140. * @param element Defines the element the controls should be listened from
  12141. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12142. */
  12143. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12144. /**
  12145. * Detach the current controls from the specified dom element.
  12146. * @param element Defines the element to stop listening the inputs from
  12147. */
  12148. detachControl(element: Nullable<HTMLElement>): void;
  12149. /**
  12150. * Update the current camera state depending on the inputs that have been used this frame.
  12151. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12152. */
  12153. checkInputs(): void;
  12154. /**
  12155. * Gets the class name of the current intput.
  12156. * @returns the class name
  12157. */
  12158. getClassName(): string;
  12159. /**
  12160. * Get the friendly name associated with the input class.
  12161. * @returns the input friendly name
  12162. */
  12163. getSimpleName(): string;
  12164. }
  12165. }
  12166. declare module BABYLON {
  12167. /**
  12168. * Default Inputs manager for the FreeCamera.
  12169. * It groups all the default supported inputs for ease of use.
  12170. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12171. */
  12172. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12173. /**
  12174. * @hidden
  12175. */
  12176. _mouseInput: Nullable<FreeCameraMouseInput>;
  12177. /**
  12178. * Instantiates a new FreeCameraInputsManager.
  12179. * @param camera Defines the camera the inputs belong to
  12180. */
  12181. constructor(camera: FreeCamera);
  12182. /**
  12183. * Add keyboard input support to the input manager.
  12184. * @returns the current input manager
  12185. */
  12186. addKeyboard(): FreeCameraInputsManager;
  12187. /**
  12188. * Add mouse input support to the input manager.
  12189. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12190. * @returns the current input manager
  12191. */
  12192. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12193. /**
  12194. * Removes the mouse input support from the manager
  12195. * @returns the current input manager
  12196. */
  12197. removeMouse(): FreeCameraInputsManager;
  12198. /**
  12199. * Add touch input support to the input manager.
  12200. * @returns the current input manager
  12201. */
  12202. addTouch(): FreeCameraInputsManager;
  12203. /**
  12204. * Remove all attached input methods from a camera
  12205. */
  12206. clear(): void;
  12207. }
  12208. }
  12209. declare module BABYLON {
  12210. /**
  12211. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12212. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12213. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12214. */
  12215. export class FreeCamera extends TargetCamera {
  12216. /**
  12217. * Define the collision ellipsoid of the camera.
  12218. * This is helpful to simulate a camera body like the player body around the camera
  12219. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12220. */
  12221. ellipsoid: Vector3;
  12222. /**
  12223. * Define an offset for the position of the ellipsoid around the camera.
  12224. * This can be helpful to determine the center of the body near the gravity center of the body
  12225. * instead of its head.
  12226. */
  12227. ellipsoidOffset: Vector3;
  12228. /**
  12229. * Enable or disable collisions of the camera with the rest of the scene objects.
  12230. */
  12231. checkCollisions: boolean;
  12232. /**
  12233. * Enable or disable gravity on the camera.
  12234. */
  12235. applyGravity: boolean;
  12236. /**
  12237. * Define the input manager associated to the camera.
  12238. */
  12239. inputs: FreeCameraInputsManager;
  12240. /**
  12241. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12242. * Higher values reduce sensitivity.
  12243. */
  12244. get angularSensibility(): number;
  12245. /**
  12246. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12247. * Higher values reduce sensitivity.
  12248. */
  12249. set angularSensibility(value: number);
  12250. /**
  12251. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12252. */
  12253. get keysUp(): number[];
  12254. set keysUp(value: number[]);
  12255. /**
  12256. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12257. */
  12258. get keysDown(): number[];
  12259. set keysDown(value: number[]);
  12260. /**
  12261. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12262. */
  12263. get keysLeft(): number[];
  12264. set keysLeft(value: number[]);
  12265. /**
  12266. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12267. */
  12268. get keysRight(): number[];
  12269. set keysRight(value: number[]);
  12270. /**
  12271. * Event raised when the camera collide with a mesh in the scene.
  12272. */
  12273. onCollide: (collidedMesh: AbstractMesh) => void;
  12274. private _collider;
  12275. private _needMoveForGravity;
  12276. private _oldPosition;
  12277. private _diffPosition;
  12278. private _newPosition;
  12279. /** @hidden */
  12280. _localDirection: Vector3;
  12281. /** @hidden */
  12282. _transformedDirection: Vector3;
  12283. /**
  12284. * Instantiates a Free Camera.
  12285. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12286. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12287. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12288. * @param name Define the name of the camera in the scene
  12289. * @param position Define the start position of the camera in the scene
  12290. * @param scene Define the scene the camera belongs to
  12291. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12292. */
  12293. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12294. /**
  12295. * Attached controls to the current camera.
  12296. * @param element Defines the element the controls should be listened from
  12297. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12298. */
  12299. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12300. /**
  12301. * Detach the current controls from the camera.
  12302. * The camera will stop reacting to inputs.
  12303. * @param element Defines the element to stop listening the inputs from
  12304. */
  12305. detachControl(element: HTMLElement): void;
  12306. private _collisionMask;
  12307. /**
  12308. * Define a collision mask to limit the list of object the camera can collide with
  12309. */
  12310. get collisionMask(): number;
  12311. set collisionMask(mask: number);
  12312. /** @hidden */
  12313. _collideWithWorld(displacement: Vector3): void;
  12314. private _onCollisionPositionChange;
  12315. /** @hidden */
  12316. _checkInputs(): void;
  12317. /** @hidden */
  12318. _decideIfNeedsToMove(): boolean;
  12319. /** @hidden */
  12320. _updatePosition(): void;
  12321. /**
  12322. * Destroy the camera and release the current resources hold by it.
  12323. */
  12324. dispose(): void;
  12325. /**
  12326. * Gets the current object class name.
  12327. * @return the class name
  12328. */
  12329. getClassName(): string;
  12330. }
  12331. }
  12332. declare module BABYLON {
  12333. /**
  12334. * Represents a gamepad control stick position
  12335. */
  12336. export class StickValues {
  12337. /**
  12338. * The x component of the control stick
  12339. */
  12340. x: number;
  12341. /**
  12342. * The y component of the control stick
  12343. */
  12344. y: number;
  12345. /**
  12346. * Initializes the gamepad x and y control stick values
  12347. * @param x The x component of the gamepad control stick value
  12348. * @param y The y component of the gamepad control stick value
  12349. */
  12350. constructor(
  12351. /**
  12352. * The x component of the control stick
  12353. */
  12354. x: number,
  12355. /**
  12356. * The y component of the control stick
  12357. */
  12358. y: number);
  12359. }
  12360. /**
  12361. * An interface which manages callbacks for gamepad button changes
  12362. */
  12363. export interface GamepadButtonChanges {
  12364. /**
  12365. * Called when a gamepad has been changed
  12366. */
  12367. changed: boolean;
  12368. /**
  12369. * Called when a gamepad press event has been triggered
  12370. */
  12371. pressChanged: boolean;
  12372. /**
  12373. * Called when a touch event has been triggered
  12374. */
  12375. touchChanged: boolean;
  12376. /**
  12377. * Called when a value has changed
  12378. */
  12379. valueChanged: boolean;
  12380. }
  12381. /**
  12382. * Represents a gamepad
  12383. */
  12384. export class Gamepad {
  12385. /**
  12386. * The id of the gamepad
  12387. */
  12388. id: string;
  12389. /**
  12390. * The index of the gamepad
  12391. */
  12392. index: number;
  12393. /**
  12394. * The browser gamepad
  12395. */
  12396. browserGamepad: any;
  12397. /**
  12398. * Specifies what type of gamepad this represents
  12399. */
  12400. type: number;
  12401. private _leftStick;
  12402. private _rightStick;
  12403. /** @hidden */
  12404. _isConnected: boolean;
  12405. private _leftStickAxisX;
  12406. private _leftStickAxisY;
  12407. private _rightStickAxisX;
  12408. private _rightStickAxisY;
  12409. /**
  12410. * Triggered when the left control stick has been changed
  12411. */
  12412. private _onleftstickchanged;
  12413. /**
  12414. * Triggered when the right control stick has been changed
  12415. */
  12416. private _onrightstickchanged;
  12417. /**
  12418. * Represents a gamepad controller
  12419. */
  12420. static GAMEPAD: number;
  12421. /**
  12422. * Represents a generic controller
  12423. */
  12424. static GENERIC: number;
  12425. /**
  12426. * Represents an XBox controller
  12427. */
  12428. static XBOX: number;
  12429. /**
  12430. * Represents a pose-enabled controller
  12431. */
  12432. static POSE_ENABLED: number;
  12433. /**
  12434. * Represents an Dual Shock controller
  12435. */
  12436. static DUALSHOCK: number;
  12437. /**
  12438. * Specifies whether the left control stick should be Y-inverted
  12439. */
  12440. protected _invertLeftStickY: boolean;
  12441. /**
  12442. * Specifies if the gamepad has been connected
  12443. */
  12444. get isConnected(): boolean;
  12445. /**
  12446. * Initializes the gamepad
  12447. * @param id The id of the gamepad
  12448. * @param index The index of the gamepad
  12449. * @param browserGamepad The browser gamepad
  12450. * @param leftStickX The x component of the left joystick
  12451. * @param leftStickY The y component of the left joystick
  12452. * @param rightStickX The x component of the right joystick
  12453. * @param rightStickY The y component of the right joystick
  12454. */
  12455. constructor(
  12456. /**
  12457. * The id of the gamepad
  12458. */
  12459. id: string,
  12460. /**
  12461. * The index of the gamepad
  12462. */
  12463. index: number,
  12464. /**
  12465. * The browser gamepad
  12466. */
  12467. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12468. /**
  12469. * Callback triggered when the left joystick has changed
  12470. * @param callback
  12471. */
  12472. onleftstickchanged(callback: (values: StickValues) => void): void;
  12473. /**
  12474. * Callback triggered when the right joystick has changed
  12475. * @param callback
  12476. */
  12477. onrightstickchanged(callback: (values: StickValues) => void): void;
  12478. /**
  12479. * Gets the left joystick
  12480. */
  12481. get leftStick(): StickValues;
  12482. /**
  12483. * Sets the left joystick values
  12484. */
  12485. set leftStick(newValues: StickValues);
  12486. /**
  12487. * Gets the right joystick
  12488. */
  12489. get rightStick(): StickValues;
  12490. /**
  12491. * Sets the right joystick value
  12492. */
  12493. set rightStick(newValues: StickValues);
  12494. /**
  12495. * Updates the gamepad joystick positions
  12496. */
  12497. update(): void;
  12498. /**
  12499. * Disposes the gamepad
  12500. */
  12501. dispose(): void;
  12502. }
  12503. /**
  12504. * Represents a generic gamepad
  12505. */
  12506. export class GenericPad extends Gamepad {
  12507. private _buttons;
  12508. private _onbuttondown;
  12509. private _onbuttonup;
  12510. /**
  12511. * Observable triggered when a button has been pressed
  12512. */
  12513. onButtonDownObservable: Observable<number>;
  12514. /**
  12515. * Observable triggered when a button has been released
  12516. */
  12517. onButtonUpObservable: Observable<number>;
  12518. /**
  12519. * Callback triggered when a button has been pressed
  12520. * @param callback Called when a button has been pressed
  12521. */
  12522. onbuttondown(callback: (buttonPressed: number) => void): void;
  12523. /**
  12524. * Callback triggered when a button has been released
  12525. * @param callback Called when a button has been released
  12526. */
  12527. onbuttonup(callback: (buttonReleased: number) => void): void;
  12528. /**
  12529. * Initializes the generic gamepad
  12530. * @param id The id of the generic gamepad
  12531. * @param index The index of the generic gamepad
  12532. * @param browserGamepad The browser gamepad
  12533. */
  12534. constructor(id: string, index: number, browserGamepad: any);
  12535. private _setButtonValue;
  12536. /**
  12537. * Updates the generic gamepad
  12538. */
  12539. update(): void;
  12540. /**
  12541. * Disposes the generic gamepad
  12542. */
  12543. dispose(): void;
  12544. }
  12545. }
  12546. declare module BABYLON {
  12547. interface Engine {
  12548. /**
  12549. * Creates a raw texture
  12550. * @param data defines the data to store in the texture
  12551. * @param width defines the width of the texture
  12552. * @param height defines the height of the texture
  12553. * @param format defines the format of the data
  12554. * @param generateMipMaps defines if the engine should generate the mip levels
  12555. * @param invertY defines if data must be stored with Y axis inverted
  12556. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12557. * @param compression defines the compression used (null by default)
  12558. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12559. * @returns the raw texture inside an InternalTexture
  12560. */
  12561. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12562. /**
  12563. * Update a raw texture
  12564. * @param texture defines the texture to update
  12565. * @param data defines the data to store in the texture
  12566. * @param format defines the format of the data
  12567. * @param invertY defines if data must be stored with Y axis inverted
  12568. */
  12569. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12570. /**
  12571. * Update a raw texture
  12572. * @param texture defines the texture to update
  12573. * @param data defines the data to store in the texture
  12574. * @param format defines the format of the data
  12575. * @param invertY defines if data must be stored with Y axis inverted
  12576. * @param compression defines the compression used (null by default)
  12577. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12578. */
  12579. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12580. /**
  12581. * Creates a new raw cube texture
  12582. * @param data defines the array of data to use to create each face
  12583. * @param size defines the size of the textures
  12584. * @param format defines the format of the data
  12585. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12586. * @param generateMipMaps defines if the engine should generate the mip levels
  12587. * @param invertY defines if data must be stored with Y axis inverted
  12588. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12589. * @param compression defines the compression used (null by default)
  12590. * @returns the cube texture as an InternalTexture
  12591. */
  12592. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12593. /**
  12594. * Update a raw cube texture
  12595. * @param texture defines the texture to udpdate
  12596. * @param data defines the data to store
  12597. * @param format defines the data format
  12598. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12599. * @param invertY defines if data must be stored with Y axis inverted
  12600. */
  12601. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12602. /**
  12603. * Update a raw cube texture
  12604. * @param texture defines the texture to udpdate
  12605. * @param data defines the data to store
  12606. * @param format defines the data format
  12607. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12608. * @param invertY defines if data must be stored with Y axis inverted
  12609. * @param compression defines the compression used (null by default)
  12610. */
  12611. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12612. /**
  12613. * Update a raw cube texture
  12614. * @param texture defines the texture to udpdate
  12615. * @param data defines the data to store
  12616. * @param format defines the data format
  12617. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12618. * @param invertY defines if data must be stored with Y axis inverted
  12619. * @param compression defines the compression used (null by default)
  12620. * @param level defines which level of the texture to update
  12621. */
  12622. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12623. /**
  12624. * Creates a new raw cube texture from a specified url
  12625. * @param url defines the url where the data is located
  12626. * @param scene defines the current scene
  12627. * @param size defines the size of the textures
  12628. * @param format defines the format of the data
  12629. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12630. * @param noMipmap defines if the engine should avoid generating the mip levels
  12631. * @param callback defines a callback used to extract texture data from loaded data
  12632. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12633. * @param onLoad defines a callback called when texture is loaded
  12634. * @param onError defines a callback called if there is an error
  12635. * @returns the cube texture as an InternalTexture
  12636. */
  12637. 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;
  12638. /**
  12639. * Creates a new raw cube texture from a specified url
  12640. * @param url defines the url where the data is located
  12641. * @param scene defines the current scene
  12642. * @param size defines the size of the textures
  12643. * @param format defines the format of the data
  12644. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12645. * @param noMipmap defines if the engine should avoid generating the mip levels
  12646. * @param callback defines a callback used to extract texture data from loaded data
  12647. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12648. * @param onLoad defines a callback called when texture is loaded
  12649. * @param onError defines a callback called if there is an error
  12650. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12651. * @param invertY defines if data must be stored with Y axis inverted
  12652. * @returns the cube texture as an InternalTexture
  12653. */
  12654. 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;
  12655. /**
  12656. * Creates a new raw 3D texture
  12657. * @param data defines the data used to create the texture
  12658. * @param width defines the width of the texture
  12659. * @param height defines the height of the texture
  12660. * @param depth defines the depth of the texture
  12661. * @param format defines the format of the texture
  12662. * @param generateMipMaps defines if the engine must generate mip levels
  12663. * @param invertY defines if data must be stored with Y axis inverted
  12664. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12665. * @param compression defines the compressed used (can be null)
  12666. * @param textureType defines the compressed used (can be null)
  12667. * @returns a new raw 3D texture (stored in an InternalTexture)
  12668. */
  12669. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12670. /**
  12671. * Update a raw 3D texture
  12672. * @param texture defines the texture to update
  12673. * @param data defines the data to store
  12674. * @param format defines the data format
  12675. * @param invertY defines if data must be stored with Y axis inverted
  12676. */
  12677. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12678. /**
  12679. * Update a raw 3D texture
  12680. * @param texture defines the texture to update
  12681. * @param data defines the data to store
  12682. * @param format defines the data format
  12683. * @param invertY defines if data must be stored with Y axis inverted
  12684. * @param compression defines the used compression (can be null)
  12685. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12686. */
  12687. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12688. /**
  12689. * Creates a new raw 2D array texture
  12690. * @param data defines the data used to create the texture
  12691. * @param width defines the width of the texture
  12692. * @param height defines the height of the texture
  12693. * @param depth defines the number of layers of the texture
  12694. * @param format defines the format of the texture
  12695. * @param generateMipMaps defines if the engine must generate mip levels
  12696. * @param invertY defines if data must be stored with Y axis inverted
  12697. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12698. * @param compression defines the compressed used (can be null)
  12699. * @param textureType defines the compressed used (can be null)
  12700. * @returns a new raw 2D array texture (stored in an InternalTexture)
  12701. */
  12702. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12703. /**
  12704. * Update a raw 2D array texture
  12705. * @param texture defines the texture to update
  12706. * @param data defines the data to store
  12707. * @param format defines the data format
  12708. * @param invertY defines if data must be stored with Y axis inverted
  12709. */
  12710. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12711. /**
  12712. * Update a raw 2D array texture
  12713. * @param texture defines the texture to update
  12714. * @param data defines the data to store
  12715. * @param format defines the data format
  12716. * @param invertY defines if data must be stored with Y axis inverted
  12717. * @param compression defines the used compression (can be null)
  12718. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12719. */
  12720. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12721. }
  12722. }
  12723. declare module BABYLON {
  12724. /**
  12725. * Raw texture can help creating a texture directly from an array of data.
  12726. * This can be super useful if you either get the data from an uncompressed source or
  12727. * if you wish to create your texture pixel by pixel.
  12728. */
  12729. export class RawTexture extends Texture {
  12730. /**
  12731. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12732. */
  12733. format: number;
  12734. private _engine;
  12735. /**
  12736. * Instantiates a new RawTexture.
  12737. * Raw texture can help creating a texture directly from an array of data.
  12738. * This can be super useful if you either get the data from an uncompressed source or
  12739. * if you wish to create your texture pixel by pixel.
  12740. * @param data define the array of data to use to create the texture
  12741. * @param width define the width of the texture
  12742. * @param height define the height of the texture
  12743. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12744. * @param scene define the scene the texture belongs to
  12745. * @param generateMipMaps define whether mip maps should be generated or not
  12746. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12747. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12748. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12749. */
  12750. constructor(data: ArrayBufferView, width: number, height: number,
  12751. /**
  12752. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12753. */
  12754. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12755. /**
  12756. * Updates the texture underlying data.
  12757. * @param data Define the new data of the texture
  12758. */
  12759. update(data: ArrayBufferView): void;
  12760. /**
  12761. * Creates a luminance texture from some data.
  12762. * @param data Define the texture data
  12763. * @param width Define the width of the texture
  12764. * @param height Define the height of the texture
  12765. * @param scene Define the scene the texture belongs to
  12766. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12767. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12768. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12769. * @returns the luminance texture
  12770. */
  12771. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12772. /**
  12773. * Creates a luminance alpha texture from some data.
  12774. * @param data Define the texture data
  12775. * @param width Define the width of the texture
  12776. * @param height Define the height of the texture
  12777. * @param scene Define the scene the texture belongs to
  12778. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12779. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12780. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12781. * @returns the luminance alpha texture
  12782. */
  12783. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12784. /**
  12785. * Creates an alpha texture from some data.
  12786. * @param data Define the texture data
  12787. * @param width Define the width of the texture
  12788. * @param height Define the height of the texture
  12789. * @param scene Define the scene the texture belongs to
  12790. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12791. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12792. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12793. * @returns the alpha texture
  12794. */
  12795. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12796. /**
  12797. * Creates a RGB texture from some data.
  12798. * @param data Define the texture data
  12799. * @param width Define the width of the texture
  12800. * @param height Define the height of the texture
  12801. * @param scene Define the scene the texture belongs to
  12802. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12803. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12804. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12805. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12806. * @returns the RGB alpha texture
  12807. */
  12808. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12809. /**
  12810. * Creates a RGBA texture from some data.
  12811. * @param data Define the texture data
  12812. * @param width Define the width of the texture
  12813. * @param height Define the height of the texture
  12814. * @param scene Define the scene the texture belongs to
  12815. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12816. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12817. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12818. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12819. * @returns the RGBA texture
  12820. */
  12821. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12822. /**
  12823. * Creates a R texture from some data.
  12824. * @param data Define the texture data
  12825. * @param width Define the width of the texture
  12826. * @param height Define the height of the texture
  12827. * @param scene Define the scene the texture belongs to
  12828. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12829. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12830. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12831. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12832. * @returns the R texture
  12833. */
  12834. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12835. }
  12836. }
  12837. declare module BABYLON {
  12838. /**
  12839. * Interface for the size containing width and height
  12840. */
  12841. export interface ISize {
  12842. /**
  12843. * Width
  12844. */
  12845. width: number;
  12846. /**
  12847. * Heighht
  12848. */
  12849. height: number;
  12850. }
  12851. /**
  12852. * Size containing widht and height
  12853. */
  12854. export class Size implements ISize {
  12855. /**
  12856. * Width
  12857. */
  12858. width: number;
  12859. /**
  12860. * Height
  12861. */
  12862. height: number;
  12863. /**
  12864. * Creates a Size object from the given width and height (floats).
  12865. * @param width width of the new size
  12866. * @param height height of the new size
  12867. */
  12868. constructor(width: number, height: number);
  12869. /**
  12870. * Returns a string with the Size width and height
  12871. * @returns a string with the Size width and height
  12872. */
  12873. toString(): string;
  12874. /**
  12875. * "Size"
  12876. * @returns the string "Size"
  12877. */
  12878. getClassName(): string;
  12879. /**
  12880. * Returns the Size hash code.
  12881. * @returns a hash code for a unique width and height
  12882. */
  12883. getHashCode(): number;
  12884. /**
  12885. * Updates the current size from the given one.
  12886. * @param src the given size
  12887. */
  12888. copyFrom(src: Size): void;
  12889. /**
  12890. * Updates in place the current Size from the given floats.
  12891. * @param width width of the new size
  12892. * @param height height of the new size
  12893. * @returns the updated Size.
  12894. */
  12895. copyFromFloats(width: number, height: number): Size;
  12896. /**
  12897. * Updates in place the current Size from the given floats.
  12898. * @param width width to set
  12899. * @param height height to set
  12900. * @returns the updated Size.
  12901. */
  12902. set(width: number, height: number): Size;
  12903. /**
  12904. * Multiplies the width and height by numbers
  12905. * @param w factor to multiple the width by
  12906. * @param h factor to multiple the height by
  12907. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12908. */
  12909. multiplyByFloats(w: number, h: number): Size;
  12910. /**
  12911. * Clones the size
  12912. * @returns a new Size copied from the given one.
  12913. */
  12914. clone(): Size;
  12915. /**
  12916. * True if the current Size and the given one width and height are strictly equal.
  12917. * @param other the other size to compare against
  12918. * @returns True if the current Size and the given one width and height are strictly equal.
  12919. */
  12920. equals(other: Size): boolean;
  12921. /**
  12922. * The surface of the Size : width * height (float).
  12923. */
  12924. get surface(): number;
  12925. /**
  12926. * Create a new size of zero
  12927. * @returns a new Size set to (0.0, 0.0)
  12928. */
  12929. static Zero(): Size;
  12930. /**
  12931. * Sums the width and height of two sizes
  12932. * @param otherSize size to add to this size
  12933. * @returns a new Size set as the addition result of the current Size and the given one.
  12934. */
  12935. add(otherSize: Size): Size;
  12936. /**
  12937. * Subtracts the width and height of two
  12938. * @param otherSize size to subtract to this size
  12939. * @returns a new Size set as the subtraction result of the given one from the current Size.
  12940. */
  12941. subtract(otherSize: Size): Size;
  12942. /**
  12943. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  12944. * @param start starting size to lerp between
  12945. * @param end end size to lerp between
  12946. * @param amount amount to lerp between the start and end values
  12947. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  12948. */
  12949. static Lerp(start: Size, end: Size, amount: number): Size;
  12950. }
  12951. }
  12952. declare module BABYLON {
  12953. /**
  12954. * Defines a runtime animation
  12955. */
  12956. export class RuntimeAnimation {
  12957. private _events;
  12958. /**
  12959. * The current frame of the runtime animation
  12960. */
  12961. private _currentFrame;
  12962. /**
  12963. * The animation used by the runtime animation
  12964. */
  12965. private _animation;
  12966. /**
  12967. * The target of the runtime animation
  12968. */
  12969. private _target;
  12970. /**
  12971. * The initiating animatable
  12972. */
  12973. private _host;
  12974. /**
  12975. * The original value of the runtime animation
  12976. */
  12977. private _originalValue;
  12978. /**
  12979. * The original blend value of the runtime animation
  12980. */
  12981. private _originalBlendValue;
  12982. /**
  12983. * The offsets cache of the runtime animation
  12984. */
  12985. private _offsetsCache;
  12986. /**
  12987. * The high limits cache of the runtime animation
  12988. */
  12989. private _highLimitsCache;
  12990. /**
  12991. * Specifies if the runtime animation has been stopped
  12992. */
  12993. private _stopped;
  12994. /**
  12995. * The blending factor of the runtime animation
  12996. */
  12997. private _blendingFactor;
  12998. /**
  12999. * The BabylonJS scene
  13000. */
  13001. private _scene;
  13002. /**
  13003. * The current value of the runtime animation
  13004. */
  13005. private _currentValue;
  13006. /** @hidden */
  13007. _animationState: _IAnimationState;
  13008. /**
  13009. * The active target of the runtime animation
  13010. */
  13011. private _activeTargets;
  13012. private _currentActiveTarget;
  13013. private _directTarget;
  13014. /**
  13015. * The target path of the runtime animation
  13016. */
  13017. private _targetPath;
  13018. /**
  13019. * The weight of the runtime animation
  13020. */
  13021. private _weight;
  13022. /**
  13023. * The ratio offset of the runtime animation
  13024. */
  13025. private _ratioOffset;
  13026. /**
  13027. * The previous delay of the runtime animation
  13028. */
  13029. private _previousDelay;
  13030. /**
  13031. * The previous ratio of the runtime animation
  13032. */
  13033. private _previousRatio;
  13034. private _enableBlending;
  13035. private _keys;
  13036. private _minFrame;
  13037. private _maxFrame;
  13038. private _minValue;
  13039. private _maxValue;
  13040. private _targetIsArray;
  13041. /**
  13042. * Gets the current frame of the runtime animation
  13043. */
  13044. get currentFrame(): number;
  13045. /**
  13046. * Gets the weight of the runtime animation
  13047. */
  13048. get weight(): number;
  13049. /**
  13050. * Gets the current value of the runtime animation
  13051. */
  13052. get currentValue(): any;
  13053. /**
  13054. * Gets the target path of the runtime animation
  13055. */
  13056. get targetPath(): string;
  13057. /**
  13058. * Gets the actual target of the runtime animation
  13059. */
  13060. get target(): any;
  13061. /** @hidden */
  13062. _onLoop: () => void;
  13063. /**
  13064. * Create a new RuntimeAnimation object
  13065. * @param target defines the target of the animation
  13066. * @param animation defines the source animation object
  13067. * @param scene defines the hosting scene
  13068. * @param host defines the initiating Animatable
  13069. */
  13070. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  13071. private _preparePath;
  13072. /**
  13073. * Gets the animation from the runtime animation
  13074. */
  13075. get animation(): Animation;
  13076. /**
  13077. * Resets the runtime animation to the beginning
  13078. * @param restoreOriginal defines whether to restore the target property to the original value
  13079. */
  13080. reset(restoreOriginal?: boolean): void;
  13081. /**
  13082. * Specifies if the runtime animation is stopped
  13083. * @returns Boolean specifying if the runtime animation is stopped
  13084. */
  13085. isStopped(): boolean;
  13086. /**
  13087. * Disposes of the runtime animation
  13088. */
  13089. dispose(): void;
  13090. /**
  13091. * Apply the interpolated value to the target
  13092. * @param currentValue defines the value computed by the animation
  13093. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  13094. */
  13095. setValue(currentValue: any, weight: number): void;
  13096. private _getOriginalValues;
  13097. private _setValue;
  13098. /**
  13099. * Gets the loop pmode of the runtime animation
  13100. * @returns Loop Mode
  13101. */
  13102. private _getCorrectLoopMode;
  13103. /**
  13104. * Move the current animation to a given frame
  13105. * @param frame defines the frame to move to
  13106. */
  13107. goToFrame(frame: number): void;
  13108. /**
  13109. * @hidden Internal use only
  13110. */
  13111. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  13112. /**
  13113. * Execute the current animation
  13114. * @param delay defines the delay to add to the current frame
  13115. * @param from defines the lower bound of the animation range
  13116. * @param to defines the upper bound of the animation range
  13117. * @param loop defines if the current animation must loop
  13118. * @param speedRatio defines the current speed ratio
  13119. * @param weight defines the weight of the animation (default is -1 so no weight)
  13120. * @param onLoop optional callback called when animation loops
  13121. * @returns a boolean indicating if the animation is running
  13122. */
  13123. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  13124. }
  13125. }
  13126. declare module BABYLON {
  13127. /**
  13128. * Class used to store an actual running animation
  13129. */
  13130. export class Animatable {
  13131. /** defines the target object */
  13132. target: any;
  13133. /** defines the starting frame number (default is 0) */
  13134. fromFrame: number;
  13135. /** defines the ending frame number (default is 100) */
  13136. toFrame: number;
  13137. /** defines if the animation must loop (default is false) */
  13138. loopAnimation: boolean;
  13139. /** defines a callback to call when animation ends if it is not looping */
  13140. onAnimationEnd?: (() => void) | null | undefined;
  13141. /** defines a callback to call when animation loops */
  13142. onAnimationLoop?: (() => void) | null | undefined;
  13143. private _localDelayOffset;
  13144. private _pausedDelay;
  13145. private _runtimeAnimations;
  13146. private _paused;
  13147. private _scene;
  13148. private _speedRatio;
  13149. private _weight;
  13150. private _syncRoot;
  13151. /**
  13152. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  13153. * This will only apply for non looping animation (default is true)
  13154. */
  13155. disposeOnEnd: boolean;
  13156. /**
  13157. * Gets a boolean indicating if the animation has started
  13158. */
  13159. animationStarted: boolean;
  13160. /**
  13161. * Observer raised when the animation ends
  13162. */
  13163. onAnimationEndObservable: Observable<Animatable>;
  13164. /**
  13165. * Observer raised when the animation loops
  13166. */
  13167. onAnimationLoopObservable: Observable<Animatable>;
  13168. /**
  13169. * Gets the root Animatable used to synchronize and normalize animations
  13170. */
  13171. get syncRoot(): Nullable<Animatable>;
  13172. /**
  13173. * Gets the current frame of the first RuntimeAnimation
  13174. * Used to synchronize Animatables
  13175. */
  13176. get masterFrame(): number;
  13177. /**
  13178. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  13179. */
  13180. get weight(): number;
  13181. set weight(value: number);
  13182. /**
  13183. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  13184. */
  13185. get speedRatio(): number;
  13186. set speedRatio(value: number);
  13187. /**
  13188. * Creates a new Animatable
  13189. * @param scene defines the hosting scene
  13190. * @param target defines the target object
  13191. * @param fromFrame defines the starting frame number (default is 0)
  13192. * @param toFrame defines the ending frame number (default is 100)
  13193. * @param loopAnimation defines if the animation must loop (default is false)
  13194. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  13195. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  13196. * @param animations defines a group of animation to add to the new Animatable
  13197. * @param onAnimationLoop defines a callback to call when animation loops
  13198. */
  13199. constructor(scene: Scene,
  13200. /** defines the target object */
  13201. target: any,
  13202. /** defines the starting frame number (default is 0) */
  13203. fromFrame?: number,
  13204. /** defines the ending frame number (default is 100) */
  13205. toFrame?: number,
  13206. /** defines if the animation must loop (default is false) */
  13207. loopAnimation?: boolean, speedRatio?: number,
  13208. /** defines a callback to call when animation ends if it is not looping */
  13209. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  13210. /** defines a callback to call when animation loops */
  13211. onAnimationLoop?: (() => void) | null | undefined);
  13212. /**
  13213. * Synchronize and normalize current Animatable with a source Animatable
  13214. * This is useful when using animation weights and when animations are not of the same length
  13215. * @param root defines the root Animatable to synchronize with
  13216. * @returns the current Animatable
  13217. */
  13218. syncWith(root: Animatable): Animatable;
  13219. /**
  13220. * Gets the list of runtime animations
  13221. * @returns an array of RuntimeAnimation
  13222. */
  13223. getAnimations(): RuntimeAnimation[];
  13224. /**
  13225. * Adds more animations to the current animatable
  13226. * @param target defines the target of the animations
  13227. * @param animations defines the new animations to add
  13228. */
  13229. appendAnimations(target: any, animations: Animation[]): void;
  13230. /**
  13231. * Gets the source animation for a specific property
  13232. * @param property defines the propertyu to look for
  13233. * @returns null or the source animation for the given property
  13234. */
  13235. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  13236. /**
  13237. * Gets the runtime animation for a specific property
  13238. * @param property defines the propertyu to look for
  13239. * @returns null or the runtime animation for the given property
  13240. */
  13241. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  13242. /**
  13243. * Resets the animatable to its original state
  13244. */
  13245. reset(): void;
  13246. /**
  13247. * Allows the animatable to blend with current running animations
  13248. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13249. * @param blendingSpeed defines the blending speed to use
  13250. */
  13251. enableBlending(blendingSpeed: number): void;
  13252. /**
  13253. * Disable animation blending
  13254. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13255. */
  13256. disableBlending(): void;
  13257. /**
  13258. * Jump directly to a given frame
  13259. * @param frame defines the frame to jump to
  13260. */
  13261. goToFrame(frame: number): void;
  13262. /**
  13263. * Pause the animation
  13264. */
  13265. pause(): void;
  13266. /**
  13267. * Restart the animation
  13268. */
  13269. restart(): void;
  13270. private _raiseOnAnimationEnd;
  13271. /**
  13272. * Stop and delete the current animation
  13273. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  13274. * @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)
  13275. */
  13276. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  13277. /**
  13278. * Wait asynchronously for the animation to end
  13279. * @returns a promise which will be fullfilled when the animation ends
  13280. */
  13281. waitAsync(): Promise<Animatable>;
  13282. /** @hidden */
  13283. _animate(delay: number): boolean;
  13284. }
  13285. interface Scene {
  13286. /** @hidden */
  13287. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  13288. /** @hidden */
  13289. _processLateAnimationBindingsForMatrices(holder: {
  13290. totalWeight: number;
  13291. animations: RuntimeAnimation[];
  13292. originalValue: Matrix;
  13293. }): any;
  13294. /** @hidden */
  13295. _processLateAnimationBindingsForQuaternions(holder: {
  13296. totalWeight: number;
  13297. animations: RuntimeAnimation[];
  13298. originalValue: Quaternion;
  13299. }, refQuaternion: Quaternion): Quaternion;
  13300. /** @hidden */
  13301. _processLateAnimationBindings(): void;
  13302. /**
  13303. * Will start the animation sequence of a given target
  13304. * @param target defines the target
  13305. * @param from defines from which frame should animation start
  13306. * @param to defines until which frame should animation run.
  13307. * @param weight defines the weight to apply to the animation (1.0 by default)
  13308. * @param loop defines if the animation loops
  13309. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13310. * @param onAnimationEnd defines the function to be executed when the animation ends
  13311. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13312. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13313. * @param onAnimationLoop defines the callback to call when an animation loops
  13314. * @returns the animatable object created for this animation
  13315. */
  13316. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13317. /**
  13318. * Will start the animation sequence of a given target
  13319. * @param target defines the target
  13320. * @param from defines from which frame should animation start
  13321. * @param to defines until which frame should animation run.
  13322. * @param loop defines if the animation loops
  13323. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13324. * @param onAnimationEnd defines the function to be executed when the animation ends
  13325. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13326. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13327. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13328. * @param onAnimationLoop defines the callback to call when an animation loops
  13329. * @returns the animatable object created for this animation
  13330. */
  13331. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13332. /**
  13333. * Will start the animation sequence of a given target and its hierarchy
  13334. * @param target defines the target
  13335. * @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.
  13336. * @param from defines from which frame should animation start
  13337. * @param to defines until which frame should animation run.
  13338. * @param loop defines if the animation loops
  13339. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13340. * @param onAnimationEnd defines the function to be executed when the animation ends
  13341. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13342. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13343. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13344. * @param onAnimationLoop defines the callback to call when an animation loops
  13345. * @returns the list of created animatables
  13346. */
  13347. 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[];
  13348. /**
  13349. * Begin a new animation on a given node
  13350. * @param target defines the target where the animation will take place
  13351. * @param animations defines the list of animations to start
  13352. * @param from defines the initial value
  13353. * @param to defines the final value
  13354. * @param loop defines if you want animation to loop (off by default)
  13355. * @param speedRatio defines the speed ratio to apply to all animations
  13356. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13357. * @param onAnimationLoop defines the callback to call when an animation loops
  13358. * @returns the list of created animatables
  13359. */
  13360. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13361. /**
  13362. * Begin a new animation on a given node and its hierarchy
  13363. * @param target defines the root node where the animation will take place
  13364. * @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.
  13365. * @param animations defines the list of animations to start
  13366. * @param from defines the initial value
  13367. * @param to defines the final value
  13368. * @param loop defines if you want animation to loop (off by default)
  13369. * @param speedRatio defines the speed ratio to apply to all animations
  13370. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13371. * @param onAnimationLoop defines the callback to call when an animation loops
  13372. * @returns the list of animatables created for all nodes
  13373. */
  13374. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13375. /**
  13376. * Gets the animatable associated with a specific target
  13377. * @param target defines the target of the animatable
  13378. * @returns the required animatable if found
  13379. */
  13380. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13381. /**
  13382. * Gets all animatables associated with a given target
  13383. * @param target defines the target to look animatables for
  13384. * @returns an array of Animatables
  13385. */
  13386. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13387. /**
  13388. * Stops and removes all animations that have been applied to the scene
  13389. */
  13390. stopAllAnimations(): void;
  13391. /**
  13392. * Gets the current delta time used by animation engine
  13393. */
  13394. deltaTime: number;
  13395. }
  13396. interface Bone {
  13397. /**
  13398. * Copy an animation range from another bone
  13399. * @param source defines the source bone
  13400. * @param rangeName defines the range name to copy
  13401. * @param frameOffset defines the frame offset
  13402. * @param rescaleAsRequired defines if rescaling must be applied if required
  13403. * @param skelDimensionsRatio defines the scaling ratio
  13404. * @returns true if operation was successful
  13405. */
  13406. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13407. }
  13408. }
  13409. declare module BABYLON {
  13410. /**
  13411. * Class used to override all child animations of a given target
  13412. */
  13413. export class AnimationPropertiesOverride {
  13414. /**
  13415. * Gets or sets a value indicating if animation blending must be used
  13416. */
  13417. enableBlending: boolean;
  13418. /**
  13419. * Gets or sets the blending speed to use when enableBlending is true
  13420. */
  13421. blendingSpeed: number;
  13422. /**
  13423. * Gets or sets the default loop mode to use
  13424. */
  13425. loopMode: number;
  13426. }
  13427. }
  13428. declare module BABYLON {
  13429. /**
  13430. * Class used to handle skinning animations
  13431. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13432. */
  13433. export class Skeleton implements IAnimatable {
  13434. /** defines the skeleton name */
  13435. name: string;
  13436. /** defines the skeleton Id */
  13437. id: string;
  13438. /**
  13439. * Defines the list of child bones
  13440. */
  13441. bones: Bone[];
  13442. /**
  13443. * Defines an estimate of the dimension of the skeleton at rest
  13444. */
  13445. dimensionsAtRest: Vector3;
  13446. /**
  13447. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13448. */
  13449. needInitialSkinMatrix: boolean;
  13450. /**
  13451. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13452. */
  13453. overrideMesh: Nullable<AbstractMesh>;
  13454. /**
  13455. * Gets the list of animations attached to this skeleton
  13456. */
  13457. animations: Array<Animation>;
  13458. private _scene;
  13459. private _isDirty;
  13460. private _transformMatrices;
  13461. private _transformMatrixTexture;
  13462. private _meshesWithPoseMatrix;
  13463. private _animatables;
  13464. private _identity;
  13465. private _synchronizedWithMesh;
  13466. private _ranges;
  13467. private _lastAbsoluteTransformsUpdateId;
  13468. private _canUseTextureForBones;
  13469. private _uniqueId;
  13470. /** @hidden */
  13471. _numBonesWithLinkedTransformNode: number;
  13472. /** @hidden */
  13473. _hasWaitingData: Nullable<boolean>;
  13474. /**
  13475. * Specifies if the skeleton should be serialized
  13476. */
  13477. doNotSerialize: boolean;
  13478. private _useTextureToStoreBoneMatrices;
  13479. /**
  13480. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13481. * Please note that this option is not available if the hardware does not support it
  13482. */
  13483. get useTextureToStoreBoneMatrices(): boolean;
  13484. set useTextureToStoreBoneMatrices(value: boolean);
  13485. private _animationPropertiesOverride;
  13486. /**
  13487. * Gets or sets the animation properties override
  13488. */
  13489. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  13490. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  13491. /**
  13492. * List of inspectable custom properties (used by the Inspector)
  13493. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13494. */
  13495. inspectableCustomProperties: IInspectable[];
  13496. /**
  13497. * An observable triggered before computing the skeleton's matrices
  13498. */
  13499. onBeforeComputeObservable: Observable<Skeleton>;
  13500. /**
  13501. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13502. */
  13503. get isUsingTextureForMatrices(): boolean;
  13504. /**
  13505. * Gets the unique ID of this skeleton
  13506. */
  13507. get uniqueId(): number;
  13508. /**
  13509. * Creates a new skeleton
  13510. * @param name defines the skeleton name
  13511. * @param id defines the skeleton Id
  13512. * @param scene defines the hosting scene
  13513. */
  13514. constructor(
  13515. /** defines the skeleton name */
  13516. name: string,
  13517. /** defines the skeleton Id */
  13518. id: string, scene: Scene);
  13519. /**
  13520. * Gets the current object class name.
  13521. * @return the class name
  13522. */
  13523. getClassName(): string;
  13524. /**
  13525. * Returns an array containing the root bones
  13526. * @returns an array containing the root bones
  13527. */
  13528. getChildren(): Array<Bone>;
  13529. /**
  13530. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13531. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13532. * @returns a Float32Array containing matrices data
  13533. */
  13534. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13535. /**
  13536. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13537. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13538. * @returns a raw texture containing the data
  13539. */
  13540. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13541. /**
  13542. * Gets the current hosting scene
  13543. * @returns a scene object
  13544. */
  13545. getScene(): Scene;
  13546. /**
  13547. * Gets a string representing the current skeleton data
  13548. * @param fullDetails defines a boolean indicating if we want a verbose version
  13549. * @returns a string representing the current skeleton data
  13550. */
  13551. toString(fullDetails?: boolean): string;
  13552. /**
  13553. * Get bone's index searching by name
  13554. * @param name defines bone's name to search for
  13555. * @return the indice of the bone. Returns -1 if not found
  13556. */
  13557. getBoneIndexByName(name: string): number;
  13558. /**
  13559. * Creater a new animation range
  13560. * @param name defines the name of the range
  13561. * @param from defines the start key
  13562. * @param to defines the end key
  13563. */
  13564. createAnimationRange(name: string, from: number, to: number): void;
  13565. /**
  13566. * Delete a specific animation range
  13567. * @param name defines the name of the range
  13568. * @param deleteFrames defines if frames must be removed as well
  13569. */
  13570. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13571. /**
  13572. * Gets a specific animation range
  13573. * @param name defines the name of the range to look for
  13574. * @returns the requested animation range or null if not found
  13575. */
  13576. getAnimationRange(name: string): Nullable<AnimationRange>;
  13577. /**
  13578. * Gets the list of all animation ranges defined on this skeleton
  13579. * @returns an array
  13580. */
  13581. getAnimationRanges(): Nullable<AnimationRange>[];
  13582. /**
  13583. * Copy animation range from a source skeleton.
  13584. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13585. * @param source defines the source skeleton
  13586. * @param name defines the name of the range to copy
  13587. * @param rescaleAsRequired defines if rescaling must be applied if required
  13588. * @returns true if operation was successful
  13589. */
  13590. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13591. /**
  13592. * Forces the skeleton to go to rest pose
  13593. */
  13594. returnToRest(): void;
  13595. private _getHighestAnimationFrame;
  13596. /**
  13597. * Begin a specific animation range
  13598. * @param name defines the name of the range to start
  13599. * @param loop defines if looping must be turned on (false by default)
  13600. * @param speedRatio defines the speed ratio to apply (1 by default)
  13601. * @param onAnimationEnd defines a callback which will be called when animation will end
  13602. * @returns a new animatable
  13603. */
  13604. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13605. /** @hidden */
  13606. _markAsDirty(): void;
  13607. /** @hidden */
  13608. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13609. /** @hidden */
  13610. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13611. private _computeTransformMatrices;
  13612. /**
  13613. * Build all resources required to render a skeleton
  13614. */
  13615. prepare(): void;
  13616. /**
  13617. * Gets the list of animatables currently running for this skeleton
  13618. * @returns an array of animatables
  13619. */
  13620. getAnimatables(): IAnimatable[];
  13621. /**
  13622. * Clone the current skeleton
  13623. * @param name defines the name of the new skeleton
  13624. * @param id defines the id of the new skeleton
  13625. * @returns the new skeleton
  13626. */
  13627. clone(name: string, id?: string): Skeleton;
  13628. /**
  13629. * Enable animation blending for this skeleton
  13630. * @param blendingSpeed defines the blending speed to apply
  13631. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13632. */
  13633. enableBlending(blendingSpeed?: number): void;
  13634. /**
  13635. * Releases all resources associated with the current skeleton
  13636. */
  13637. dispose(): void;
  13638. /**
  13639. * Serialize the skeleton in a JSON object
  13640. * @returns a JSON object
  13641. */
  13642. serialize(): any;
  13643. /**
  13644. * Creates a new skeleton from serialized data
  13645. * @param parsedSkeleton defines the serialized data
  13646. * @param scene defines the hosting scene
  13647. * @returns a new skeleton
  13648. */
  13649. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13650. /**
  13651. * Compute all node absolute transforms
  13652. * @param forceUpdate defines if computation must be done even if cache is up to date
  13653. */
  13654. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13655. /**
  13656. * Gets the root pose matrix
  13657. * @returns a matrix
  13658. */
  13659. getPoseMatrix(): Nullable<Matrix>;
  13660. /**
  13661. * Sorts bones per internal index
  13662. */
  13663. sortBones(): void;
  13664. private _sortBones;
  13665. }
  13666. }
  13667. declare module BABYLON {
  13668. /**
  13669. * Class used to store bone information
  13670. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13671. */
  13672. export class Bone extends Node {
  13673. /**
  13674. * defines the bone name
  13675. */
  13676. name: string;
  13677. private static _tmpVecs;
  13678. private static _tmpQuat;
  13679. private static _tmpMats;
  13680. /**
  13681. * Gets the list of child bones
  13682. */
  13683. children: Bone[];
  13684. /** Gets the animations associated with this bone */
  13685. animations: Animation[];
  13686. /**
  13687. * Gets or sets bone length
  13688. */
  13689. length: number;
  13690. /**
  13691. * @hidden Internal only
  13692. * Set this value to map this bone to a different index in the transform matrices
  13693. * Set this value to -1 to exclude the bone from the transform matrices
  13694. */
  13695. _index: Nullable<number>;
  13696. private _skeleton;
  13697. private _localMatrix;
  13698. private _restPose;
  13699. private _baseMatrix;
  13700. private _absoluteTransform;
  13701. private _invertedAbsoluteTransform;
  13702. private _parent;
  13703. private _scalingDeterminant;
  13704. private _worldTransform;
  13705. private _localScaling;
  13706. private _localRotation;
  13707. private _localPosition;
  13708. private _needToDecompose;
  13709. private _needToCompose;
  13710. /** @hidden */
  13711. _linkedTransformNode: Nullable<TransformNode>;
  13712. /** @hidden */
  13713. _waitingTransformNodeId: Nullable<string>;
  13714. /** @hidden */
  13715. get _matrix(): Matrix;
  13716. /** @hidden */
  13717. set _matrix(value: Matrix);
  13718. /**
  13719. * Create a new bone
  13720. * @param name defines the bone name
  13721. * @param skeleton defines the parent skeleton
  13722. * @param parentBone defines the parent (can be null if the bone is the root)
  13723. * @param localMatrix defines the local matrix
  13724. * @param restPose defines the rest pose matrix
  13725. * @param baseMatrix defines the base matrix
  13726. * @param index defines index of the bone in the hiearchy
  13727. */
  13728. constructor(
  13729. /**
  13730. * defines the bone name
  13731. */
  13732. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13733. /**
  13734. * Gets the current object class name.
  13735. * @return the class name
  13736. */
  13737. getClassName(): string;
  13738. /**
  13739. * Gets the parent skeleton
  13740. * @returns a skeleton
  13741. */
  13742. getSkeleton(): Skeleton;
  13743. /**
  13744. * Gets parent bone
  13745. * @returns a bone or null if the bone is the root of the bone hierarchy
  13746. */
  13747. getParent(): Nullable<Bone>;
  13748. /**
  13749. * Returns an array containing the root bones
  13750. * @returns an array containing the root bones
  13751. */
  13752. getChildren(): Array<Bone>;
  13753. /**
  13754. * Gets the node index in matrix array generated for rendering
  13755. * @returns the node index
  13756. */
  13757. getIndex(): number;
  13758. /**
  13759. * Sets the parent bone
  13760. * @param parent defines the parent (can be null if the bone is the root)
  13761. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13762. */
  13763. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13764. /**
  13765. * Gets the local matrix
  13766. * @returns a matrix
  13767. */
  13768. getLocalMatrix(): Matrix;
  13769. /**
  13770. * Gets the base matrix (initial matrix which remains unchanged)
  13771. * @returns a matrix
  13772. */
  13773. getBaseMatrix(): Matrix;
  13774. /**
  13775. * Gets the rest pose matrix
  13776. * @returns a matrix
  13777. */
  13778. getRestPose(): Matrix;
  13779. /**
  13780. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13781. */
  13782. getWorldMatrix(): Matrix;
  13783. /**
  13784. * Sets the local matrix to rest pose matrix
  13785. */
  13786. returnToRest(): void;
  13787. /**
  13788. * Gets the inverse of the absolute transform matrix.
  13789. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13790. * @returns a matrix
  13791. */
  13792. getInvertedAbsoluteTransform(): Matrix;
  13793. /**
  13794. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13795. * @returns a matrix
  13796. */
  13797. getAbsoluteTransform(): Matrix;
  13798. /**
  13799. * Links with the given transform node.
  13800. * The local matrix of this bone is copied from the transform node every frame.
  13801. * @param transformNode defines the transform node to link to
  13802. */
  13803. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13804. /**
  13805. * Gets the node used to drive the bone's transformation
  13806. * @returns a transform node or null
  13807. */
  13808. getTransformNode(): Nullable<TransformNode>;
  13809. /** Gets or sets current position (in local space) */
  13810. get position(): Vector3;
  13811. set position(newPosition: Vector3);
  13812. /** Gets or sets current rotation (in local space) */
  13813. get rotation(): Vector3;
  13814. set rotation(newRotation: Vector3);
  13815. /** Gets or sets current rotation quaternion (in local space) */
  13816. get rotationQuaternion(): Quaternion;
  13817. set rotationQuaternion(newRotation: Quaternion);
  13818. /** Gets or sets current scaling (in local space) */
  13819. get scaling(): Vector3;
  13820. set scaling(newScaling: Vector3);
  13821. /**
  13822. * Gets the animation properties override
  13823. */
  13824. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  13825. private _decompose;
  13826. private _compose;
  13827. /**
  13828. * Update the base and local matrices
  13829. * @param matrix defines the new base or local matrix
  13830. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13831. * @param updateLocalMatrix defines if the local matrix should be updated
  13832. */
  13833. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13834. /** @hidden */
  13835. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13836. /**
  13837. * Flag the bone as dirty (Forcing it to update everything)
  13838. */
  13839. markAsDirty(): void;
  13840. /** @hidden */
  13841. _markAsDirtyAndCompose(): void;
  13842. private _markAsDirtyAndDecompose;
  13843. /**
  13844. * Translate the bone in local or world space
  13845. * @param vec The amount to translate the bone
  13846. * @param space The space that the translation is in
  13847. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13848. */
  13849. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13850. /**
  13851. * Set the postion of the bone in local or world space
  13852. * @param position The position to set the bone
  13853. * @param space The space that the position is in
  13854. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13855. */
  13856. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13857. /**
  13858. * Set the absolute position of the bone (world space)
  13859. * @param position The position to set the bone
  13860. * @param mesh The mesh that this bone is attached to
  13861. */
  13862. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13863. /**
  13864. * Scale the bone on the x, y and z axes (in local space)
  13865. * @param x The amount to scale the bone on the x axis
  13866. * @param y The amount to scale the bone on the y axis
  13867. * @param z The amount to scale the bone on the z axis
  13868. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13869. */
  13870. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13871. /**
  13872. * Set the bone scaling in local space
  13873. * @param scale defines the scaling vector
  13874. */
  13875. setScale(scale: Vector3): void;
  13876. /**
  13877. * Gets the current scaling in local space
  13878. * @returns the current scaling vector
  13879. */
  13880. getScale(): Vector3;
  13881. /**
  13882. * Gets the current scaling in local space and stores it in a target vector
  13883. * @param result defines the target vector
  13884. */
  13885. getScaleToRef(result: Vector3): void;
  13886. /**
  13887. * Set the yaw, pitch, and roll of the bone in local or world space
  13888. * @param yaw The rotation of the bone on the y axis
  13889. * @param pitch The rotation of the bone on the x axis
  13890. * @param roll The rotation of the bone on the z axis
  13891. * @param space The space that the axes of rotation are in
  13892. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13893. */
  13894. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13895. /**
  13896. * Add a rotation to the bone on an axis in local or world space
  13897. * @param axis The axis to rotate the bone on
  13898. * @param amount The amount to rotate the bone
  13899. * @param space The space that the axis is in
  13900. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13901. */
  13902. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13903. /**
  13904. * Set the rotation of the bone to a particular axis angle in local or world space
  13905. * @param axis The axis to rotate the bone on
  13906. * @param angle The angle that the bone should be rotated to
  13907. * @param space The space that the axis is in
  13908. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13909. */
  13910. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  13911. /**
  13912. * Set the euler rotation of the bone in local of world space
  13913. * @param rotation The euler rotation that the bone should be set to
  13914. * @param space The space that the rotation is in
  13915. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13916. */
  13917. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13918. /**
  13919. * Set the quaternion rotation of the bone in local of world space
  13920. * @param quat The quaternion rotation that the bone should be set to
  13921. * @param space The space that the rotation is in
  13922. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13923. */
  13924. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  13925. /**
  13926. * Set the rotation matrix of the bone in local of world space
  13927. * @param rotMat The rotation matrix that the bone should be set to
  13928. * @param space The space that the rotation is in
  13929. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13930. */
  13931. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  13932. private _rotateWithMatrix;
  13933. private _getNegativeRotationToRef;
  13934. /**
  13935. * Get the position of the bone in local or world space
  13936. * @param space The space that the returned position is in
  13937. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13938. * @returns The position of the bone
  13939. */
  13940. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13941. /**
  13942. * Copy the position of the bone to a vector3 in local or world space
  13943. * @param space The space that the returned position is in
  13944. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13945. * @param result The vector3 to copy the position to
  13946. */
  13947. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  13948. /**
  13949. * Get the absolute position of the bone (world space)
  13950. * @param mesh The mesh that this bone is attached to
  13951. * @returns The absolute position of the bone
  13952. */
  13953. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  13954. /**
  13955. * Copy the absolute position of the bone (world space) to the result param
  13956. * @param mesh The mesh that this bone is attached to
  13957. * @param result The vector3 to copy the absolute position to
  13958. */
  13959. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  13960. /**
  13961. * Compute the absolute transforms of this bone and its children
  13962. */
  13963. computeAbsoluteTransforms(): void;
  13964. /**
  13965. * Get the world direction from an axis that is in the local space of the bone
  13966. * @param localAxis The local direction that is used to compute the world direction
  13967. * @param mesh The mesh that this bone is attached to
  13968. * @returns The world direction
  13969. */
  13970. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13971. /**
  13972. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  13973. * @param localAxis The local direction that is used to compute the world direction
  13974. * @param mesh The mesh that this bone is attached to
  13975. * @param result The vector3 that the world direction will be copied to
  13976. */
  13977. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13978. /**
  13979. * Get the euler rotation of the bone in local or world space
  13980. * @param space The space that the rotation should be in
  13981. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13982. * @returns The euler rotation
  13983. */
  13984. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13985. /**
  13986. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  13987. * @param space The space that the rotation should be in
  13988. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13989. * @param result The vector3 that the rotation should be copied to
  13990. */
  13991. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13992. /**
  13993. * Get the quaternion rotation of the bone in either local or world space
  13994. * @param space The space that the rotation should be in
  13995. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13996. * @returns The quaternion rotation
  13997. */
  13998. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  13999. /**
  14000. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14001. * @param space The space that the rotation should be in
  14002. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14003. * @param result The quaternion that the rotation should be copied to
  14004. */
  14005. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14006. /**
  14007. * Get the rotation matrix of the bone in local or world space
  14008. * @param space The space that the rotation should be in
  14009. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14010. * @returns The rotation matrix
  14011. */
  14012. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14013. /**
  14014. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14015. * @param space The space that the rotation should be in
  14016. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14017. * @param result The quaternion that the rotation should be copied to
  14018. */
  14019. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14020. /**
  14021. * Get the world position of a point that is in the local space of the bone
  14022. * @param position The local position
  14023. * @param mesh The mesh that this bone is attached to
  14024. * @returns The world position
  14025. */
  14026. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14027. /**
  14028. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14029. * @param position The local position
  14030. * @param mesh The mesh that this bone is attached to
  14031. * @param result The vector3 that the world position should be copied to
  14032. */
  14033. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14034. /**
  14035. * Get the local position of a point that is in world space
  14036. * @param position The world position
  14037. * @param mesh The mesh that this bone is attached to
  14038. * @returns The local position
  14039. */
  14040. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14041. /**
  14042. * Get the local position of a point that is in world space and copy it to the result param
  14043. * @param position The world position
  14044. * @param mesh The mesh that this bone is attached to
  14045. * @param result The vector3 that the local position should be copied to
  14046. */
  14047. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14048. }
  14049. }
  14050. declare module BABYLON {
  14051. /**
  14052. * 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.
  14053. * @see https://doc.babylonjs.com/how_to/transformnode
  14054. */
  14055. export class TransformNode extends Node {
  14056. /**
  14057. * Object will not rotate to face the camera
  14058. */
  14059. static BILLBOARDMODE_NONE: number;
  14060. /**
  14061. * Object will rotate to face the camera but only on the x axis
  14062. */
  14063. static BILLBOARDMODE_X: number;
  14064. /**
  14065. * Object will rotate to face the camera but only on the y axis
  14066. */
  14067. static BILLBOARDMODE_Y: number;
  14068. /**
  14069. * Object will rotate to face the camera but only on the z axis
  14070. */
  14071. static BILLBOARDMODE_Z: number;
  14072. /**
  14073. * Object will rotate to face the camera
  14074. */
  14075. static BILLBOARDMODE_ALL: number;
  14076. /**
  14077. * Object will rotate to face the camera's position instead of orientation
  14078. */
  14079. static BILLBOARDMODE_USE_POSITION: number;
  14080. private _forward;
  14081. private _forwardInverted;
  14082. private _up;
  14083. private _right;
  14084. private _rightInverted;
  14085. private _position;
  14086. private _rotation;
  14087. private _rotationQuaternion;
  14088. protected _scaling: Vector3;
  14089. protected _isDirty: boolean;
  14090. private _transformToBoneReferal;
  14091. private _isAbsoluteSynced;
  14092. private _billboardMode;
  14093. /**
  14094. * Gets or sets the billboard mode. Default is 0.
  14095. *
  14096. * | Value | Type | Description |
  14097. * | --- | --- | --- |
  14098. * | 0 | BILLBOARDMODE_NONE | |
  14099. * | 1 | BILLBOARDMODE_X | |
  14100. * | 2 | BILLBOARDMODE_Y | |
  14101. * | 4 | BILLBOARDMODE_Z | |
  14102. * | 7 | BILLBOARDMODE_ALL | |
  14103. *
  14104. */
  14105. get billboardMode(): number;
  14106. set billboardMode(value: number);
  14107. private _preserveParentRotationForBillboard;
  14108. /**
  14109. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14110. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14111. */
  14112. get preserveParentRotationForBillboard(): boolean;
  14113. set preserveParentRotationForBillboard(value: boolean);
  14114. /**
  14115. * 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
  14116. */
  14117. scalingDeterminant: number;
  14118. private _infiniteDistance;
  14119. /**
  14120. * Gets or sets the distance of the object to max, often used by skybox
  14121. */
  14122. get infiniteDistance(): boolean;
  14123. set infiniteDistance(value: boolean);
  14124. /**
  14125. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14126. * By default the system will update normals to compensate
  14127. */
  14128. ignoreNonUniformScaling: boolean;
  14129. /**
  14130. * 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
  14131. */
  14132. reIntegrateRotationIntoRotationQuaternion: boolean;
  14133. /** @hidden */
  14134. _poseMatrix: Nullable<Matrix>;
  14135. /** @hidden */
  14136. _localMatrix: Matrix;
  14137. private _usePivotMatrix;
  14138. private _absolutePosition;
  14139. private _absoluteScaling;
  14140. private _absoluteRotationQuaternion;
  14141. private _pivotMatrix;
  14142. private _pivotMatrixInverse;
  14143. protected _postMultiplyPivotMatrix: boolean;
  14144. protected _isWorldMatrixFrozen: boolean;
  14145. /** @hidden */
  14146. _indexInSceneTransformNodesArray: number;
  14147. /**
  14148. * An event triggered after the world matrix is updated
  14149. */
  14150. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14151. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14152. /**
  14153. * Gets a string identifying the name of the class
  14154. * @returns "TransformNode" string
  14155. */
  14156. getClassName(): string;
  14157. /**
  14158. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14159. */
  14160. get position(): Vector3;
  14161. set position(newPosition: Vector3);
  14162. /**
  14163. * 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)).
  14164. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14165. */
  14166. get rotation(): Vector3;
  14167. set rotation(newRotation: Vector3);
  14168. /**
  14169. * 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)).
  14170. */
  14171. get scaling(): Vector3;
  14172. set scaling(newScaling: Vector3);
  14173. /**
  14174. * 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).
  14175. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14176. */
  14177. get rotationQuaternion(): Nullable<Quaternion>;
  14178. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  14179. /**
  14180. * The forward direction of that transform in world space.
  14181. */
  14182. get forward(): Vector3;
  14183. /**
  14184. * The up direction of that transform in world space.
  14185. */
  14186. get up(): Vector3;
  14187. /**
  14188. * The right direction of that transform in world space.
  14189. */
  14190. get right(): Vector3;
  14191. /**
  14192. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14193. * @param matrix the matrix to copy the pose from
  14194. * @returns this TransformNode.
  14195. */
  14196. updatePoseMatrix(matrix: Matrix): TransformNode;
  14197. /**
  14198. * Returns the mesh Pose matrix.
  14199. * @returns the pose matrix
  14200. */
  14201. getPoseMatrix(): Matrix;
  14202. /** @hidden */
  14203. _isSynchronized(): boolean;
  14204. /** @hidden */
  14205. _initCache(): void;
  14206. /**
  14207. * Flag the transform node as dirty (Forcing it to update everything)
  14208. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14209. * @returns this transform node
  14210. */
  14211. markAsDirty(property: string): TransformNode;
  14212. /**
  14213. * Returns the current mesh absolute position.
  14214. * Returns a Vector3.
  14215. */
  14216. get absolutePosition(): Vector3;
  14217. /**
  14218. * Returns the current mesh absolute scaling.
  14219. * Returns a Vector3.
  14220. */
  14221. get absoluteScaling(): Vector3;
  14222. /**
  14223. * Returns the current mesh absolute rotation.
  14224. * Returns a Quaternion.
  14225. */
  14226. get absoluteRotationQuaternion(): Quaternion;
  14227. /**
  14228. * Sets a new matrix to apply before all other transformation
  14229. * @param matrix defines the transform matrix
  14230. * @returns the current TransformNode
  14231. */
  14232. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14233. /**
  14234. * Sets a new pivot matrix to the current node
  14235. * @param matrix defines the new pivot matrix to use
  14236. * @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
  14237. * @returns the current TransformNode
  14238. */
  14239. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14240. /**
  14241. * Returns the mesh pivot matrix.
  14242. * Default : Identity.
  14243. * @returns the matrix
  14244. */
  14245. getPivotMatrix(): Matrix;
  14246. /**
  14247. * Instantiate (when possible) or clone that node with its hierarchy
  14248. * @param newParent defines the new parent to use for the instance (or clone)
  14249. * @param options defines options to configure how copy is done
  14250. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14251. * @returns an instance (or a clone) of the current node with its hiearchy
  14252. */
  14253. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14254. doNotInstantiate: boolean;
  14255. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14256. /**
  14257. * Prevents the World matrix to be computed any longer
  14258. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14259. * @returns the TransformNode.
  14260. */
  14261. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14262. /**
  14263. * Allows back the World matrix computation.
  14264. * @returns the TransformNode.
  14265. */
  14266. unfreezeWorldMatrix(): this;
  14267. /**
  14268. * True if the World matrix has been frozen.
  14269. */
  14270. get isWorldMatrixFrozen(): boolean;
  14271. /**
  14272. * Retuns the mesh absolute position in the World.
  14273. * @returns a Vector3.
  14274. */
  14275. getAbsolutePosition(): Vector3;
  14276. /**
  14277. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14278. * @param absolutePosition the absolute position to set
  14279. * @returns the TransformNode.
  14280. */
  14281. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14282. /**
  14283. * Sets the mesh position in its local space.
  14284. * @param vector3 the position to set in localspace
  14285. * @returns the TransformNode.
  14286. */
  14287. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14288. /**
  14289. * Returns the mesh position in the local space from the current World matrix values.
  14290. * @returns a new Vector3.
  14291. */
  14292. getPositionExpressedInLocalSpace(): Vector3;
  14293. /**
  14294. * Translates the mesh along the passed Vector3 in its local space.
  14295. * @param vector3 the distance to translate in localspace
  14296. * @returns the TransformNode.
  14297. */
  14298. locallyTranslate(vector3: Vector3): TransformNode;
  14299. private static _lookAtVectorCache;
  14300. /**
  14301. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14302. * @param targetPoint the position (must be in same space as current mesh) to look at
  14303. * @param yawCor optional yaw (y-axis) correction in radians
  14304. * @param pitchCor optional pitch (x-axis) correction in radians
  14305. * @param rollCor optional roll (z-axis) correction in radians
  14306. * @param space the choosen space of the target
  14307. * @returns the TransformNode.
  14308. */
  14309. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14310. /**
  14311. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14312. * This Vector3 is expressed in the World space.
  14313. * @param localAxis axis to rotate
  14314. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14315. */
  14316. getDirection(localAxis: Vector3): Vector3;
  14317. /**
  14318. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14319. * localAxis is expressed in the mesh local space.
  14320. * result is computed in the Wordl space from the mesh World matrix.
  14321. * @param localAxis axis to rotate
  14322. * @param result the resulting transformnode
  14323. * @returns this TransformNode.
  14324. */
  14325. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14326. /**
  14327. * Sets this transform node rotation to the given local axis.
  14328. * @param localAxis the axis in local space
  14329. * @param yawCor optional yaw (y-axis) correction in radians
  14330. * @param pitchCor optional pitch (x-axis) correction in radians
  14331. * @param rollCor optional roll (z-axis) correction in radians
  14332. * @returns this TransformNode
  14333. */
  14334. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14335. /**
  14336. * Sets a new pivot point to the current node
  14337. * @param point defines the new pivot point to use
  14338. * @param space defines if the point is in world or local space (local by default)
  14339. * @returns the current TransformNode
  14340. */
  14341. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14342. /**
  14343. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14344. * @returns the pivot point
  14345. */
  14346. getPivotPoint(): Vector3;
  14347. /**
  14348. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14349. * @param result the vector3 to store the result
  14350. * @returns this TransformNode.
  14351. */
  14352. getPivotPointToRef(result: Vector3): TransformNode;
  14353. /**
  14354. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14355. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14356. */
  14357. getAbsolutePivotPoint(): Vector3;
  14358. /**
  14359. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14360. * @param result vector3 to store the result
  14361. * @returns this TransformNode.
  14362. */
  14363. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14364. /**
  14365. * Defines the passed node as the parent of the current node.
  14366. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14367. * @see https://doc.babylonjs.com/how_to/parenting
  14368. * @param node the node ot set as the parent
  14369. * @returns this TransformNode.
  14370. */
  14371. setParent(node: Nullable<Node>): TransformNode;
  14372. private _nonUniformScaling;
  14373. /**
  14374. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14375. */
  14376. get nonUniformScaling(): boolean;
  14377. /** @hidden */
  14378. _updateNonUniformScalingState(value: boolean): boolean;
  14379. /**
  14380. * Attach the current TransformNode to another TransformNode associated with a bone
  14381. * @param bone Bone affecting the TransformNode
  14382. * @param affectedTransformNode TransformNode associated with the bone
  14383. * @returns this object
  14384. */
  14385. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14386. /**
  14387. * Detach the transform node if its associated with a bone
  14388. * @returns this object
  14389. */
  14390. detachFromBone(): TransformNode;
  14391. private static _rotationAxisCache;
  14392. /**
  14393. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14394. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14395. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14396. * The passed axis is also normalized.
  14397. * @param axis the axis to rotate around
  14398. * @param amount the amount to rotate in radians
  14399. * @param space Space to rotate in (Default: local)
  14400. * @returns the TransformNode.
  14401. */
  14402. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14403. /**
  14404. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14405. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14406. * The passed axis is also normalized. .
  14407. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14408. * @param point the point to rotate around
  14409. * @param axis the axis to rotate around
  14410. * @param amount the amount to rotate in radians
  14411. * @returns the TransformNode
  14412. */
  14413. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14414. /**
  14415. * Translates the mesh along the axis vector for the passed distance in the given space.
  14416. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14417. * @param axis the axis to translate in
  14418. * @param distance the distance to translate
  14419. * @param space Space to rotate in (Default: local)
  14420. * @returns the TransformNode.
  14421. */
  14422. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14423. /**
  14424. * Adds a rotation step to the mesh current rotation.
  14425. * x, y, z are Euler angles expressed in radians.
  14426. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14427. * This means this rotation is made in the mesh local space only.
  14428. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14429. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14430. * ```javascript
  14431. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14432. * ```
  14433. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14434. * 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.
  14435. * @param x Rotation to add
  14436. * @param y Rotation to add
  14437. * @param z Rotation to add
  14438. * @returns the TransformNode.
  14439. */
  14440. addRotation(x: number, y: number, z: number): TransformNode;
  14441. /**
  14442. * @hidden
  14443. */
  14444. protected _getEffectiveParent(): Nullable<Node>;
  14445. /**
  14446. * Computes the world matrix of the node
  14447. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14448. * @returns the world matrix
  14449. */
  14450. computeWorldMatrix(force?: boolean): Matrix;
  14451. protected _afterComputeWorldMatrix(): void;
  14452. /**
  14453. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14454. * @param func callback function to add
  14455. *
  14456. * @returns the TransformNode.
  14457. */
  14458. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14459. /**
  14460. * Removes a registered callback function.
  14461. * @param func callback function to remove
  14462. * @returns the TransformNode.
  14463. */
  14464. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14465. /**
  14466. * Gets the position of the current mesh in camera space
  14467. * @param camera defines the camera to use
  14468. * @returns a position
  14469. */
  14470. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14471. /**
  14472. * Returns the distance from the mesh to the active camera
  14473. * @param camera defines the camera to use
  14474. * @returns the distance
  14475. */
  14476. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14477. /**
  14478. * Clone the current transform node
  14479. * @param name Name of the new clone
  14480. * @param newParent New parent for the clone
  14481. * @param doNotCloneChildren Do not clone children hierarchy
  14482. * @returns the new transform node
  14483. */
  14484. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14485. /**
  14486. * Serializes the objects information.
  14487. * @param currentSerializationObject defines the object to serialize in
  14488. * @returns the serialized object
  14489. */
  14490. serialize(currentSerializationObject?: any): any;
  14491. /**
  14492. * Returns a new TransformNode object parsed from the source provided.
  14493. * @param parsedTransformNode is the source.
  14494. * @param scene the scne the object belongs to
  14495. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14496. * @returns a new TransformNode object parsed from the source provided.
  14497. */
  14498. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14499. /**
  14500. * Get all child-transformNodes of this node
  14501. * @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
  14502. * @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
  14503. * @returns an array of TransformNode
  14504. */
  14505. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14506. /**
  14507. * Releases resources associated with this transform node.
  14508. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14509. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14510. */
  14511. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14512. /**
  14513. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14514. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14515. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14516. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14517. * @returns the current mesh
  14518. */
  14519. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14520. private _syncAbsoluteScalingAndRotation;
  14521. }
  14522. }
  14523. declare module BABYLON {
  14524. /**
  14525. * Defines the types of pose enabled controllers that are supported
  14526. */
  14527. export enum PoseEnabledControllerType {
  14528. /**
  14529. * HTC Vive
  14530. */
  14531. VIVE = 0,
  14532. /**
  14533. * Oculus Rift
  14534. */
  14535. OCULUS = 1,
  14536. /**
  14537. * Windows mixed reality
  14538. */
  14539. WINDOWS = 2,
  14540. /**
  14541. * Samsung gear VR
  14542. */
  14543. GEAR_VR = 3,
  14544. /**
  14545. * Google Daydream
  14546. */
  14547. DAYDREAM = 4,
  14548. /**
  14549. * Generic
  14550. */
  14551. GENERIC = 5
  14552. }
  14553. /**
  14554. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14555. */
  14556. export interface MutableGamepadButton {
  14557. /**
  14558. * Value of the button/trigger
  14559. */
  14560. value: number;
  14561. /**
  14562. * If the button/trigger is currently touched
  14563. */
  14564. touched: boolean;
  14565. /**
  14566. * If the button/trigger is currently pressed
  14567. */
  14568. pressed: boolean;
  14569. }
  14570. /**
  14571. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14572. * @hidden
  14573. */
  14574. export interface ExtendedGamepadButton extends GamepadButton {
  14575. /**
  14576. * If the button/trigger is currently pressed
  14577. */
  14578. readonly pressed: boolean;
  14579. /**
  14580. * If the button/trigger is currently touched
  14581. */
  14582. readonly touched: boolean;
  14583. /**
  14584. * Value of the button/trigger
  14585. */
  14586. readonly value: number;
  14587. }
  14588. /** @hidden */
  14589. export interface _GamePadFactory {
  14590. /**
  14591. * Returns wether or not the current gamepad can be created for this type of controller.
  14592. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14593. * @returns true if it can be created, otherwise false
  14594. */
  14595. canCreate(gamepadInfo: any): boolean;
  14596. /**
  14597. * Creates a new instance of the Gamepad.
  14598. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14599. * @returns the new gamepad instance
  14600. */
  14601. create(gamepadInfo: any): Gamepad;
  14602. }
  14603. /**
  14604. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14605. */
  14606. export class PoseEnabledControllerHelper {
  14607. /** @hidden */
  14608. static _ControllerFactories: _GamePadFactory[];
  14609. /** @hidden */
  14610. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14611. /**
  14612. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14613. * @param vrGamepad the gamepad to initialized
  14614. * @returns a vr controller of the type the gamepad identified as
  14615. */
  14616. static InitiateController(vrGamepad: any): Gamepad;
  14617. }
  14618. /**
  14619. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14620. */
  14621. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14622. /**
  14623. * If the controller is used in a webXR session
  14624. */
  14625. isXR: boolean;
  14626. private _deviceRoomPosition;
  14627. private _deviceRoomRotationQuaternion;
  14628. /**
  14629. * The device position in babylon space
  14630. */
  14631. devicePosition: Vector3;
  14632. /**
  14633. * The device rotation in babylon space
  14634. */
  14635. deviceRotationQuaternion: Quaternion;
  14636. /**
  14637. * The scale factor of the device in babylon space
  14638. */
  14639. deviceScaleFactor: number;
  14640. /**
  14641. * (Likely devicePosition should be used instead) The device position in its room space
  14642. */
  14643. position: Vector3;
  14644. /**
  14645. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14646. */
  14647. rotationQuaternion: Quaternion;
  14648. /**
  14649. * The type of controller (Eg. Windows mixed reality)
  14650. */
  14651. controllerType: PoseEnabledControllerType;
  14652. protected _calculatedPosition: Vector3;
  14653. private _calculatedRotation;
  14654. /**
  14655. * The raw pose from the device
  14656. */
  14657. rawPose: DevicePose;
  14658. private _trackPosition;
  14659. private _maxRotationDistFromHeadset;
  14660. private _draggedRoomRotation;
  14661. /**
  14662. * @hidden
  14663. */
  14664. _disableTrackPosition(fixedPosition: Vector3): void;
  14665. /**
  14666. * Internal, the mesh attached to the controller
  14667. * @hidden
  14668. */
  14669. _mesh: Nullable<AbstractMesh>;
  14670. private _poseControlledCamera;
  14671. private _leftHandSystemQuaternion;
  14672. /**
  14673. * Internal, matrix used to convert room space to babylon space
  14674. * @hidden
  14675. */
  14676. _deviceToWorld: Matrix;
  14677. /**
  14678. * Node to be used when casting a ray from the controller
  14679. * @hidden
  14680. */
  14681. _pointingPoseNode: Nullable<TransformNode>;
  14682. /**
  14683. * Name of the child mesh that can be used to cast a ray from the controller
  14684. */
  14685. static readonly POINTING_POSE: string;
  14686. /**
  14687. * Creates a new PoseEnabledController from a gamepad
  14688. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14689. */
  14690. constructor(browserGamepad: any);
  14691. private _workingMatrix;
  14692. /**
  14693. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14694. */
  14695. update(): void;
  14696. /**
  14697. * Updates only the pose device and mesh without doing any button event checking
  14698. */
  14699. protected _updatePoseAndMesh(): void;
  14700. /**
  14701. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14702. * @param poseData raw pose fromthe device
  14703. */
  14704. updateFromDevice(poseData: DevicePose): void;
  14705. /**
  14706. * @hidden
  14707. */
  14708. _meshAttachedObservable: Observable<AbstractMesh>;
  14709. /**
  14710. * Attaches a mesh to the controller
  14711. * @param mesh the mesh to be attached
  14712. */
  14713. attachToMesh(mesh: AbstractMesh): void;
  14714. /**
  14715. * Attaches the controllers mesh to a camera
  14716. * @param camera the camera the mesh should be attached to
  14717. */
  14718. attachToPoseControlledCamera(camera: TargetCamera): void;
  14719. /**
  14720. * Disposes of the controller
  14721. */
  14722. dispose(): void;
  14723. /**
  14724. * The mesh that is attached to the controller
  14725. */
  14726. get mesh(): Nullable<AbstractMesh>;
  14727. /**
  14728. * Gets the ray of the controller in the direction the controller is pointing
  14729. * @param length the length the resulting ray should be
  14730. * @returns a ray in the direction the controller is pointing
  14731. */
  14732. getForwardRay(length?: number): Ray;
  14733. }
  14734. }
  14735. declare module BABYLON {
  14736. /**
  14737. * Defines the WebVRController object that represents controllers tracked in 3D space
  14738. */
  14739. export abstract class WebVRController extends PoseEnabledController {
  14740. /**
  14741. * Internal, the default controller model for the controller
  14742. */
  14743. protected _defaultModel: Nullable<AbstractMesh>;
  14744. /**
  14745. * Fired when the trigger state has changed
  14746. */
  14747. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14748. /**
  14749. * Fired when the main button state has changed
  14750. */
  14751. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14752. /**
  14753. * Fired when the secondary button state has changed
  14754. */
  14755. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14756. /**
  14757. * Fired when the pad state has changed
  14758. */
  14759. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14760. /**
  14761. * Fired when controllers stick values have changed
  14762. */
  14763. onPadValuesChangedObservable: Observable<StickValues>;
  14764. /**
  14765. * Array of button availible on the controller
  14766. */
  14767. protected _buttons: Array<MutableGamepadButton>;
  14768. private _onButtonStateChange;
  14769. /**
  14770. * Fired when a controller button's state has changed
  14771. * @param callback the callback containing the button that was modified
  14772. */
  14773. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14774. /**
  14775. * X and Y axis corresponding to the controllers joystick
  14776. */
  14777. pad: StickValues;
  14778. /**
  14779. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14780. */
  14781. hand: string;
  14782. /**
  14783. * The default controller model for the controller
  14784. */
  14785. get defaultModel(): Nullable<AbstractMesh>;
  14786. /**
  14787. * Creates a new WebVRController from a gamepad
  14788. * @param vrGamepad the gamepad that the WebVRController should be created from
  14789. */
  14790. constructor(vrGamepad: any);
  14791. /**
  14792. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14793. */
  14794. update(): void;
  14795. /**
  14796. * Function to be called when a button is modified
  14797. */
  14798. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14799. /**
  14800. * Loads a mesh and attaches it to the controller
  14801. * @param scene the scene the mesh should be added to
  14802. * @param meshLoaded callback for when the mesh has been loaded
  14803. */
  14804. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14805. private _setButtonValue;
  14806. private _changes;
  14807. private _checkChanges;
  14808. /**
  14809. * Disposes of th webVRCOntroller
  14810. */
  14811. dispose(): void;
  14812. }
  14813. }
  14814. declare module BABYLON {
  14815. /**
  14816. * The HemisphericLight simulates the ambient environment light,
  14817. * so the passed direction is the light reflection direction, not the incoming direction.
  14818. */
  14819. export class HemisphericLight extends Light {
  14820. /**
  14821. * The groundColor is the light in the opposite direction to the one specified during creation.
  14822. * 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.
  14823. */
  14824. groundColor: Color3;
  14825. /**
  14826. * The light reflection direction, not the incoming direction.
  14827. */
  14828. direction: Vector3;
  14829. /**
  14830. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14831. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14832. * The HemisphericLight can't cast shadows.
  14833. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14834. * @param name The friendly name of the light
  14835. * @param direction The direction of the light reflection
  14836. * @param scene The scene the light belongs to
  14837. */
  14838. constructor(name: string, direction: Vector3, scene: Scene);
  14839. protected _buildUniformLayout(): void;
  14840. /**
  14841. * Returns the string "HemisphericLight".
  14842. * @return The class name
  14843. */
  14844. getClassName(): string;
  14845. /**
  14846. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14847. * Returns the updated direction.
  14848. * @param target The target the direction should point to
  14849. * @return The computed direction
  14850. */
  14851. setDirectionToTarget(target: Vector3): Vector3;
  14852. /**
  14853. * Returns the shadow generator associated to the light.
  14854. * @returns Always null for hemispheric lights because it does not support shadows.
  14855. */
  14856. getShadowGenerator(): Nullable<IShadowGenerator>;
  14857. /**
  14858. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14859. * @param effect The effect to update
  14860. * @param lightIndex The index of the light in the effect to update
  14861. * @returns The hemispheric light
  14862. */
  14863. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14864. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  14865. /**
  14866. * Computes the world matrix of the node
  14867. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14868. * @param useWasUpdatedFlag defines a reserved property
  14869. * @returns the world matrix
  14870. */
  14871. computeWorldMatrix(): Matrix;
  14872. /**
  14873. * Returns the integer 3.
  14874. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14875. */
  14876. getTypeID(): number;
  14877. /**
  14878. * Prepares the list of defines specific to the light type.
  14879. * @param defines the list of defines
  14880. * @param lightIndex defines the index of the light for the effect
  14881. */
  14882. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14883. }
  14884. }
  14885. declare module BABYLON {
  14886. /** @hidden */
  14887. export var vrMultiviewToSingleviewPixelShader: {
  14888. name: string;
  14889. shader: string;
  14890. };
  14891. }
  14892. declare module BABYLON {
  14893. /**
  14894. * Renders to multiple views with a single draw call
  14895. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  14896. */
  14897. export class MultiviewRenderTarget extends RenderTargetTexture {
  14898. /**
  14899. * Creates a multiview render target
  14900. * @param scene scene used with the render target
  14901. * @param size the size of the render target (used for each view)
  14902. */
  14903. constructor(scene: Scene, size?: number | {
  14904. width: number;
  14905. height: number;
  14906. } | {
  14907. ratio: number;
  14908. });
  14909. /**
  14910. * @hidden
  14911. * @param faceIndex the face index, if its a cube texture
  14912. */
  14913. _bindFrameBuffer(faceIndex?: number): void;
  14914. /**
  14915. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  14916. * @returns the view count
  14917. */
  14918. getViewCount(): number;
  14919. }
  14920. }
  14921. declare module BABYLON {
  14922. /**
  14923. * Represents a camera frustum
  14924. */
  14925. export class Frustum {
  14926. /**
  14927. * Gets the planes representing the frustum
  14928. * @param transform matrix to be applied to the returned planes
  14929. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  14930. */
  14931. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  14932. /**
  14933. * Gets the near frustum plane transformed by the transform matrix
  14934. * @param transform transformation matrix to be applied to the resulting frustum plane
  14935. * @param frustumPlane the resuling frustum plane
  14936. */
  14937. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14938. /**
  14939. * Gets the far frustum plane transformed by the transform matrix
  14940. * @param transform transformation matrix to be applied to the resulting frustum plane
  14941. * @param frustumPlane the resuling frustum plane
  14942. */
  14943. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14944. /**
  14945. * Gets the left frustum plane transformed by the transform matrix
  14946. * @param transform transformation matrix to be applied to the resulting frustum plane
  14947. * @param frustumPlane the resuling frustum plane
  14948. */
  14949. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14950. /**
  14951. * Gets the right frustum plane transformed by the transform matrix
  14952. * @param transform transformation matrix to be applied to the resulting frustum plane
  14953. * @param frustumPlane the resuling frustum plane
  14954. */
  14955. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14956. /**
  14957. * Gets the top frustum plane transformed by the transform matrix
  14958. * @param transform transformation matrix to be applied to the resulting frustum plane
  14959. * @param frustumPlane the resuling frustum plane
  14960. */
  14961. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14962. /**
  14963. * Gets the bottom frustum plane transformed by the transform matrix
  14964. * @param transform transformation matrix to be applied to the resulting frustum plane
  14965. * @param frustumPlane the resuling frustum plane
  14966. */
  14967. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14968. /**
  14969. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  14970. * @param transform transformation matrix to be applied to the resulting frustum planes
  14971. * @param frustumPlanes the resuling frustum planes
  14972. */
  14973. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  14974. }
  14975. }
  14976. declare module BABYLON {
  14977. interface Engine {
  14978. /**
  14979. * Creates a new multiview render target
  14980. * @param width defines the width of the texture
  14981. * @param height defines the height of the texture
  14982. * @returns the created multiview texture
  14983. */
  14984. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  14985. /**
  14986. * Binds a multiview framebuffer to be drawn to
  14987. * @param multiviewTexture texture to bind
  14988. */
  14989. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  14990. }
  14991. interface Camera {
  14992. /**
  14993. * @hidden
  14994. * 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)
  14995. */
  14996. _useMultiviewToSingleView: boolean;
  14997. /**
  14998. * @hidden
  14999. * 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)
  15000. */
  15001. _multiviewTexture: Nullable<RenderTargetTexture>;
  15002. /**
  15003. * @hidden
  15004. * ensures the multiview texture of the camera exists and has the specified width/height
  15005. * @param width height to set on the multiview texture
  15006. * @param height width to set on the multiview texture
  15007. */
  15008. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  15009. }
  15010. interface Scene {
  15011. /** @hidden */
  15012. _transformMatrixR: Matrix;
  15013. /** @hidden */
  15014. _multiviewSceneUbo: Nullable<UniformBuffer>;
  15015. /** @hidden */
  15016. _createMultiviewUbo(): void;
  15017. /** @hidden */
  15018. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  15019. /** @hidden */
  15020. _renderMultiviewToSingleView(camera: Camera): void;
  15021. }
  15022. }
  15023. declare module BABYLON {
  15024. /**
  15025. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  15026. * This will not be used for webXR as it supports displaying texture arrays directly
  15027. */
  15028. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  15029. /**
  15030. * Initializes a VRMultiviewToSingleview
  15031. * @param name name of the post process
  15032. * @param camera camera to be applied to
  15033. * @param scaleFactor scaling factor to the size of the output texture
  15034. */
  15035. constructor(name: string, camera: Camera, scaleFactor: number);
  15036. }
  15037. }
  15038. declare module BABYLON {
  15039. /**
  15040. * Interface used to define additional presentation attributes
  15041. */
  15042. export interface IVRPresentationAttributes {
  15043. /**
  15044. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  15045. */
  15046. highRefreshRate: boolean;
  15047. /**
  15048. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  15049. */
  15050. foveationLevel: number;
  15051. }
  15052. interface Engine {
  15053. /** @hidden */
  15054. _vrDisplay: any;
  15055. /** @hidden */
  15056. _vrSupported: boolean;
  15057. /** @hidden */
  15058. _oldSize: Size;
  15059. /** @hidden */
  15060. _oldHardwareScaleFactor: number;
  15061. /** @hidden */
  15062. _vrExclusivePointerMode: boolean;
  15063. /** @hidden */
  15064. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  15065. /** @hidden */
  15066. _onVRDisplayPointerRestricted: () => void;
  15067. /** @hidden */
  15068. _onVRDisplayPointerUnrestricted: () => void;
  15069. /** @hidden */
  15070. _onVrDisplayConnect: Nullable<(display: any) => void>;
  15071. /** @hidden */
  15072. _onVrDisplayDisconnect: Nullable<() => void>;
  15073. /** @hidden */
  15074. _onVrDisplayPresentChange: Nullable<() => void>;
  15075. /**
  15076. * Observable signaled when VR display mode changes
  15077. */
  15078. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  15079. /**
  15080. * Observable signaled when VR request present is complete
  15081. */
  15082. onVRRequestPresentComplete: Observable<boolean>;
  15083. /**
  15084. * Observable signaled when VR request present starts
  15085. */
  15086. onVRRequestPresentStart: Observable<Engine>;
  15087. /**
  15088. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  15089. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  15090. */
  15091. isInVRExclusivePointerMode: boolean;
  15092. /**
  15093. * Gets a boolean indicating if a webVR device was detected
  15094. * @returns true if a webVR device was detected
  15095. */
  15096. isVRDevicePresent(): boolean;
  15097. /**
  15098. * Gets the current webVR device
  15099. * @returns the current webVR device (or null)
  15100. */
  15101. getVRDevice(): any;
  15102. /**
  15103. * Initializes a webVR display and starts listening to display change events
  15104. * The onVRDisplayChangedObservable will be notified upon these changes
  15105. * @returns A promise containing a VRDisplay and if vr is supported
  15106. */
  15107. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  15108. /** @hidden */
  15109. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  15110. /**
  15111. * Gets or sets the presentation attributes used to configure VR rendering
  15112. */
  15113. vrPresentationAttributes?: IVRPresentationAttributes;
  15114. /**
  15115. * Call this function to switch to webVR mode
  15116. * Will do nothing if webVR is not supported or if there is no webVR device
  15117. * @param options the webvr options provided to the camera. mainly used for multiview
  15118. * @see http://doc.babylonjs.com/how_to/webvr_camera
  15119. */
  15120. enableVR(options: WebVROptions): void;
  15121. /** @hidden */
  15122. _onVRFullScreenTriggered(): void;
  15123. }
  15124. }
  15125. declare module BABYLON {
  15126. /**
  15127. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  15128. * IMPORTANT!! The data is right-hand data.
  15129. * @export
  15130. * @interface DevicePose
  15131. */
  15132. export interface DevicePose {
  15133. /**
  15134. * The position of the device, values in array are [x,y,z].
  15135. */
  15136. readonly position: Nullable<Float32Array>;
  15137. /**
  15138. * The linearVelocity of the device, values in array are [x,y,z].
  15139. */
  15140. readonly linearVelocity: Nullable<Float32Array>;
  15141. /**
  15142. * The linearAcceleration of the device, values in array are [x,y,z].
  15143. */
  15144. readonly linearAcceleration: Nullable<Float32Array>;
  15145. /**
  15146. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  15147. */
  15148. readonly orientation: Nullable<Float32Array>;
  15149. /**
  15150. * The angularVelocity of the device, values in array are [x,y,z].
  15151. */
  15152. readonly angularVelocity: Nullable<Float32Array>;
  15153. /**
  15154. * The angularAcceleration of the device, values in array are [x,y,z].
  15155. */
  15156. readonly angularAcceleration: Nullable<Float32Array>;
  15157. }
  15158. /**
  15159. * Interface representing a pose controlled object in Babylon.
  15160. * A pose controlled object has both regular pose values as well as pose values
  15161. * from an external device such as a VR head mounted display
  15162. */
  15163. export interface PoseControlled {
  15164. /**
  15165. * The position of the object in babylon space.
  15166. */
  15167. position: Vector3;
  15168. /**
  15169. * The rotation quaternion of the object in babylon space.
  15170. */
  15171. rotationQuaternion: Quaternion;
  15172. /**
  15173. * The position of the device in babylon space.
  15174. */
  15175. devicePosition?: Vector3;
  15176. /**
  15177. * The rotation quaternion of the device in babylon space.
  15178. */
  15179. deviceRotationQuaternion: Quaternion;
  15180. /**
  15181. * The raw pose coming from the device.
  15182. */
  15183. rawPose: Nullable<DevicePose>;
  15184. /**
  15185. * The scale of the device to be used when translating from device space to babylon space.
  15186. */
  15187. deviceScaleFactor: number;
  15188. /**
  15189. * Updates the poseControlled values based on the input device pose.
  15190. * @param poseData the pose data to update the object with
  15191. */
  15192. updateFromDevice(poseData: DevicePose): void;
  15193. }
  15194. /**
  15195. * Set of options to customize the webVRCamera
  15196. */
  15197. export interface WebVROptions {
  15198. /**
  15199. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  15200. */
  15201. trackPosition?: boolean;
  15202. /**
  15203. * Sets the scale of the vrDevice in babylon space. (default: 1)
  15204. */
  15205. positionScale?: number;
  15206. /**
  15207. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  15208. */
  15209. displayName?: string;
  15210. /**
  15211. * Should the native controller meshes be initialized. (default: true)
  15212. */
  15213. controllerMeshes?: boolean;
  15214. /**
  15215. * Creating a default HemiLight only on controllers. (default: true)
  15216. */
  15217. defaultLightingOnControllers?: boolean;
  15218. /**
  15219. * If you don't want to use the default VR button of the helper. (default: false)
  15220. */
  15221. useCustomVRButton?: boolean;
  15222. /**
  15223. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  15224. */
  15225. customVRButton?: HTMLButtonElement;
  15226. /**
  15227. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  15228. */
  15229. rayLength?: number;
  15230. /**
  15231. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  15232. */
  15233. defaultHeight?: number;
  15234. /**
  15235. * If multiview should be used if availible (default: false)
  15236. */
  15237. useMultiview?: boolean;
  15238. }
  15239. /**
  15240. * This represents a WebVR camera.
  15241. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  15242. * @example http://doc.babylonjs.com/how_to/webvr_camera
  15243. */
  15244. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  15245. private webVROptions;
  15246. /**
  15247. * @hidden
  15248. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  15249. */
  15250. _vrDevice: any;
  15251. /**
  15252. * The rawPose of the vrDevice.
  15253. */
  15254. rawPose: Nullable<DevicePose>;
  15255. private _onVREnabled;
  15256. private _specsVersion;
  15257. private _attached;
  15258. private _frameData;
  15259. protected _descendants: Array<Node>;
  15260. private _deviceRoomPosition;
  15261. /** @hidden */
  15262. _deviceRoomRotationQuaternion: Quaternion;
  15263. private _standingMatrix;
  15264. /**
  15265. * Represents device position in babylon space.
  15266. */
  15267. devicePosition: Vector3;
  15268. /**
  15269. * Represents device rotation in babylon space.
  15270. */
  15271. deviceRotationQuaternion: Quaternion;
  15272. /**
  15273. * The scale of the device to be used when translating from device space to babylon space.
  15274. */
  15275. deviceScaleFactor: number;
  15276. private _deviceToWorld;
  15277. private _worldToDevice;
  15278. /**
  15279. * References to the webVR controllers for the vrDevice.
  15280. */
  15281. controllers: Array<WebVRController>;
  15282. /**
  15283. * Emits an event when a controller is attached.
  15284. */
  15285. onControllersAttachedObservable: Observable<WebVRController[]>;
  15286. /**
  15287. * Emits an event when a controller's mesh has been loaded;
  15288. */
  15289. onControllerMeshLoadedObservable: Observable<WebVRController>;
  15290. /**
  15291. * Emits an event when the HMD's pose has been updated.
  15292. */
  15293. onPoseUpdatedFromDeviceObservable: Observable<any>;
  15294. private _poseSet;
  15295. /**
  15296. * If the rig cameras be used as parent instead of this camera.
  15297. */
  15298. rigParenting: boolean;
  15299. private _lightOnControllers;
  15300. private _defaultHeight?;
  15301. /**
  15302. * Instantiates a WebVRFreeCamera.
  15303. * @param name The name of the WebVRFreeCamera
  15304. * @param position The starting anchor position for the camera
  15305. * @param scene The scene the camera belongs to
  15306. * @param webVROptions a set of customizable options for the webVRCamera
  15307. */
  15308. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  15309. /**
  15310. * Gets the device distance from the ground in meters.
  15311. * @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.
  15312. */
  15313. deviceDistanceToRoomGround(): number;
  15314. /**
  15315. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15316. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  15317. */
  15318. useStandingMatrix(callback?: (bool: boolean) => void): void;
  15319. /**
  15320. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15321. * @returns A promise with a boolean set to if the standing matrix is supported.
  15322. */
  15323. useStandingMatrixAsync(): Promise<boolean>;
  15324. /**
  15325. * Disposes the camera
  15326. */
  15327. dispose(): void;
  15328. /**
  15329. * Gets a vrController by name.
  15330. * @param name The name of the controller to retreive
  15331. * @returns the controller matching the name specified or null if not found
  15332. */
  15333. getControllerByName(name: string): Nullable<WebVRController>;
  15334. private _leftController;
  15335. /**
  15336. * The controller corresponding to the users left hand.
  15337. */
  15338. get leftController(): Nullable<WebVRController>;
  15339. private _rightController;
  15340. /**
  15341. * The controller corresponding to the users right hand.
  15342. */
  15343. get rightController(): Nullable<WebVRController>;
  15344. /**
  15345. * Casts a ray forward from the vrCamera's gaze.
  15346. * @param length Length of the ray (default: 100)
  15347. * @returns the ray corresponding to the gaze
  15348. */
  15349. getForwardRay(length?: number): Ray;
  15350. /**
  15351. * @hidden
  15352. * Updates the camera based on device's frame data
  15353. */
  15354. _checkInputs(): void;
  15355. /**
  15356. * Updates the poseControlled values based on the input device pose.
  15357. * @param poseData Pose coming from the device
  15358. */
  15359. updateFromDevice(poseData: DevicePose): void;
  15360. private _htmlElementAttached;
  15361. private _detachIfAttached;
  15362. /**
  15363. * WebVR's attach control will start broadcasting frames to the device.
  15364. * Note that in certain browsers (chrome for example) this function must be called
  15365. * within a user-interaction callback. Example:
  15366. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15367. *
  15368. * @param element html element to attach the vrDevice to
  15369. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15370. */
  15371. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15372. /**
  15373. * Detaches the camera from the html element and disables VR
  15374. *
  15375. * @param element html element to detach from
  15376. */
  15377. detachControl(element: HTMLElement): void;
  15378. /**
  15379. * @returns the name of this class
  15380. */
  15381. getClassName(): string;
  15382. /**
  15383. * Calls resetPose on the vrDisplay
  15384. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15385. */
  15386. resetToCurrentRotation(): void;
  15387. /**
  15388. * @hidden
  15389. * Updates the rig cameras (left and right eye)
  15390. */
  15391. _updateRigCameras(): void;
  15392. private _workingVector;
  15393. private _oneVector;
  15394. private _workingMatrix;
  15395. private updateCacheCalled;
  15396. private _correctPositionIfNotTrackPosition;
  15397. /**
  15398. * @hidden
  15399. * Updates the cached values of the camera
  15400. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15401. */
  15402. _updateCache(ignoreParentClass?: boolean): void;
  15403. /**
  15404. * @hidden
  15405. * Get current device position in babylon world
  15406. */
  15407. _computeDevicePosition(): void;
  15408. /**
  15409. * Updates the current device position and rotation in the babylon world
  15410. */
  15411. update(): void;
  15412. /**
  15413. * @hidden
  15414. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15415. * @returns an identity matrix
  15416. */
  15417. _getViewMatrix(): Matrix;
  15418. private _tmpMatrix;
  15419. /**
  15420. * This function is called by the two RIG cameras.
  15421. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15422. * @hidden
  15423. */
  15424. _getWebVRViewMatrix(): Matrix;
  15425. /** @hidden */
  15426. _getWebVRProjectionMatrix(): Matrix;
  15427. private _onGamepadConnectedObserver;
  15428. private _onGamepadDisconnectedObserver;
  15429. private _updateCacheWhenTrackingDisabledObserver;
  15430. /**
  15431. * Initializes the controllers and their meshes
  15432. */
  15433. initControllers(): void;
  15434. }
  15435. }
  15436. declare module BABYLON {
  15437. /**
  15438. * Size options for a post process
  15439. */
  15440. export type PostProcessOptions = {
  15441. width: number;
  15442. height: number;
  15443. };
  15444. /**
  15445. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15446. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15447. */
  15448. export class PostProcess {
  15449. /** Name of the PostProcess. */
  15450. name: string;
  15451. /**
  15452. * Gets or sets the unique id of the post process
  15453. */
  15454. uniqueId: number;
  15455. /**
  15456. * Width of the texture to apply the post process on
  15457. */
  15458. width: number;
  15459. /**
  15460. * Height of the texture to apply the post process on
  15461. */
  15462. height: number;
  15463. /**
  15464. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15465. * @hidden
  15466. */
  15467. _outputTexture: Nullable<InternalTexture>;
  15468. /**
  15469. * Sampling mode used by the shader
  15470. * See https://doc.babylonjs.com/classes/3.1/texture
  15471. */
  15472. renderTargetSamplingMode: number;
  15473. /**
  15474. * Clear color to use when screen clearing
  15475. */
  15476. clearColor: Color4;
  15477. /**
  15478. * If the buffer needs to be cleared before applying the post process. (default: true)
  15479. * Should be set to false if shader will overwrite all previous pixels.
  15480. */
  15481. autoClear: boolean;
  15482. /**
  15483. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15484. */
  15485. alphaMode: number;
  15486. /**
  15487. * Sets the setAlphaBlendConstants of the babylon engine
  15488. */
  15489. alphaConstants: Color4;
  15490. /**
  15491. * Animations to be used for the post processing
  15492. */
  15493. animations: Animation[];
  15494. /**
  15495. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15496. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15497. */
  15498. enablePixelPerfectMode: boolean;
  15499. /**
  15500. * Force the postprocess to be applied without taking in account viewport
  15501. */
  15502. forceFullscreenViewport: boolean;
  15503. /**
  15504. * List of inspectable custom properties (used by the Inspector)
  15505. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15506. */
  15507. inspectableCustomProperties: IInspectable[];
  15508. /**
  15509. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15510. *
  15511. * | Value | Type | Description |
  15512. * | ----- | ----------------------------------- | ----------- |
  15513. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15514. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15515. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15516. *
  15517. */
  15518. scaleMode: number;
  15519. /**
  15520. * Force textures to be a power of two (default: false)
  15521. */
  15522. alwaysForcePOT: boolean;
  15523. private _samples;
  15524. /**
  15525. * Number of sample textures (default: 1)
  15526. */
  15527. get samples(): number;
  15528. set samples(n: number);
  15529. /**
  15530. * Modify the scale of the post process to be the same as the viewport (default: false)
  15531. */
  15532. adaptScaleToCurrentViewport: boolean;
  15533. private _camera;
  15534. private _scene;
  15535. private _engine;
  15536. private _options;
  15537. private _reusable;
  15538. private _textureType;
  15539. /**
  15540. * Smart array of input and output textures for the post process.
  15541. * @hidden
  15542. */
  15543. _textures: SmartArray<InternalTexture>;
  15544. /**
  15545. * The index in _textures that corresponds to the output texture.
  15546. * @hidden
  15547. */
  15548. _currentRenderTextureInd: number;
  15549. private _effect;
  15550. private _samplers;
  15551. private _fragmentUrl;
  15552. private _vertexUrl;
  15553. private _parameters;
  15554. private _scaleRatio;
  15555. protected _indexParameters: any;
  15556. private _shareOutputWithPostProcess;
  15557. private _texelSize;
  15558. private _forcedOutputTexture;
  15559. /**
  15560. * Returns the fragment url or shader name used in the post process.
  15561. * @returns the fragment url or name in the shader store.
  15562. */
  15563. getEffectName(): string;
  15564. /**
  15565. * An event triggered when the postprocess is activated.
  15566. */
  15567. onActivateObservable: Observable<Camera>;
  15568. private _onActivateObserver;
  15569. /**
  15570. * A function that is added to the onActivateObservable
  15571. */
  15572. set onActivate(callback: Nullable<(camera: Camera) => void>);
  15573. /**
  15574. * An event triggered when the postprocess changes its size.
  15575. */
  15576. onSizeChangedObservable: Observable<PostProcess>;
  15577. private _onSizeChangedObserver;
  15578. /**
  15579. * A function that is added to the onSizeChangedObservable
  15580. */
  15581. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  15582. /**
  15583. * An event triggered when the postprocess applies its effect.
  15584. */
  15585. onApplyObservable: Observable<Effect>;
  15586. private _onApplyObserver;
  15587. /**
  15588. * A function that is added to the onApplyObservable
  15589. */
  15590. set onApply(callback: (effect: Effect) => void);
  15591. /**
  15592. * An event triggered before rendering the postprocess
  15593. */
  15594. onBeforeRenderObservable: Observable<Effect>;
  15595. private _onBeforeRenderObserver;
  15596. /**
  15597. * A function that is added to the onBeforeRenderObservable
  15598. */
  15599. set onBeforeRender(callback: (effect: Effect) => void);
  15600. /**
  15601. * An event triggered after rendering the postprocess
  15602. */
  15603. onAfterRenderObservable: Observable<Effect>;
  15604. private _onAfterRenderObserver;
  15605. /**
  15606. * A function that is added to the onAfterRenderObservable
  15607. */
  15608. set onAfterRender(callback: (efect: Effect) => void);
  15609. /**
  15610. * 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
  15611. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15612. */
  15613. get inputTexture(): InternalTexture;
  15614. set inputTexture(value: InternalTexture);
  15615. /**
  15616. * Gets the camera which post process is applied to.
  15617. * @returns The camera the post process is applied to.
  15618. */
  15619. getCamera(): Camera;
  15620. /**
  15621. * Gets the texel size of the postprocess.
  15622. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15623. */
  15624. get texelSize(): Vector2;
  15625. /**
  15626. * Creates a new instance PostProcess
  15627. * @param name The name of the PostProcess.
  15628. * @param fragmentUrl The url of the fragment shader to be used.
  15629. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15630. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15631. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15632. * @param camera The camera to apply the render pass to.
  15633. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15634. * @param engine The engine which the post process will be applied. (default: current engine)
  15635. * @param reusable If the post process can be reused on the same frame. (default: false)
  15636. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15637. * @param textureType Type of textures used when performing the post process. (default: 0)
  15638. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15639. * @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
  15640. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15641. */
  15642. constructor(
  15643. /** Name of the PostProcess. */
  15644. 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);
  15645. /**
  15646. * Gets a string idenfifying the name of the class
  15647. * @returns "PostProcess" string
  15648. */
  15649. getClassName(): string;
  15650. /**
  15651. * Gets the engine which this post process belongs to.
  15652. * @returns The engine the post process was enabled with.
  15653. */
  15654. getEngine(): Engine;
  15655. /**
  15656. * The effect that is created when initializing the post process.
  15657. * @returns The created effect corresponding the the postprocess.
  15658. */
  15659. getEffect(): Effect;
  15660. /**
  15661. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15662. * @param postProcess The post process to share the output with.
  15663. * @returns This post process.
  15664. */
  15665. shareOutputWith(postProcess: PostProcess): PostProcess;
  15666. /**
  15667. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15668. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15669. */
  15670. useOwnOutput(): void;
  15671. /**
  15672. * Updates the effect with the current post process compile time values and recompiles the shader.
  15673. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15674. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15675. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15676. * @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
  15677. * @param onCompiled Called when the shader has been compiled.
  15678. * @param onError Called if there is an error when compiling a shader.
  15679. */
  15680. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15681. /**
  15682. * The post process is reusable if it can be used multiple times within one frame.
  15683. * @returns If the post process is reusable
  15684. */
  15685. isReusable(): boolean;
  15686. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15687. markTextureDirty(): void;
  15688. /**
  15689. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15690. * 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.
  15691. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15692. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15693. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15694. * @returns The target texture that was bound to be written to.
  15695. */
  15696. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15697. /**
  15698. * If the post process is supported.
  15699. */
  15700. get isSupported(): boolean;
  15701. /**
  15702. * The aspect ratio of the output texture.
  15703. */
  15704. get aspectRatio(): number;
  15705. /**
  15706. * Get a value indicating if the post-process is ready to be used
  15707. * @returns true if the post-process is ready (shader is compiled)
  15708. */
  15709. isReady(): boolean;
  15710. /**
  15711. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15712. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15713. */
  15714. apply(): Nullable<Effect>;
  15715. private _disposeTextures;
  15716. /**
  15717. * Disposes the post process.
  15718. * @param camera The camera to dispose the post process on.
  15719. */
  15720. dispose(camera?: Camera): void;
  15721. }
  15722. }
  15723. declare module BABYLON {
  15724. /** @hidden */
  15725. export var kernelBlurVaryingDeclaration: {
  15726. name: string;
  15727. shader: string;
  15728. };
  15729. }
  15730. declare module BABYLON {
  15731. /** @hidden */
  15732. export var kernelBlurFragment: {
  15733. name: string;
  15734. shader: string;
  15735. };
  15736. }
  15737. declare module BABYLON {
  15738. /** @hidden */
  15739. export var kernelBlurFragment2: {
  15740. name: string;
  15741. shader: string;
  15742. };
  15743. }
  15744. declare module BABYLON {
  15745. /** @hidden */
  15746. export var kernelBlurPixelShader: {
  15747. name: string;
  15748. shader: string;
  15749. };
  15750. }
  15751. declare module BABYLON {
  15752. /** @hidden */
  15753. export var kernelBlurVertex: {
  15754. name: string;
  15755. shader: string;
  15756. };
  15757. }
  15758. declare module BABYLON {
  15759. /** @hidden */
  15760. export var kernelBlurVertexShader: {
  15761. name: string;
  15762. shader: string;
  15763. };
  15764. }
  15765. declare module BABYLON {
  15766. /**
  15767. * The Blur Post Process which blurs an image based on a kernel and direction.
  15768. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15769. */
  15770. export class BlurPostProcess extends PostProcess {
  15771. /** The direction in which to blur the image. */
  15772. direction: Vector2;
  15773. private blockCompilation;
  15774. protected _kernel: number;
  15775. protected _idealKernel: number;
  15776. protected _packedFloat: boolean;
  15777. private _staticDefines;
  15778. /**
  15779. * Sets the length in pixels of the blur sample region
  15780. */
  15781. set kernel(v: number);
  15782. /**
  15783. * Gets the length in pixels of the blur sample region
  15784. */
  15785. get kernel(): number;
  15786. /**
  15787. * Sets wether or not the blur needs to unpack/repack floats
  15788. */
  15789. set packedFloat(v: boolean);
  15790. /**
  15791. * Gets wether or not the blur is unpacking/repacking floats
  15792. */
  15793. get packedFloat(): boolean;
  15794. /**
  15795. * Creates a new instance BlurPostProcess
  15796. * @param name The name of the effect.
  15797. * @param direction The direction in which to blur the image.
  15798. * @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.
  15799. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15800. * @param camera The camera to apply the render pass to.
  15801. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15802. * @param engine The engine which the post process will be applied. (default: current engine)
  15803. * @param reusable If the post process can be reused on the same frame. (default: false)
  15804. * @param textureType Type of textures used when performing the post process. (default: 0)
  15805. * @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)
  15806. */
  15807. constructor(name: string,
  15808. /** The direction in which to blur the image. */
  15809. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15810. /**
  15811. * Updates the effect with the current post process compile time values and recompiles the shader.
  15812. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15813. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15814. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15815. * @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
  15816. * @param onCompiled Called when the shader has been compiled.
  15817. * @param onError Called if there is an error when compiling a shader.
  15818. */
  15819. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15820. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15821. /**
  15822. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15823. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15824. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15825. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15826. * The gaps between physical kernels are compensated for in the weighting of the samples
  15827. * @param idealKernel Ideal blur kernel.
  15828. * @return Nearest best kernel.
  15829. */
  15830. protected _nearestBestKernel(idealKernel: number): number;
  15831. /**
  15832. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15833. * @param x The point on the Gaussian distribution to sample.
  15834. * @return the value of the Gaussian function at x.
  15835. */
  15836. protected _gaussianWeight(x: number): number;
  15837. /**
  15838. * Generates a string that can be used as a floating point number in GLSL.
  15839. * @param x Value to print.
  15840. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15841. * @return GLSL float string.
  15842. */
  15843. protected _glslFloat(x: number, decimalFigures?: number): string;
  15844. }
  15845. }
  15846. declare module BABYLON {
  15847. /**
  15848. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15849. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15850. * You can then easily use it as a reflectionTexture on a flat surface.
  15851. * In case the surface is not a plane, please consider relying on reflection probes.
  15852. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15853. */
  15854. export class MirrorTexture extends RenderTargetTexture {
  15855. private scene;
  15856. /**
  15857. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  15858. * 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.
  15859. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15860. */
  15861. mirrorPlane: Plane;
  15862. /**
  15863. * Define the blur ratio used to blur the reflection if needed.
  15864. */
  15865. set blurRatio(value: number);
  15866. get blurRatio(): number;
  15867. /**
  15868. * Define the adaptive blur kernel used to blur the reflection if needed.
  15869. * This will autocompute the closest best match for the `blurKernel`
  15870. */
  15871. set adaptiveBlurKernel(value: number);
  15872. /**
  15873. * Define the blur kernel used to blur the reflection if needed.
  15874. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15875. */
  15876. set blurKernel(value: number);
  15877. /**
  15878. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  15879. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15880. */
  15881. set blurKernelX(value: number);
  15882. get blurKernelX(): number;
  15883. /**
  15884. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  15885. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15886. */
  15887. set blurKernelY(value: number);
  15888. get blurKernelY(): number;
  15889. private _autoComputeBlurKernel;
  15890. protected _onRatioRescale(): void;
  15891. private _updateGammaSpace;
  15892. private _imageProcessingConfigChangeObserver;
  15893. private _transformMatrix;
  15894. private _mirrorMatrix;
  15895. private _savedViewMatrix;
  15896. private _blurX;
  15897. private _blurY;
  15898. private _adaptiveBlurKernel;
  15899. private _blurKernelX;
  15900. private _blurKernelY;
  15901. private _blurRatio;
  15902. /**
  15903. * Instantiates a Mirror Texture.
  15904. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15905. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15906. * You can then easily use it as a reflectionTexture on a flat surface.
  15907. * In case the surface is not a plane, please consider relying on reflection probes.
  15908. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15909. * @param name
  15910. * @param size
  15911. * @param scene
  15912. * @param generateMipMaps
  15913. * @param type
  15914. * @param samplingMode
  15915. * @param generateDepthBuffer
  15916. */
  15917. constructor(name: string, size: number | {
  15918. width: number;
  15919. height: number;
  15920. } | {
  15921. ratio: number;
  15922. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  15923. private _preparePostProcesses;
  15924. /**
  15925. * Clone the mirror texture.
  15926. * @returns the cloned texture
  15927. */
  15928. clone(): MirrorTexture;
  15929. /**
  15930. * Serialize the texture to a JSON representation you could use in Parse later on
  15931. * @returns the serialized JSON representation
  15932. */
  15933. serialize(): any;
  15934. /**
  15935. * Dispose the texture and release its associated resources.
  15936. */
  15937. dispose(): void;
  15938. }
  15939. }
  15940. declare module BABYLON {
  15941. /**
  15942. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15943. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15944. */
  15945. export class Texture extends BaseTexture {
  15946. /**
  15947. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  15948. */
  15949. static SerializeBuffers: boolean;
  15950. /** @hidden */
  15951. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  15952. /** @hidden */
  15953. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  15954. /** @hidden */
  15955. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  15956. /** nearest is mag = nearest and min = nearest and mip = linear */
  15957. static readonly NEAREST_SAMPLINGMODE: number;
  15958. /** nearest is mag = nearest and min = nearest and mip = linear */
  15959. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  15960. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15961. static readonly BILINEAR_SAMPLINGMODE: number;
  15962. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15963. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  15964. /** Trilinear is mag = linear and min = linear and mip = linear */
  15965. static readonly TRILINEAR_SAMPLINGMODE: number;
  15966. /** Trilinear is mag = linear and min = linear and mip = linear */
  15967. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  15968. /** mag = nearest and min = nearest and mip = nearest */
  15969. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  15970. /** mag = nearest and min = linear and mip = nearest */
  15971. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  15972. /** mag = nearest and min = linear and mip = linear */
  15973. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  15974. /** mag = nearest and min = linear and mip = none */
  15975. static readonly NEAREST_LINEAR: number;
  15976. /** mag = nearest and min = nearest and mip = none */
  15977. static readonly NEAREST_NEAREST: number;
  15978. /** mag = linear and min = nearest and mip = nearest */
  15979. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  15980. /** mag = linear and min = nearest and mip = linear */
  15981. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  15982. /** mag = linear and min = linear and mip = none */
  15983. static readonly LINEAR_LINEAR: number;
  15984. /** mag = linear and min = nearest and mip = none */
  15985. static readonly LINEAR_NEAREST: number;
  15986. /** Explicit coordinates mode */
  15987. static readonly EXPLICIT_MODE: number;
  15988. /** Spherical coordinates mode */
  15989. static readonly SPHERICAL_MODE: number;
  15990. /** Planar coordinates mode */
  15991. static readonly PLANAR_MODE: number;
  15992. /** Cubic coordinates mode */
  15993. static readonly CUBIC_MODE: number;
  15994. /** Projection coordinates mode */
  15995. static readonly PROJECTION_MODE: number;
  15996. /** Inverse Cubic coordinates mode */
  15997. static readonly SKYBOX_MODE: number;
  15998. /** Inverse Cubic coordinates mode */
  15999. static readonly INVCUBIC_MODE: number;
  16000. /** Equirectangular coordinates mode */
  16001. static readonly EQUIRECTANGULAR_MODE: number;
  16002. /** Equirectangular Fixed coordinates mode */
  16003. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  16004. /** Equirectangular Fixed Mirrored coordinates mode */
  16005. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  16006. /** Texture is not repeating outside of 0..1 UVs */
  16007. static readonly CLAMP_ADDRESSMODE: number;
  16008. /** Texture is repeating outside of 0..1 UVs */
  16009. static readonly WRAP_ADDRESSMODE: number;
  16010. /** Texture is repeating and mirrored */
  16011. static readonly MIRROR_ADDRESSMODE: number;
  16012. /**
  16013. * 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
  16014. */
  16015. static UseSerializedUrlIfAny: boolean;
  16016. /**
  16017. * Define the url of the texture.
  16018. */
  16019. url: Nullable<string>;
  16020. /**
  16021. * Define an offset on the texture to offset the u coordinates of the UVs
  16022. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16023. */
  16024. uOffset: number;
  16025. /**
  16026. * Define an offset on the texture to offset the v coordinates of the UVs
  16027. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16028. */
  16029. vOffset: number;
  16030. /**
  16031. * Define an offset on the texture to scale the u coordinates of the UVs
  16032. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16033. */
  16034. uScale: number;
  16035. /**
  16036. * Define an offset on the texture to scale the v coordinates of the UVs
  16037. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16038. */
  16039. vScale: number;
  16040. /**
  16041. * Define an offset on the texture to rotate around the u coordinates of the UVs
  16042. * @see http://doc.babylonjs.com/how_to/more_materials
  16043. */
  16044. uAng: number;
  16045. /**
  16046. * Define an offset on the texture to rotate around the v coordinates of the UVs
  16047. * @see http://doc.babylonjs.com/how_to/more_materials
  16048. */
  16049. vAng: number;
  16050. /**
  16051. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  16052. * @see http://doc.babylonjs.com/how_to/more_materials
  16053. */
  16054. wAng: number;
  16055. /**
  16056. * Defines the center of rotation (U)
  16057. */
  16058. uRotationCenter: number;
  16059. /**
  16060. * Defines the center of rotation (V)
  16061. */
  16062. vRotationCenter: number;
  16063. /**
  16064. * Defines the center of rotation (W)
  16065. */
  16066. wRotationCenter: number;
  16067. /**
  16068. * Are mip maps generated for this texture or not.
  16069. */
  16070. get noMipmap(): boolean;
  16071. /**
  16072. * List of inspectable custom properties (used by the Inspector)
  16073. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16074. */
  16075. inspectableCustomProperties: Nullable<IInspectable[]>;
  16076. private _noMipmap;
  16077. /** @hidden */
  16078. _invertY: boolean;
  16079. private _rowGenerationMatrix;
  16080. private _cachedTextureMatrix;
  16081. private _projectionModeMatrix;
  16082. private _t0;
  16083. private _t1;
  16084. private _t2;
  16085. private _cachedUOffset;
  16086. private _cachedVOffset;
  16087. private _cachedUScale;
  16088. private _cachedVScale;
  16089. private _cachedUAng;
  16090. private _cachedVAng;
  16091. private _cachedWAng;
  16092. private _cachedProjectionMatrixId;
  16093. private _cachedCoordinatesMode;
  16094. /** @hidden */
  16095. protected _initialSamplingMode: number;
  16096. /** @hidden */
  16097. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  16098. private _deleteBuffer;
  16099. protected _format: Nullable<number>;
  16100. private _delayedOnLoad;
  16101. private _delayedOnError;
  16102. private _mimeType?;
  16103. /**
  16104. * Observable triggered once the texture has been loaded.
  16105. */
  16106. onLoadObservable: Observable<Texture>;
  16107. protected _isBlocking: boolean;
  16108. /**
  16109. * Is the texture preventing material to render while loading.
  16110. * If false, a default texture will be used instead of the loading one during the preparation step.
  16111. */
  16112. set isBlocking(value: boolean);
  16113. get isBlocking(): boolean;
  16114. /**
  16115. * Get the current sampling mode associated with the texture.
  16116. */
  16117. get samplingMode(): number;
  16118. /**
  16119. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  16120. */
  16121. get invertY(): boolean;
  16122. /**
  16123. * Instantiates a new texture.
  16124. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16125. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16126. * @param url defines the url of the picture to load as a texture
  16127. * @param scene defines the scene or engine the texture will belong to
  16128. * @param noMipmap defines if the texture will require mip maps or not
  16129. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  16130. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16131. * @param onLoad defines a callback triggered when the texture has been loaded
  16132. * @param onError defines a callback triggered when an error occurred during the loading session
  16133. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  16134. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  16135. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16136. * @param mimeType defines an optional mime type information
  16137. */
  16138. 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);
  16139. /**
  16140. * Update the url (and optional buffer) of this texture if url was null during construction.
  16141. * @param url the url of the texture
  16142. * @param buffer the buffer of the texture (defaults to null)
  16143. * @param onLoad callback called when the texture is loaded (defaults to null)
  16144. */
  16145. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  16146. /**
  16147. * Finish the loading sequence of a texture flagged as delayed load.
  16148. * @hidden
  16149. */
  16150. delayLoad(): void;
  16151. private _prepareRowForTextureGeneration;
  16152. /**
  16153. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  16154. * @returns the transform matrix of the texture.
  16155. */
  16156. getTextureMatrix(uBase?: number): Matrix;
  16157. /**
  16158. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  16159. * @returns The reflection texture transform
  16160. */
  16161. getReflectionTextureMatrix(): Matrix;
  16162. /**
  16163. * Clones the texture.
  16164. * @returns the cloned texture
  16165. */
  16166. clone(): Texture;
  16167. /**
  16168. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  16169. * @returns The JSON representation of the texture
  16170. */
  16171. serialize(): any;
  16172. /**
  16173. * Get the current class name of the texture useful for serialization or dynamic coding.
  16174. * @returns "Texture"
  16175. */
  16176. getClassName(): string;
  16177. /**
  16178. * Dispose the texture and release its associated resources.
  16179. */
  16180. dispose(): void;
  16181. /**
  16182. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  16183. * @param parsedTexture Define the JSON representation of the texture
  16184. * @param scene Define the scene the parsed texture should be instantiated in
  16185. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  16186. * @returns The parsed texture if successful
  16187. */
  16188. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  16189. /**
  16190. * Creates a texture from its base 64 representation.
  16191. * @param data Define the base64 payload without the data: prefix
  16192. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16193. * @param scene Define the scene the texture should belong to
  16194. * @param noMipmap Forces the texture to not create mip map information if true
  16195. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16196. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16197. * @param onLoad define a callback triggered when the texture has been loaded
  16198. * @param onError define a callback triggered when an error occurred during the loading session
  16199. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16200. * @returns the created texture
  16201. */
  16202. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  16203. /**
  16204. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  16205. * @param data Define the base64 payload without the data: prefix
  16206. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16207. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16208. * @param scene Define the scene the texture should belong to
  16209. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16210. * @param noMipmap Forces the texture to not create mip map information if true
  16211. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16212. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16213. * @param onLoad define a callback triggered when the texture has been loaded
  16214. * @param onError define a callback triggered when an error occurred during the loading session
  16215. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16216. * @returns the created texture
  16217. */
  16218. 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;
  16219. }
  16220. }
  16221. declare module BABYLON {
  16222. /**
  16223. * PostProcessManager is used to manage one or more post processes or post process pipelines
  16224. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  16225. */
  16226. export class PostProcessManager {
  16227. private _scene;
  16228. private _indexBuffer;
  16229. private _vertexBuffers;
  16230. /**
  16231. * Creates a new instance PostProcess
  16232. * @param scene The scene that the post process is associated with.
  16233. */
  16234. constructor(scene: Scene);
  16235. private _prepareBuffers;
  16236. private _buildIndexBuffer;
  16237. /**
  16238. * Rebuilds the vertex buffers of the manager.
  16239. * @hidden
  16240. */
  16241. _rebuild(): void;
  16242. /**
  16243. * Prepares a frame to be run through a post process.
  16244. * @param sourceTexture The input texture to the post procesess. (default: null)
  16245. * @param postProcesses An array of post processes to be run. (default: null)
  16246. * @returns True if the post processes were able to be run.
  16247. * @hidden
  16248. */
  16249. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  16250. /**
  16251. * Manually render a set of post processes to a texture.
  16252. * @param postProcesses An array of post processes to be run.
  16253. * @param targetTexture The target texture to render to.
  16254. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  16255. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  16256. * @param lodLevel defines which lod of the texture to render to
  16257. */
  16258. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  16259. /**
  16260. * Finalize the result of the output of the postprocesses.
  16261. * @param doNotPresent If true the result will not be displayed to the screen.
  16262. * @param targetTexture The target texture to render to.
  16263. * @param faceIndex The index of the face to bind the target texture to.
  16264. * @param postProcesses The array of post processes to render.
  16265. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  16266. * @hidden
  16267. */
  16268. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  16269. /**
  16270. * Disposes of the post process manager.
  16271. */
  16272. dispose(): void;
  16273. }
  16274. }
  16275. declare module BABYLON {
  16276. /** Interface used by value gradients (color, factor, ...) */
  16277. export interface IValueGradient {
  16278. /**
  16279. * Gets or sets the gradient value (between 0 and 1)
  16280. */
  16281. gradient: number;
  16282. }
  16283. /** Class used to store color4 gradient */
  16284. export class ColorGradient implements IValueGradient {
  16285. /**
  16286. * Gets or sets the gradient value (between 0 and 1)
  16287. */
  16288. gradient: number;
  16289. /**
  16290. * Gets or sets first associated color
  16291. */
  16292. color1: Color4;
  16293. /**
  16294. * Gets or sets second associated color
  16295. */
  16296. color2?: Color4;
  16297. /**
  16298. * Will get a color picked randomly between color1 and color2.
  16299. * If color2 is undefined then color1 will be used
  16300. * @param result defines the target Color4 to store the result in
  16301. */
  16302. getColorToRef(result: Color4): void;
  16303. }
  16304. /** Class used to store color 3 gradient */
  16305. export class Color3Gradient implements IValueGradient {
  16306. /**
  16307. * Gets or sets the gradient value (between 0 and 1)
  16308. */
  16309. gradient: number;
  16310. /**
  16311. * Gets or sets the associated color
  16312. */
  16313. color: Color3;
  16314. }
  16315. /** Class used to store factor gradient */
  16316. export class FactorGradient implements IValueGradient {
  16317. /**
  16318. * Gets or sets the gradient value (between 0 and 1)
  16319. */
  16320. gradient: number;
  16321. /**
  16322. * Gets or sets first associated factor
  16323. */
  16324. factor1: number;
  16325. /**
  16326. * Gets or sets second associated factor
  16327. */
  16328. factor2?: number;
  16329. /**
  16330. * Will get a number picked randomly between factor1 and factor2.
  16331. * If factor2 is undefined then factor1 will be used
  16332. * @returns the picked number
  16333. */
  16334. getFactor(): number;
  16335. }
  16336. /**
  16337. * Helper used to simplify some generic gradient tasks
  16338. */
  16339. export class GradientHelper {
  16340. /**
  16341. * Gets the current gradient from an array of IValueGradient
  16342. * @param ratio defines the current ratio to get
  16343. * @param gradients defines the array of IValueGradient
  16344. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  16345. */
  16346. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  16347. }
  16348. }
  16349. declare module BABYLON {
  16350. interface ThinEngine {
  16351. /**
  16352. * Creates a dynamic texture
  16353. * @param width defines the width of the texture
  16354. * @param height defines the height of the texture
  16355. * @param generateMipMaps defines if the engine should generate the mip levels
  16356. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  16357. * @returns the dynamic texture inside an InternalTexture
  16358. */
  16359. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  16360. /**
  16361. * Update the content of a dynamic texture
  16362. * @param texture defines the texture to update
  16363. * @param canvas defines the canvas containing the source
  16364. * @param invertY defines if data must be stored with Y axis inverted
  16365. * @param premulAlpha defines if alpha is stored as premultiplied
  16366. * @param format defines the format of the data
  16367. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  16368. */
  16369. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  16370. }
  16371. }
  16372. declare module BABYLON {
  16373. /**
  16374. * Helper class used to generate a canvas to manipulate images
  16375. */
  16376. export class CanvasGenerator {
  16377. /**
  16378. * Create a new canvas (or offscreen canvas depending on the context)
  16379. * @param width defines the expected width
  16380. * @param height defines the expected height
  16381. * @return a new canvas or offscreen canvas
  16382. */
  16383. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  16384. }
  16385. }
  16386. declare module BABYLON {
  16387. /**
  16388. * A class extending Texture allowing drawing on a texture
  16389. * @see http://doc.babylonjs.com/how_to/dynamictexture
  16390. */
  16391. export class DynamicTexture extends Texture {
  16392. private _generateMipMaps;
  16393. private _canvas;
  16394. private _context;
  16395. private _engine;
  16396. /**
  16397. * Creates a DynamicTexture
  16398. * @param name defines the name of the texture
  16399. * @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
  16400. * @param scene defines the scene where you want the texture
  16401. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  16402. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  16403. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  16404. */
  16405. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  16406. /**
  16407. * Get the current class name of the texture useful for serialization or dynamic coding.
  16408. * @returns "DynamicTexture"
  16409. */
  16410. getClassName(): string;
  16411. /**
  16412. * Gets the current state of canRescale
  16413. */
  16414. get canRescale(): boolean;
  16415. private _recreate;
  16416. /**
  16417. * Scales the texture
  16418. * @param ratio the scale factor to apply to both width and height
  16419. */
  16420. scale(ratio: number): void;
  16421. /**
  16422. * Resizes the texture
  16423. * @param width the new width
  16424. * @param height the new height
  16425. */
  16426. scaleTo(width: number, height: number): void;
  16427. /**
  16428. * Gets the context of the canvas used by the texture
  16429. * @returns the canvas context of the dynamic texture
  16430. */
  16431. getContext(): CanvasRenderingContext2D;
  16432. /**
  16433. * Clears the texture
  16434. */
  16435. clear(): void;
  16436. /**
  16437. * Updates the texture
  16438. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16439. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  16440. */
  16441. update(invertY?: boolean, premulAlpha?: boolean): void;
  16442. /**
  16443. * Draws text onto the texture
  16444. * @param text defines the text to be drawn
  16445. * @param x defines the placement of the text from the left
  16446. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  16447. * @param font defines the font to be used with font-style, font-size, font-name
  16448. * @param color defines the color used for the text
  16449. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  16450. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16451. * @param update defines whether texture is immediately update (default is true)
  16452. */
  16453. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  16454. /**
  16455. * Clones the texture
  16456. * @returns the clone of the texture.
  16457. */
  16458. clone(): DynamicTexture;
  16459. /**
  16460. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  16461. * @returns a serialized dynamic texture object
  16462. */
  16463. serialize(): any;
  16464. /** @hidden */
  16465. _rebuild(): void;
  16466. }
  16467. }
  16468. declare module BABYLON {
  16469. interface AbstractScene {
  16470. /**
  16471. * The list of procedural textures added to the scene
  16472. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16473. */
  16474. proceduralTextures: Array<ProceduralTexture>;
  16475. }
  16476. /**
  16477. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16478. * in a given scene.
  16479. */
  16480. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16481. /**
  16482. * The component name helpfull to identify the component in the list of scene components.
  16483. */
  16484. readonly name: string;
  16485. /**
  16486. * The scene the component belongs to.
  16487. */
  16488. scene: Scene;
  16489. /**
  16490. * Creates a new instance of the component for the given scene
  16491. * @param scene Defines the scene to register the component in
  16492. */
  16493. constructor(scene: Scene);
  16494. /**
  16495. * Registers the component in a given scene
  16496. */
  16497. register(): void;
  16498. /**
  16499. * Rebuilds the elements related to this component in case of
  16500. * context lost for instance.
  16501. */
  16502. rebuild(): void;
  16503. /**
  16504. * Disposes the component and the associated ressources.
  16505. */
  16506. dispose(): void;
  16507. private _beforeClear;
  16508. }
  16509. }
  16510. declare module BABYLON {
  16511. interface ThinEngine {
  16512. /**
  16513. * Creates a new render target cube texture
  16514. * @param size defines the size of the texture
  16515. * @param options defines the options used to create the texture
  16516. * @returns a new render target cube texture stored in an InternalTexture
  16517. */
  16518. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16519. }
  16520. }
  16521. declare module BABYLON {
  16522. /** @hidden */
  16523. export var proceduralVertexShader: {
  16524. name: string;
  16525. shader: string;
  16526. };
  16527. }
  16528. declare module BABYLON {
  16529. /**
  16530. * 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.
  16531. * This is the base class of any Procedural texture and contains most of the shareable code.
  16532. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16533. */
  16534. export class ProceduralTexture extends Texture {
  16535. isCube: boolean;
  16536. /**
  16537. * Define if the texture is enabled or not (disabled texture will not render)
  16538. */
  16539. isEnabled: boolean;
  16540. /**
  16541. * Define if the texture must be cleared before rendering (default is true)
  16542. */
  16543. autoClear: boolean;
  16544. /**
  16545. * Callback called when the texture is generated
  16546. */
  16547. onGenerated: () => void;
  16548. /**
  16549. * Event raised when the texture is generated
  16550. */
  16551. onGeneratedObservable: Observable<ProceduralTexture>;
  16552. /** @hidden */
  16553. _generateMipMaps: boolean;
  16554. /** @hidden **/
  16555. _effect: Effect;
  16556. /** @hidden */
  16557. _textures: {
  16558. [key: string]: Texture;
  16559. };
  16560. private _size;
  16561. private _currentRefreshId;
  16562. private _frameId;
  16563. private _refreshRate;
  16564. private _vertexBuffers;
  16565. private _indexBuffer;
  16566. private _uniforms;
  16567. private _samplers;
  16568. private _fragment;
  16569. private _floats;
  16570. private _ints;
  16571. private _floatsArrays;
  16572. private _colors3;
  16573. private _colors4;
  16574. private _vectors2;
  16575. private _vectors3;
  16576. private _matrices;
  16577. private _fallbackTexture;
  16578. private _fallbackTextureUsed;
  16579. private _engine;
  16580. private _cachedDefines;
  16581. private _contentUpdateId;
  16582. private _contentData;
  16583. /**
  16584. * Instantiates a new procedural texture.
  16585. * 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.
  16586. * This is the base class of any Procedural texture and contains most of the shareable code.
  16587. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16588. * @param name Define the name of the texture
  16589. * @param size Define the size of the texture to create
  16590. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16591. * @param scene Define the scene the texture belongs to
  16592. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16593. * @param generateMipMaps Define if the texture should creates mip maps or not
  16594. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16595. */
  16596. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16597. /**
  16598. * The effect that is created when initializing the post process.
  16599. * @returns The created effect corresponding the the postprocess.
  16600. */
  16601. getEffect(): Effect;
  16602. /**
  16603. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16604. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16605. */
  16606. getContent(): Nullable<ArrayBufferView>;
  16607. private _createIndexBuffer;
  16608. /** @hidden */
  16609. _rebuild(): void;
  16610. /**
  16611. * Resets the texture in order to recreate its associated resources.
  16612. * This can be called in case of context loss
  16613. */
  16614. reset(): void;
  16615. protected _getDefines(): string;
  16616. /**
  16617. * Is the texture ready to be used ? (rendered at least once)
  16618. * @returns true if ready, otherwise, false.
  16619. */
  16620. isReady(): boolean;
  16621. /**
  16622. * Resets the refresh counter of the texture and start bak from scratch.
  16623. * Could be useful to regenerate the texture if it is setup to render only once.
  16624. */
  16625. resetRefreshCounter(): void;
  16626. /**
  16627. * Set the fragment shader to use in order to render the texture.
  16628. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16629. */
  16630. setFragment(fragment: any): void;
  16631. /**
  16632. * Define the refresh rate of the texture or the rendering frequency.
  16633. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16634. */
  16635. get refreshRate(): number;
  16636. set refreshRate(value: number);
  16637. /** @hidden */
  16638. _shouldRender(): boolean;
  16639. /**
  16640. * Get the size the texture is rendering at.
  16641. * @returns the size (texture is always squared)
  16642. */
  16643. getRenderSize(): number;
  16644. /**
  16645. * Resize the texture to new value.
  16646. * @param size Define the new size the texture should have
  16647. * @param generateMipMaps Define whether the new texture should create mip maps
  16648. */
  16649. resize(size: number, generateMipMaps: boolean): void;
  16650. private _checkUniform;
  16651. /**
  16652. * Set a texture in the shader program used to render.
  16653. * @param name Define the name of the uniform samplers as defined in the shader
  16654. * @param texture Define the texture to bind to this sampler
  16655. * @return the texture itself allowing "fluent" like uniform updates
  16656. */
  16657. setTexture(name: string, texture: Texture): ProceduralTexture;
  16658. /**
  16659. * Set a float in the shader.
  16660. * @param name Define the name of the uniform as defined in the shader
  16661. * @param value Define the value to give to the uniform
  16662. * @return the texture itself allowing "fluent" like uniform updates
  16663. */
  16664. setFloat(name: string, value: number): ProceduralTexture;
  16665. /**
  16666. * Set a int in the shader.
  16667. * @param name Define the name of the uniform as defined in the shader
  16668. * @param value Define the value to give to the uniform
  16669. * @return the texture itself allowing "fluent" like uniform updates
  16670. */
  16671. setInt(name: string, value: number): ProceduralTexture;
  16672. /**
  16673. * Set an array of floats in the shader.
  16674. * @param name Define the name of the uniform as defined in the shader
  16675. * @param value Define the value to give to the uniform
  16676. * @return the texture itself allowing "fluent" like uniform updates
  16677. */
  16678. setFloats(name: string, value: number[]): ProceduralTexture;
  16679. /**
  16680. * Set a vec3 in the shader from a Color3.
  16681. * @param name Define the name of the uniform as defined in the shader
  16682. * @param value Define the value to give to the uniform
  16683. * @return the texture itself allowing "fluent" like uniform updates
  16684. */
  16685. setColor3(name: string, value: Color3): ProceduralTexture;
  16686. /**
  16687. * Set a vec4 in the shader from a Color4.
  16688. * @param name Define the name of the uniform as defined in the shader
  16689. * @param value Define the value to give to the uniform
  16690. * @return the texture itself allowing "fluent" like uniform updates
  16691. */
  16692. setColor4(name: string, value: Color4): ProceduralTexture;
  16693. /**
  16694. * Set a vec2 in the shader from a Vector2.
  16695. * @param name Define the name of the uniform as defined in the shader
  16696. * @param value Define the value to give to the uniform
  16697. * @return the texture itself allowing "fluent" like uniform updates
  16698. */
  16699. setVector2(name: string, value: Vector2): ProceduralTexture;
  16700. /**
  16701. * Set a vec3 in the shader from a Vector3.
  16702. * @param name Define the name of the uniform as defined in the shader
  16703. * @param value Define the value to give to the uniform
  16704. * @return the texture itself allowing "fluent" like uniform updates
  16705. */
  16706. setVector3(name: string, value: Vector3): ProceduralTexture;
  16707. /**
  16708. * Set a mat4 in the shader from a MAtrix.
  16709. * @param name Define the name of the uniform as defined in the shader
  16710. * @param value Define the value to give to the uniform
  16711. * @return the texture itself allowing "fluent" like uniform updates
  16712. */
  16713. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16714. /**
  16715. * Render the texture to its associated render target.
  16716. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16717. */
  16718. render(useCameraPostProcess?: boolean): void;
  16719. /**
  16720. * Clone the texture.
  16721. * @returns the cloned texture
  16722. */
  16723. clone(): ProceduralTexture;
  16724. /**
  16725. * Dispose the texture and release its asoociated resources.
  16726. */
  16727. dispose(): void;
  16728. }
  16729. }
  16730. declare module BABYLON {
  16731. /**
  16732. * This represents the base class for particle system in Babylon.
  16733. * 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.
  16734. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16735. * @example https://doc.babylonjs.com/babylon101/particles
  16736. */
  16737. export class BaseParticleSystem {
  16738. /**
  16739. * Source color is added to the destination color without alpha affecting the result
  16740. */
  16741. static BLENDMODE_ONEONE: number;
  16742. /**
  16743. * Blend current color and particle color using particle’s alpha
  16744. */
  16745. static BLENDMODE_STANDARD: number;
  16746. /**
  16747. * Add current color and particle color multiplied by particle’s alpha
  16748. */
  16749. static BLENDMODE_ADD: number;
  16750. /**
  16751. * Multiply current color with particle color
  16752. */
  16753. static BLENDMODE_MULTIPLY: number;
  16754. /**
  16755. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16756. */
  16757. static BLENDMODE_MULTIPLYADD: number;
  16758. /**
  16759. * List of animations used by the particle system.
  16760. */
  16761. animations: Animation[];
  16762. /**
  16763. * The id of the Particle system.
  16764. */
  16765. id: string;
  16766. /**
  16767. * The friendly name of the Particle system.
  16768. */
  16769. name: string;
  16770. /**
  16771. * The rendering group used by the Particle system to chose when to render.
  16772. */
  16773. renderingGroupId: number;
  16774. /**
  16775. * The emitter represents the Mesh or position we are attaching the particle system to.
  16776. */
  16777. emitter: Nullable<AbstractMesh | Vector3>;
  16778. /**
  16779. * The maximum number of particles to emit per frame
  16780. */
  16781. emitRate: number;
  16782. /**
  16783. * If you want to launch only a few particles at once, that can be done, as well.
  16784. */
  16785. manualEmitCount: number;
  16786. /**
  16787. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16788. */
  16789. updateSpeed: number;
  16790. /**
  16791. * The amount of time the particle system is running (depends of the overall update speed).
  16792. */
  16793. targetStopDuration: number;
  16794. /**
  16795. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16796. */
  16797. disposeOnStop: boolean;
  16798. /**
  16799. * Minimum power of emitting particles.
  16800. */
  16801. minEmitPower: number;
  16802. /**
  16803. * Maximum power of emitting particles.
  16804. */
  16805. maxEmitPower: number;
  16806. /**
  16807. * Minimum life time of emitting particles.
  16808. */
  16809. minLifeTime: number;
  16810. /**
  16811. * Maximum life time of emitting particles.
  16812. */
  16813. maxLifeTime: number;
  16814. /**
  16815. * Minimum Size of emitting particles.
  16816. */
  16817. minSize: number;
  16818. /**
  16819. * Maximum Size of emitting particles.
  16820. */
  16821. maxSize: number;
  16822. /**
  16823. * Minimum scale of emitting particles on X axis.
  16824. */
  16825. minScaleX: number;
  16826. /**
  16827. * Maximum scale of emitting particles on X axis.
  16828. */
  16829. maxScaleX: number;
  16830. /**
  16831. * Minimum scale of emitting particles on Y axis.
  16832. */
  16833. minScaleY: number;
  16834. /**
  16835. * Maximum scale of emitting particles on Y axis.
  16836. */
  16837. maxScaleY: number;
  16838. /**
  16839. * Gets or sets the minimal initial rotation in radians.
  16840. */
  16841. minInitialRotation: number;
  16842. /**
  16843. * Gets or sets the maximal initial rotation in radians.
  16844. */
  16845. maxInitialRotation: number;
  16846. /**
  16847. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16848. */
  16849. minAngularSpeed: number;
  16850. /**
  16851. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16852. */
  16853. maxAngularSpeed: number;
  16854. /**
  16855. * The texture used to render each particle. (this can be a spritesheet)
  16856. */
  16857. particleTexture: Nullable<Texture>;
  16858. /**
  16859. * The layer mask we are rendering the particles through.
  16860. */
  16861. layerMask: number;
  16862. /**
  16863. * This can help using your own shader to render the particle system.
  16864. * The according effect will be created
  16865. */
  16866. customShader: any;
  16867. /**
  16868. * By default particle system starts as soon as they are created. This prevents the
  16869. * automatic start to happen and let you decide when to start emitting particles.
  16870. */
  16871. preventAutoStart: boolean;
  16872. private _noiseTexture;
  16873. /**
  16874. * Gets or sets a texture used to add random noise to particle positions
  16875. */
  16876. get noiseTexture(): Nullable<ProceduralTexture>;
  16877. set noiseTexture(value: Nullable<ProceduralTexture>);
  16878. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16879. noiseStrength: Vector3;
  16880. /**
  16881. * Callback triggered when the particle animation is ending.
  16882. */
  16883. onAnimationEnd: Nullable<() => void>;
  16884. /**
  16885. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  16886. */
  16887. blendMode: number;
  16888. /**
  16889. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  16890. * to override the particles.
  16891. */
  16892. forceDepthWrite: boolean;
  16893. /** 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 */
  16894. preWarmCycles: number;
  16895. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  16896. preWarmStepOffset: number;
  16897. /**
  16898. * 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)
  16899. */
  16900. spriteCellChangeSpeed: number;
  16901. /**
  16902. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16903. */
  16904. startSpriteCellID: number;
  16905. /**
  16906. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16907. */
  16908. endSpriteCellID: number;
  16909. /**
  16910. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16911. */
  16912. spriteCellWidth: number;
  16913. /**
  16914. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16915. */
  16916. spriteCellHeight: number;
  16917. /**
  16918. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16919. */
  16920. spriteRandomStartCell: boolean;
  16921. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16922. translationPivot: Vector2;
  16923. /** @hidden */
  16924. protected _isAnimationSheetEnabled: boolean;
  16925. /**
  16926. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16927. */
  16928. beginAnimationOnStart: boolean;
  16929. /**
  16930. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16931. */
  16932. beginAnimationFrom: number;
  16933. /**
  16934. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16935. */
  16936. beginAnimationTo: number;
  16937. /**
  16938. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16939. */
  16940. beginAnimationLoop: boolean;
  16941. /**
  16942. * Gets or sets a world offset applied to all particles
  16943. */
  16944. worldOffset: Vector3;
  16945. /**
  16946. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  16947. */
  16948. get isAnimationSheetEnabled(): boolean;
  16949. set isAnimationSheetEnabled(value: boolean);
  16950. /**
  16951. * Get hosting scene
  16952. * @returns the scene
  16953. */
  16954. getScene(): Scene;
  16955. /**
  16956. * You can use gravity if you want to give an orientation to your particles.
  16957. */
  16958. gravity: Vector3;
  16959. protected _colorGradients: Nullable<Array<ColorGradient>>;
  16960. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  16961. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  16962. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  16963. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  16964. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  16965. protected _dragGradients: Nullable<Array<FactorGradient>>;
  16966. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  16967. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  16968. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  16969. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  16970. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  16971. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  16972. /**
  16973. * Defines the delay in milliseconds before starting the system (0 by default)
  16974. */
  16975. startDelay: number;
  16976. /**
  16977. * Gets the current list of drag gradients.
  16978. * You must use addDragGradient and removeDragGradient to udpate this list
  16979. * @returns the list of drag gradients
  16980. */
  16981. getDragGradients(): Nullable<Array<FactorGradient>>;
  16982. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16983. limitVelocityDamping: number;
  16984. /**
  16985. * Gets the current list of limit velocity gradients.
  16986. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16987. * @returns the list of limit velocity gradients
  16988. */
  16989. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16990. /**
  16991. * Gets the current list of color gradients.
  16992. * You must use addColorGradient and removeColorGradient to udpate this list
  16993. * @returns the list of color gradients
  16994. */
  16995. getColorGradients(): Nullable<Array<ColorGradient>>;
  16996. /**
  16997. * Gets the current list of size gradients.
  16998. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16999. * @returns the list of size gradients
  17000. */
  17001. getSizeGradients(): Nullable<Array<FactorGradient>>;
  17002. /**
  17003. * Gets the current list of color remap gradients.
  17004. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  17005. * @returns the list of color remap gradients
  17006. */
  17007. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  17008. /**
  17009. * Gets the current list of alpha remap gradients.
  17010. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  17011. * @returns the list of alpha remap gradients
  17012. */
  17013. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  17014. /**
  17015. * Gets the current list of life time gradients.
  17016. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  17017. * @returns the list of life time gradients
  17018. */
  17019. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  17020. /**
  17021. * Gets the current list of angular speed gradients.
  17022. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  17023. * @returns the list of angular speed gradients
  17024. */
  17025. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  17026. /**
  17027. * Gets the current list of velocity gradients.
  17028. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  17029. * @returns the list of velocity gradients
  17030. */
  17031. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  17032. /**
  17033. * Gets the current list of start size gradients.
  17034. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  17035. * @returns the list of start size gradients
  17036. */
  17037. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  17038. /**
  17039. * Gets the current list of emit rate gradients.
  17040. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  17041. * @returns the list of emit rate gradients
  17042. */
  17043. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  17044. /**
  17045. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17046. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17047. */
  17048. get direction1(): Vector3;
  17049. set direction1(value: Vector3);
  17050. /**
  17051. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17052. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17053. */
  17054. get direction2(): Vector3;
  17055. set direction2(value: Vector3);
  17056. /**
  17057. * 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.
  17058. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17059. */
  17060. get minEmitBox(): Vector3;
  17061. set minEmitBox(value: Vector3);
  17062. /**
  17063. * 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.
  17064. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17065. */
  17066. get maxEmitBox(): Vector3;
  17067. set maxEmitBox(value: Vector3);
  17068. /**
  17069. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17070. */
  17071. color1: Color4;
  17072. /**
  17073. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17074. */
  17075. color2: Color4;
  17076. /**
  17077. * Color the particle will have at the end of its lifetime
  17078. */
  17079. colorDead: Color4;
  17080. /**
  17081. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  17082. */
  17083. textureMask: Color4;
  17084. /**
  17085. * The particle emitter type defines the emitter used by the particle system.
  17086. * It can be for example box, sphere, or cone...
  17087. */
  17088. particleEmitterType: IParticleEmitterType;
  17089. /** @hidden */
  17090. _isSubEmitter: boolean;
  17091. /**
  17092. * Gets or sets the billboard mode to use when isBillboardBased = true.
  17093. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  17094. */
  17095. billboardMode: number;
  17096. protected _isBillboardBased: boolean;
  17097. /**
  17098. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  17099. */
  17100. get isBillboardBased(): boolean;
  17101. set isBillboardBased(value: boolean);
  17102. /**
  17103. * The scene the particle system belongs to.
  17104. */
  17105. protected _scene: Scene;
  17106. /**
  17107. * Local cache of defines for image processing.
  17108. */
  17109. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  17110. /**
  17111. * Default configuration related to image processing available in the standard Material.
  17112. */
  17113. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17114. /**
  17115. * Gets the image processing configuration used either in this material.
  17116. */
  17117. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  17118. /**
  17119. * Sets the Default image processing configuration used either in the this material.
  17120. *
  17121. * If sets to null, the scene one is in use.
  17122. */
  17123. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  17124. /**
  17125. * Attaches a new image processing configuration to the Standard Material.
  17126. * @param configuration
  17127. */
  17128. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  17129. /** @hidden */
  17130. protected _reset(): void;
  17131. /** @hidden */
  17132. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  17133. /**
  17134. * Instantiates a particle system.
  17135. * 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.
  17136. * @param name The name of the particle system
  17137. */
  17138. constructor(name: string);
  17139. /**
  17140. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17141. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17142. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17143. * @returns the emitter
  17144. */
  17145. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17146. /**
  17147. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17148. * @param radius The radius of the hemisphere to emit from
  17149. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17150. * @returns the emitter
  17151. */
  17152. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  17153. /**
  17154. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17155. * @param radius The radius of the sphere to emit from
  17156. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17157. * @returns the emitter
  17158. */
  17159. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  17160. /**
  17161. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17162. * @param radius The radius of the sphere to emit from
  17163. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17164. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17165. * @returns the emitter
  17166. */
  17167. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  17168. /**
  17169. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17170. * @param radius The radius of the emission cylinder
  17171. * @param height The height of the emission cylinder
  17172. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17173. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17174. * @returns the emitter
  17175. */
  17176. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  17177. /**
  17178. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17179. * @param radius The radius of the cylinder to emit from
  17180. * @param height The height of the emission cylinder
  17181. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17182. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17183. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17184. * @returns the emitter
  17185. */
  17186. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  17187. /**
  17188. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17189. * @param radius The radius of the cone to emit from
  17190. * @param angle The base angle of the cone
  17191. * @returns the emitter
  17192. */
  17193. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  17194. /**
  17195. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17196. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17197. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17198. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17199. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17200. * @returns the emitter
  17201. */
  17202. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17203. }
  17204. }
  17205. declare module BABYLON {
  17206. /**
  17207. * Type of sub emitter
  17208. */
  17209. export enum SubEmitterType {
  17210. /**
  17211. * Attached to the particle over it's lifetime
  17212. */
  17213. ATTACHED = 0,
  17214. /**
  17215. * Created when the particle dies
  17216. */
  17217. END = 1
  17218. }
  17219. /**
  17220. * Sub emitter class used to emit particles from an existing particle
  17221. */
  17222. export class SubEmitter {
  17223. /**
  17224. * the particle system to be used by the sub emitter
  17225. */
  17226. particleSystem: ParticleSystem;
  17227. /**
  17228. * Type of the submitter (Default: END)
  17229. */
  17230. type: SubEmitterType;
  17231. /**
  17232. * 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)
  17233. * Note: This only is supported when using an emitter of type Mesh
  17234. */
  17235. inheritDirection: boolean;
  17236. /**
  17237. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  17238. */
  17239. inheritedVelocityAmount: number;
  17240. /**
  17241. * Creates a sub emitter
  17242. * @param particleSystem the particle system to be used by the sub emitter
  17243. */
  17244. constructor(
  17245. /**
  17246. * the particle system to be used by the sub emitter
  17247. */
  17248. particleSystem: ParticleSystem);
  17249. /**
  17250. * Clones the sub emitter
  17251. * @returns the cloned sub emitter
  17252. */
  17253. clone(): SubEmitter;
  17254. /**
  17255. * Serialize current object to a JSON object
  17256. * @returns the serialized object
  17257. */
  17258. serialize(): any;
  17259. /** @hidden */
  17260. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  17261. /**
  17262. * Creates a new SubEmitter from a serialized JSON version
  17263. * @param serializationObject defines the JSON object to read from
  17264. * @param scene defines the hosting scene
  17265. * @param rootUrl defines the rootUrl for data loading
  17266. * @returns a new SubEmitter
  17267. */
  17268. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  17269. /** Release associated resources */
  17270. dispose(): void;
  17271. }
  17272. }
  17273. declare module BABYLON {
  17274. /** @hidden */
  17275. export var clipPlaneFragmentDeclaration: {
  17276. name: string;
  17277. shader: string;
  17278. };
  17279. }
  17280. declare module BABYLON {
  17281. /** @hidden */
  17282. export var imageProcessingDeclaration: {
  17283. name: string;
  17284. shader: string;
  17285. };
  17286. }
  17287. declare module BABYLON {
  17288. /** @hidden */
  17289. export var imageProcessingFunctions: {
  17290. name: string;
  17291. shader: string;
  17292. };
  17293. }
  17294. declare module BABYLON {
  17295. /** @hidden */
  17296. export var clipPlaneFragment: {
  17297. name: string;
  17298. shader: string;
  17299. };
  17300. }
  17301. declare module BABYLON {
  17302. /** @hidden */
  17303. export var particlesPixelShader: {
  17304. name: string;
  17305. shader: string;
  17306. };
  17307. }
  17308. declare module BABYLON {
  17309. /** @hidden */
  17310. export var clipPlaneVertexDeclaration: {
  17311. name: string;
  17312. shader: string;
  17313. };
  17314. }
  17315. declare module BABYLON {
  17316. /** @hidden */
  17317. export var clipPlaneVertex: {
  17318. name: string;
  17319. shader: string;
  17320. };
  17321. }
  17322. declare module BABYLON {
  17323. /** @hidden */
  17324. export var particlesVertexShader: {
  17325. name: string;
  17326. shader: string;
  17327. };
  17328. }
  17329. declare module BABYLON {
  17330. /**
  17331. * This represents a particle system in Babylon.
  17332. * 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.
  17333. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17334. * @example https://doc.babylonjs.com/babylon101/particles
  17335. */
  17336. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17337. /**
  17338. * Billboard mode will only apply to Y axis
  17339. */
  17340. static readonly BILLBOARDMODE_Y: number;
  17341. /**
  17342. * Billboard mode will apply to all axes
  17343. */
  17344. static readonly BILLBOARDMODE_ALL: number;
  17345. /**
  17346. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  17347. */
  17348. static readonly BILLBOARDMODE_STRETCHED: number;
  17349. /**
  17350. * This function can be defined to provide custom update for active particles.
  17351. * This function will be called instead of regular update (age, position, color, etc.).
  17352. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17353. */
  17354. updateFunction: (particles: Particle[]) => void;
  17355. private _emitterWorldMatrix;
  17356. /**
  17357. * This function can be defined to specify initial direction for every new particle.
  17358. * It by default use the emitterType defined function
  17359. */
  17360. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17361. /**
  17362. * This function can be defined to specify initial position for every new particle.
  17363. * It by default use the emitterType defined function
  17364. */
  17365. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17366. /**
  17367. * @hidden
  17368. */
  17369. _inheritedVelocityOffset: Vector3;
  17370. /**
  17371. * An event triggered when the system is disposed
  17372. */
  17373. onDisposeObservable: Observable<ParticleSystem>;
  17374. private _onDisposeObserver;
  17375. /**
  17376. * Sets a callback that will be triggered when the system is disposed
  17377. */
  17378. set onDispose(callback: () => void);
  17379. private _particles;
  17380. private _epsilon;
  17381. private _capacity;
  17382. private _stockParticles;
  17383. private _newPartsExcess;
  17384. private _vertexData;
  17385. private _vertexBuffer;
  17386. private _vertexBuffers;
  17387. private _spriteBuffer;
  17388. private _indexBuffer;
  17389. private _effect;
  17390. private _customEffect;
  17391. private _cachedDefines;
  17392. private _scaledColorStep;
  17393. private _colorDiff;
  17394. private _scaledDirection;
  17395. private _scaledGravity;
  17396. private _currentRenderId;
  17397. private _alive;
  17398. private _useInstancing;
  17399. private _started;
  17400. private _stopped;
  17401. private _actualFrame;
  17402. private _scaledUpdateSpeed;
  17403. private _vertexBufferSize;
  17404. /** @hidden */
  17405. _currentEmitRateGradient: Nullable<FactorGradient>;
  17406. /** @hidden */
  17407. _currentEmitRate1: number;
  17408. /** @hidden */
  17409. _currentEmitRate2: number;
  17410. /** @hidden */
  17411. _currentStartSizeGradient: Nullable<FactorGradient>;
  17412. /** @hidden */
  17413. _currentStartSize1: number;
  17414. /** @hidden */
  17415. _currentStartSize2: number;
  17416. private readonly _rawTextureWidth;
  17417. private _rampGradientsTexture;
  17418. private _useRampGradients;
  17419. /** Gets or sets a boolean indicating that ramp gradients must be used
  17420. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17421. */
  17422. get useRampGradients(): boolean;
  17423. set useRampGradients(value: boolean);
  17424. /**
  17425. * 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.
  17426. * 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: [])
  17427. */
  17428. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17429. private _subEmitters;
  17430. /**
  17431. * @hidden
  17432. * If the particle systems emitter should be disposed when the particle system is disposed
  17433. */
  17434. _disposeEmitterOnDispose: boolean;
  17435. /**
  17436. * The current active Sub-systems, this property is used by the root particle system only.
  17437. */
  17438. activeSubSystems: Array<ParticleSystem>;
  17439. private _rootParticleSystem;
  17440. /**
  17441. * Gets the current list of active particles
  17442. */
  17443. get particles(): Particle[];
  17444. /**
  17445. * Returns the string "ParticleSystem"
  17446. * @returns a string containing the class name
  17447. */
  17448. getClassName(): string;
  17449. /**
  17450. * Instantiates a particle system.
  17451. * 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.
  17452. * @param name The name of the particle system
  17453. * @param capacity The max number of particles alive at the same time
  17454. * @param scene The scene the particle system belongs to
  17455. * @param customEffect a custom effect used to change the way particles are rendered by default
  17456. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17457. * @param epsilon Offset used to render the particles
  17458. */
  17459. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17460. private _addFactorGradient;
  17461. private _removeFactorGradient;
  17462. /**
  17463. * Adds a new life time gradient
  17464. * @param gradient defines the gradient to use (between 0 and 1)
  17465. * @param factor defines the life time factor to affect to the specified gradient
  17466. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17467. * @returns the current particle system
  17468. */
  17469. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17470. /**
  17471. * Remove a specific life time gradient
  17472. * @param gradient defines the gradient to remove
  17473. * @returns the current particle system
  17474. */
  17475. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17476. /**
  17477. * Adds a new size gradient
  17478. * @param gradient defines the gradient to use (between 0 and 1)
  17479. * @param factor defines the size factor to affect to the specified gradient
  17480. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17481. * @returns the current particle system
  17482. */
  17483. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17484. /**
  17485. * Remove a specific size gradient
  17486. * @param gradient defines the gradient to remove
  17487. * @returns the current particle system
  17488. */
  17489. removeSizeGradient(gradient: number): IParticleSystem;
  17490. /**
  17491. * Adds a new color remap gradient
  17492. * @param gradient defines the gradient to use (between 0 and 1)
  17493. * @param min defines the color remap minimal range
  17494. * @param max defines the color remap maximal range
  17495. * @returns the current particle system
  17496. */
  17497. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17498. /**
  17499. * Remove a specific color remap gradient
  17500. * @param gradient defines the gradient to remove
  17501. * @returns the current particle system
  17502. */
  17503. removeColorRemapGradient(gradient: number): IParticleSystem;
  17504. /**
  17505. * Adds a new alpha remap gradient
  17506. * @param gradient defines the gradient to use (between 0 and 1)
  17507. * @param min defines the alpha remap minimal range
  17508. * @param max defines the alpha remap maximal range
  17509. * @returns the current particle system
  17510. */
  17511. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17512. /**
  17513. * Remove a specific alpha remap gradient
  17514. * @param gradient defines the gradient to remove
  17515. * @returns the current particle system
  17516. */
  17517. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  17518. /**
  17519. * Adds a new angular speed gradient
  17520. * @param gradient defines the gradient to use (between 0 and 1)
  17521. * @param factor defines the angular speed to affect to the specified gradient
  17522. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17523. * @returns the current particle system
  17524. */
  17525. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17526. /**
  17527. * Remove a specific angular speed gradient
  17528. * @param gradient defines the gradient to remove
  17529. * @returns the current particle system
  17530. */
  17531. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17532. /**
  17533. * Adds a new velocity gradient
  17534. * @param gradient defines the gradient to use (between 0 and 1)
  17535. * @param factor defines the velocity to affect to the specified gradient
  17536. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17537. * @returns the current particle system
  17538. */
  17539. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17540. /**
  17541. * Remove a specific velocity gradient
  17542. * @param gradient defines the gradient to remove
  17543. * @returns the current particle system
  17544. */
  17545. removeVelocityGradient(gradient: number): IParticleSystem;
  17546. /**
  17547. * Adds a new limit velocity gradient
  17548. * @param gradient defines the gradient to use (between 0 and 1)
  17549. * @param factor defines the limit velocity value to affect to the specified gradient
  17550. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17551. * @returns the current particle system
  17552. */
  17553. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17554. /**
  17555. * Remove a specific limit velocity gradient
  17556. * @param gradient defines the gradient to remove
  17557. * @returns the current particle system
  17558. */
  17559. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17560. /**
  17561. * Adds a new drag gradient
  17562. * @param gradient defines the gradient to use (between 0 and 1)
  17563. * @param factor defines the drag value to affect to the specified gradient
  17564. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17565. * @returns the current particle system
  17566. */
  17567. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17568. /**
  17569. * Remove a specific drag gradient
  17570. * @param gradient defines the gradient to remove
  17571. * @returns the current particle system
  17572. */
  17573. removeDragGradient(gradient: number): IParticleSystem;
  17574. /**
  17575. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17576. * @param gradient defines the gradient to use (between 0 and 1)
  17577. * @param factor defines the emit rate value to affect to the specified gradient
  17578. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17579. * @returns the current particle system
  17580. */
  17581. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17582. /**
  17583. * Remove a specific emit rate gradient
  17584. * @param gradient defines the gradient to remove
  17585. * @returns the current particle system
  17586. */
  17587. removeEmitRateGradient(gradient: number): IParticleSystem;
  17588. /**
  17589. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17590. * @param gradient defines the gradient to use (between 0 and 1)
  17591. * @param factor defines the start size value to affect to the specified gradient
  17592. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17593. * @returns the current particle system
  17594. */
  17595. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17596. /**
  17597. * Remove a specific start size gradient
  17598. * @param gradient defines the gradient to remove
  17599. * @returns the current particle system
  17600. */
  17601. removeStartSizeGradient(gradient: number): IParticleSystem;
  17602. private _createRampGradientTexture;
  17603. /**
  17604. * Gets the current list of ramp gradients.
  17605. * You must use addRampGradient and removeRampGradient to udpate this list
  17606. * @returns the list of ramp gradients
  17607. */
  17608. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17609. /**
  17610. * Adds a new ramp gradient used to remap particle colors
  17611. * @param gradient defines the gradient to use (between 0 and 1)
  17612. * @param color defines the color to affect to the specified gradient
  17613. * @returns the current particle system
  17614. */
  17615. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17616. /**
  17617. * Remove a specific ramp gradient
  17618. * @param gradient defines the gradient to remove
  17619. * @returns the current particle system
  17620. */
  17621. removeRampGradient(gradient: number): ParticleSystem;
  17622. /**
  17623. * Adds a new color gradient
  17624. * @param gradient defines the gradient to use (between 0 and 1)
  17625. * @param color1 defines the color to affect to the specified gradient
  17626. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17627. * @returns this particle system
  17628. */
  17629. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17630. /**
  17631. * Remove a specific color gradient
  17632. * @param gradient defines the gradient to remove
  17633. * @returns this particle system
  17634. */
  17635. removeColorGradient(gradient: number): IParticleSystem;
  17636. private _fetchR;
  17637. protected _reset(): void;
  17638. private _resetEffect;
  17639. private _createVertexBuffers;
  17640. private _createIndexBuffer;
  17641. /**
  17642. * Gets the maximum number of particles active at the same time.
  17643. * @returns The max number of active particles.
  17644. */
  17645. getCapacity(): number;
  17646. /**
  17647. * Gets whether there are still active particles in the system.
  17648. * @returns True if it is alive, otherwise false.
  17649. */
  17650. isAlive(): boolean;
  17651. /**
  17652. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17653. * @returns True if it has been started, otherwise false.
  17654. */
  17655. isStarted(): boolean;
  17656. private _prepareSubEmitterInternalArray;
  17657. /**
  17658. * Starts the particle system and begins to emit
  17659. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17660. */
  17661. start(delay?: number): void;
  17662. /**
  17663. * Stops the particle system.
  17664. * @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.
  17665. */
  17666. stop(stopSubEmitters?: boolean): void;
  17667. /**
  17668. * Remove all active particles
  17669. */
  17670. reset(): void;
  17671. /**
  17672. * @hidden (for internal use only)
  17673. */
  17674. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17675. /**
  17676. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17677. * Its lifetime will start back at 0.
  17678. */
  17679. recycleParticle: (particle: Particle) => void;
  17680. private _stopSubEmitters;
  17681. private _createParticle;
  17682. private _removeFromRoot;
  17683. private _emitFromParticle;
  17684. private _update;
  17685. /** @hidden */
  17686. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17687. /** @hidden */
  17688. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17689. /** @hidden */
  17690. private _getEffect;
  17691. /**
  17692. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17693. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  17694. */
  17695. animate(preWarmOnly?: boolean): void;
  17696. private _appendParticleVertices;
  17697. /**
  17698. * Rebuilds the particle system.
  17699. */
  17700. rebuild(): void;
  17701. /**
  17702. * Is this system ready to be used/rendered
  17703. * @return true if the system is ready
  17704. */
  17705. isReady(): boolean;
  17706. private _render;
  17707. /**
  17708. * Renders the particle system in its current state.
  17709. * @returns the current number of particles
  17710. */
  17711. render(): number;
  17712. /**
  17713. * Disposes the particle system and free the associated resources
  17714. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17715. */
  17716. dispose(disposeTexture?: boolean): void;
  17717. /**
  17718. * Clones the particle system.
  17719. * @param name The name of the cloned object
  17720. * @param newEmitter The new emitter to use
  17721. * @returns the cloned particle system
  17722. */
  17723. clone(name: string, newEmitter: any): ParticleSystem;
  17724. /**
  17725. * Serializes the particle system to a JSON object.
  17726. * @returns the JSON object
  17727. */
  17728. serialize(): any;
  17729. /** @hidden */
  17730. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  17731. /** @hidden */
  17732. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  17733. /**
  17734. * Parses a JSON object to create a particle system.
  17735. * @param parsedParticleSystem The JSON object to parse
  17736. * @param scene The scene to create the particle system in
  17737. * @param rootUrl The root url to use to load external dependencies like texture
  17738. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  17739. * @returns the Parsed particle system
  17740. */
  17741. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  17742. }
  17743. }
  17744. declare module BABYLON {
  17745. /**
  17746. * A particle represents one of the element emitted by a particle system.
  17747. * This is mainly define by its coordinates, direction, velocity and age.
  17748. */
  17749. export class Particle {
  17750. /**
  17751. * The particle system the particle belongs to.
  17752. */
  17753. particleSystem: ParticleSystem;
  17754. private static _Count;
  17755. /**
  17756. * Unique ID of the particle
  17757. */
  17758. id: number;
  17759. /**
  17760. * The world position of the particle in the scene.
  17761. */
  17762. position: Vector3;
  17763. /**
  17764. * The world direction of the particle in the scene.
  17765. */
  17766. direction: Vector3;
  17767. /**
  17768. * The color of the particle.
  17769. */
  17770. color: Color4;
  17771. /**
  17772. * The color change of the particle per step.
  17773. */
  17774. colorStep: Color4;
  17775. /**
  17776. * Defines how long will the life of the particle be.
  17777. */
  17778. lifeTime: number;
  17779. /**
  17780. * The current age of the particle.
  17781. */
  17782. age: number;
  17783. /**
  17784. * The current size of the particle.
  17785. */
  17786. size: number;
  17787. /**
  17788. * The current scale of the particle.
  17789. */
  17790. scale: Vector2;
  17791. /**
  17792. * The current angle of the particle.
  17793. */
  17794. angle: number;
  17795. /**
  17796. * Defines how fast is the angle changing.
  17797. */
  17798. angularSpeed: number;
  17799. /**
  17800. * Defines the cell index used by the particle to be rendered from a sprite.
  17801. */
  17802. cellIndex: number;
  17803. /**
  17804. * The information required to support color remapping
  17805. */
  17806. remapData: Vector4;
  17807. /** @hidden */
  17808. _randomCellOffset?: number;
  17809. /** @hidden */
  17810. _initialDirection: Nullable<Vector3>;
  17811. /** @hidden */
  17812. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  17813. /** @hidden */
  17814. _initialStartSpriteCellID: number;
  17815. /** @hidden */
  17816. _initialEndSpriteCellID: number;
  17817. /** @hidden */
  17818. _currentColorGradient: Nullable<ColorGradient>;
  17819. /** @hidden */
  17820. _currentColor1: Color4;
  17821. /** @hidden */
  17822. _currentColor2: Color4;
  17823. /** @hidden */
  17824. _currentSizeGradient: Nullable<FactorGradient>;
  17825. /** @hidden */
  17826. _currentSize1: number;
  17827. /** @hidden */
  17828. _currentSize2: number;
  17829. /** @hidden */
  17830. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  17831. /** @hidden */
  17832. _currentAngularSpeed1: number;
  17833. /** @hidden */
  17834. _currentAngularSpeed2: number;
  17835. /** @hidden */
  17836. _currentVelocityGradient: Nullable<FactorGradient>;
  17837. /** @hidden */
  17838. _currentVelocity1: number;
  17839. /** @hidden */
  17840. _currentVelocity2: number;
  17841. /** @hidden */
  17842. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  17843. /** @hidden */
  17844. _currentLimitVelocity1: number;
  17845. /** @hidden */
  17846. _currentLimitVelocity2: number;
  17847. /** @hidden */
  17848. _currentDragGradient: Nullable<FactorGradient>;
  17849. /** @hidden */
  17850. _currentDrag1: number;
  17851. /** @hidden */
  17852. _currentDrag2: number;
  17853. /** @hidden */
  17854. _randomNoiseCoordinates1: Vector3;
  17855. /** @hidden */
  17856. _randomNoiseCoordinates2: Vector3;
  17857. /**
  17858. * Creates a new instance Particle
  17859. * @param particleSystem the particle system the particle belongs to
  17860. */
  17861. constructor(
  17862. /**
  17863. * The particle system the particle belongs to.
  17864. */
  17865. particleSystem: ParticleSystem);
  17866. private updateCellInfoFromSystem;
  17867. /**
  17868. * Defines how the sprite cell index is updated for the particle
  17869. */
  17870. updateCellIndex(): void;
  17871. /** @hidden */
  17872. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  17873. /** @hidden */
  17874. _inheritParticleInfoToSubEmitters(): void;
  17875. /** @hidden */
  17876. _reset(): void;
  17877. /**
  17878. * Copy the properties of particle to another one.
  17879. * @param other the particle to copy the information to.
  17880. */
  17881. copyTo(other: Particle): void;
  17882. }
  17883. }
  17884. declare module BABYLON {
  17885. /**
  17886. * Particle emitter represents a volume emitting particles.
  17887. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  17888. */
  17889. export interface IParticleEmitterType {
  17890. /**
  17891. * Called by the particle System when the direction is computed for the created particle.
  17892. * @param worldMatrix is the world matrix of the particle system
  17893. * @param directionToUpdate is the direction vector to update with the result
  17894. * @param particle is the particle we are computed the direction for
  17895. */
  17896. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17897. /**
  17898. * Called by the particle System when the position is computed for the created particle.
  17899. * @param worldMatrix is the world matrix of the particle system
  17900. * @param positionToUpdate is the position vector to update with the result
  17901. * @param particle is the particle we are computed the position for
  17902. */
  17903. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17904. /**
  17905. * Clones the current emitter and returns a copy of it
  17906. * @returns the new emitter
  17907. */
  17908. clone(): IParticleEmitterType;
  17909. /**
  17910. * Called by the GPUParticleSystem to setup the update shader
  17911. * @param effect defines the update shader
  17912. */
  17913. applyToShader(effect: Effect): void;
  17914. /**
  17915. * Returns a string to use to update the GPU particles update shader
  17916. * @returns the effect defines string
  17917. */
  17918. getEffectDefines(): string;
  17919. /**
  17920. * Returns a string representing the class name
  17921. * @returns a string containing the class name
  17922. */
  17923. getClassName(): string;
  17924. /**
  17925. * Serializes the particle system to a JSON object.
  17926. * @returns the JSON object
  17927. */
  17928. serialize(): any;
  17929. /**
  17930. * Parse properties from a JSON object
  17931. * @param serializationObject defines the JSON object
  17932. */
  17933. parse(serializationObject: any): void;
  17934. }
  17935. }
  17936. declare module BABYLON {
  17937. /**
  17938. * Particle emitter emitting particles from the inside of a box.
  17939. * It emits the particles randomly between 2 given directions.
  17940. */
  17941. export class BoxParticleEmitter implements IParticleEmitterType {
  17942. /**
  17943. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17944. */
  17945. direction1: Vector3;
  17946. /**
  17947. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17948. */
  17949. direction2: Vector3;
  17950. /**
  17951. * 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.
  17952. */
  17953. minEmitBox: Vector3;
  17954. /**
  17955. * 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.
  17956. */
  17957. maxEmitBox: Vector3;
  17958. /**
  17959. * Creates a new instance BoxParticleEmitter
  17960. */
  17961. constructor();
  17962. /**
  17963. * Called by the particle System when the direction is computed for the created particle.
  17964. * @param worldMatrix is the world matrix of the particle system
  17965. * @param directionToUpdate is the direction vector to update with the result
  17966. * @param particle is the particle we are computed the direction for
  17967. */
  17968. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17969. /**
  17970. * Called by the particle System when the position is computed for the created particle.
  17971. * @param worldMatrix is the world matrix of the particle system
  17972. * @param positionToUpdate is the position vector to update with the result
  17973. * @param particle is the particle we are computed the position for
  17974. */
  17975. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17976. /**
  17977. * Clones the current emitter and returns a copy of it
  17978. * @returns the new emitter
  17979. */
  17980. clone(): BoxParticleEmitter;
  17981. /**
  17982. * Called by the GPUParticleSystem to setup the update shader
  17983. * @param effect defines the update shader
  17984. */
  17985. applyToShader(effect: Effect): void;
  17986. /**
  17987. * Returns a string to use to update the GPU particles update shader
  17988. * @returns a string containng the defines string
  17989. */
  17990. getEffectDefines(): string;
  17991. /**
  17992. * Returns the string "BoxParticleEmitter"
  17993. * @returns a string containing the class name
  17994. */
  17995. getClassName(): string;
  17996. /**
  17997. * Serializes the particle system to a JSON object.
  17998. * @returns the JSON object
  17999. */
  18000. serialize(): any;
  18001. /**
  18002. * Parse properties from a JSON object
  18003. * @param serializationObject defines the JSON object
  18004. */
  18005. parse(serializationObject: any): void;
  18006. }
  18007. }
  18008. declare module BABYLON {
  18009. /**
  18010. * Particle emitter emitting particles from the inside of a cone.
  18011. * It emits the particles alongside the cone volume from the base to the particle.
  18012. * The emission direction might be randomized.
  18013. */
  18014. export class ConeParticleEmitter implements IParticleEmitterType {
  18015. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18016. directionRandomizer: number;
  18017. private _radius;
  18018. private _angle;
  18019. private _height;
  18020. /**
  18021. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  18022. */
  18023. radiusRange: number;
  18024. /**
  18025. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  18026. */
  18027. heightRange: number;
  18028. /**
  18029. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  18030. */
  18031. emitFromSpawnPointOnly: boolean;
  18032. /**
  18033. * Gets or sets the radius of the emission cone
  18034. */
  18035. get radius(): number;
  18036. set radius(value: number);
  18037. /**
  18038. * Gets or sets the angle of the emission cone
  18039. */
  18040. get angle(): number;
  18041. set angle(value: number);
  18042. private _buildHeight;
  18043. /**
  18044. * Creates a new instance ConeParticleEmitter
  18045. * @param radius the radius of the emission cone (1 by default)
  18046. * @param angle the cone base angle (PI by default)
  18047. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  18048. */
  18049. constructor(radius?: number, angle?: number,
  18050. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18051. directionRandomizer?: number);
  18052. /**
  18053. * Called by the particle System when the direction is computed for the created particle.
  18054. * @param worldMatrix is the world matrix of the particle system
  18055. * @param directionToUpdate is the direction vector to update with the result
  18056. * @param particle is the particle we are computed the direction for
  18057. */
  18058. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18059. /**
  18060. * Called by the particle System when the position is computed for the created particle.
  18061. * @param worldMatrix is the world matrix of the particle system
  18062. * @param positionToUpdate is the position vector to update with the result
  18063. * @param particle is the particle we are computed the position for
  18064. */
  18065. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18066. /**
  18067. * Clones the current emitter and returns a copy of it
  18068. * @returns the new emitter
  18069. */
  18070. clone(): ConeParticleEmitter;
  18071. /**
  18072. * Called by the GPUParticleSystem to setup the update shader
  18073. * @param effect defines the update shader
  18074. */
  18075. applyToShader(effect: Effect): void;
  18076. /**
  18077. * Returns a string to use to update the GPU particles update shader
  18078. * @returns a string containng the defines string
  18079. */
  18080. getEffectDefines(): string;
  18081. /**
  18082. * Returns the string "ConeParticleEmitter"
  18083. * @returns a string containing the class name
  18084. */
  18085. getClassName(): string;
  18086. /**
  18087. * Serializes the particle system to a JSON object.
  18088. * @returns the JSON object
  18089. */
  18090. serialize(): any;
  18091. /**
  18092. * Parse properties from a JSON object
  18093. * @param serializationObject defines the JSON object
  18094. */
  18095. parse(serializationObject: any): void;
  18096. }
  18097. }
  18098. declare module BABYLON {
  18099. /**
  18100. * Particle emitter emitting particles from the inside of a cylinder.
  18101. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  18102. */
  18103. export class CylinderParticleEmitter implements IParticleEmitterType {
  18104. /**
  18105. * The radius of the emission cylinder.
  18106. */
  18107. radius: number;
  18108. /**
  18109. * The height of the emission cylinder.
  18110. */
  18111. height: number;
  18112. /**
  18113. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18114. */
  18115. radiusRange: number;
  18116. /**
  18117. * How much to randomize the particle direction [0-1].
  18118. */
  18119. directionRandomizer: number;
  18120. /**
  18121. * Creates a new instance CylinderParticleEmitter
  18122. * @param radius the radius of the emission cylinder (1 by default)
  18123. * @param height the height of the emission cylinder (1 by default)
  18124. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18125. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18126. */
  18127. constructor(
  18128. /**
  18129. * The radius of the emission cylinder.
  18130. */
  18131. radius?: number,
  18132. /**
  18133. * The height of the emission cylinder.
  18134. */
  18135. height?: number,
  18136. /**
  18137. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18138. */
  18139. radiusRange?: number,
  18140. /**
  18141. * How much to randomize the particle direction [0-1].
  18142. */
  18143. directionRandomizer?: number);
  18144. /**
  18145. * Called by the particle System when the direction is computed for the created particle.
  18146. * @param worldMatrix is the world matrix of the particle system
  18147. * @param directionToUpdate is the direction vector to update with the result
  18148. * @param particle is the particle we are computed the direction for
  18149. */
  18150. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18151. /**
  18152. * Called by the particle System when the position is computed for the created particle.
  18153. * @param worldMatrix is the world matrix of the particle system
  18154. * @param positionToUpdate is the position vector to update with the result
  18155. * @param particle is the particle we are computed the position for
  18156. */
  18157. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18158. /**
  18159. * Clones the current emitter and returns a copy of it
  18160. * @returns the new emitter
  18161. */
  18162. clone(): CylinderParticleEmitter;
  18163. /**
  18164. * Called by the GPUParticleSystem to setup the update shader
  18165. * @param effect defines the update shader
  18166. */
  18167. applyToShader(effect: Effect): void;
  18168. /**
  18169. * Returns a string to use to update the GPU particles update shader
  18170. * @returns a string containng the defines string
  18171. */
  18172. getEffectDefines(): string;
  18173. /**
  18174. * Returns the string "CylinderParticleEmitter"
  18175. * @returns a string containing the class name
  18176. */
  18177. getClassName(): string;
  18178. /**
  18179. * Serializes the particle system to a JSON object.
  18180. * @returns the JSON object
  18181. */
  18182. serialize(): any;
  18183. /**
  18184. * Parse properties from a JSON object
  18185. * @param serializationObject defines the JSON object
  18186. */
  18187. parse(serializationObject: any): void;
  18188. }
  18189. /**
  18190. * Particle emitter emitting particles from the inside of a cylinder.
  18191. * It emits the particles randomly between two vectors.
  18192. */
  18193. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  18194. /**
  18195. * The min limit of the emission direction.
  18196. */
  18197. direction1: Vector3;
  18198. /**
  18199. * The max limit of the emission direction.
  18200. */
  18201. direction2: Vector3;
  18202. /**
  18203. * Creates a new instance CylinderDirectedParticleEmitter
  18204. * @param radius the radius of the emission cylinder (1 by default)
  18205. * @param height the height of the emission cylinder (1 by default)
  18206. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18207. * @param direction1 the min limit of the emission direction (up vector by default)
  18208. * @param direction2 the max limit of the emission direction (up vector by default)
  18209. */
  18210. constructor(radius?: number, height?: number, radiusRange?: number,
  18211. /**
  18212. * The min limit of the emission direction.
  18213. */
  18214. direction1?: Vector3,
  18215. /**
  18216. * The max limit of the emission direction.
  18217. */
  18218. direction2?: Vector3);
  18219. /**
  18220. * Called by the particle System when the direction is computed for the created particle.
  18221. * @param worldMatrix is the world matrix of the particle system
  18222. * @param directionToUpdate is the direction vector to update with the result
  18223. * @param particle is the particle we are computed the direction for
  18224. */
  18225. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18226. /**
  18227. * Clones the current emitter and returns a copy of it
  18228. * @returns the new emitter
  18229. */
  18230. clone(): CylinderDirectedParticleEmitter;
  18231. /**
  18232. * Called by the GPUParticleSystem to setup the update shader
  18233. * @param effect defines the update shader
  18234. */
  18235. applyToShader(effect: Effect): void;
  18236. /**
  18237. * Returns a string to use to update the GPU particles update shader
  18238. * @returns a string containng the defines string
  18239. */
  18240. getEffectDefines(): string;
  18241. /**
  18242. * Returns the string "CylinderDirectedParticleEmitter"
  18243. * @returns a string containing the class name
  18244. */
  18245. getClassName(): string;
  18246. /**
  18247. * Serializes the particle system to a JSON object.
  18248. * @returns the JSON object
  18249. */
  18250. serialize(): any;
  18251. /**
  18252. * Parse properties from a JSON object
  18253. * @param serializationObject defines the JSON object
  18254. */
  18255. parse(serializationObject: any): void;
  18256. }
  18257. }
  18258. declare module BABYLON {
  18259. /**
  18260. * Particle emitter emitting particles from the inside of a hemisphere.
  18261. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  18262. */
  18263. export class HemisphericParticleEmitter implements IParticleEmitterType {
  18264. /**
  18265. * The radius of the emission hemisphere.
  18266. */
  18267. radius: number;
  18268. /**
  18269. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18270. */
  18271. radiusRange: number;
  18272. /**
  18273. * How much to randomize the particle direction [0-1].
  18274. */
  18275. directionRandomizer: number;
  18276. /**
  18277. * Creates a new instance HemisphericParticleEmitter
  18278. * @param radius the radius of the emission hemisphere (1 by default)
  18279. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18280. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18281. */
  18282. constructor(
  18283. /**
  18284. * The radius of the emission hemisphere.
  18285. */
  18286. radius?: number,
  18287. /**
  18288. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18289. */
  18290. radiusRange?: number,
  18291. /**
  18292. * How much to randomize the particle direction [0-1].
  18293. */
  18294. directionRandomizer?: number);
  18295. /**
  18296. * Called by the particle System when the direction is computed for the created particle.
  18297. * @param worldMatrix is the world matrix of the particle system
  18298. * @param directionToUpdate is the direction vector to update with the result
  18299. * @param particle is the particle we are computed the direction for
  18300. */
  18301. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18302. /**
  18303. * Called by the particle System when the position is computed for the created particle.
  18304. * @param worldMatrix is the world matrix of the particle system
  18305. * @param positionToUpdate is the position vector to update with the result
  18306. * @param particle is the particle we are computed the position for
  18307. */
  18308. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18309. /**
  18310. * Clones the current emitter and returns a copy of it
  18311. * @returns the new emitter
  18312. */
  18313. clone(): HemisphericParticleEmitter;
  18314. /**
  18315. * Called by the GPUParticleSystem to setup the update shader
  18316. * @param effect defines the update shader
  18317. */
  18318. applyToShader(effect: Effect): void;
  18319. /**
  18320. * Returns a string to use to update the GPU particles update shader
  18321. * @returns a string containng the defines string
  18322. */
  18323. getEffectDefines(): string;
  18324. /**
  18325. * Returns the string "HemisphericParticleEmitter"
  18326. * @returns a string containing the class name
  18327. */
  18328. getClassName(): string;
  18329. /**
  18330. * Serializes the particle system to a JSON object.
  18331. * @returns the JSON object
  18332. */
  18333. serialize(): any;
  18334. /**
  18335. * Parse properties from a JSON object
  18336. * @param serializationObject defines the JSON object
  18337. */
  18338. parse(serializationObject: any): void;
  18339. }
  18340. }
  18341. declare module BABYLON {
  18342. /**
  18343. * Particle emitter emitting particles from a point.
  18344. * It emits the particles randomly between 2 given directions.
  18345. */
  18346. export class PointParticleEmitter implements IParticleEmitterType {
  18347. /**
  18348. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18349. */
  18350. direction1: Vector3;
  18351. /**
  18352. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18353. */
  18354. direction2: Vector3;
  18355. /**
  18356. * Creates a new instance PointParticleEmitter
  18357. */
  18358. constructor();
  18359. /**
  18360. * Called by the particle System when the direction is computed for the created particle.
  18361. * @param worldMatrix is the world matrix of the particle system
  18362. * @param directionToUpdate is the direction vector to update with the result
  18363. * @param particle is the particle we are computed the direction for
  18364. */
  18365. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18366. /**
  18367. * Called by the particle System when the position is computed for the created particle.
  18368. * @param worldMatrix is the world matrix of the particle system
  18369. * @param positionToUpdate is the position vector to update with the result
  18370. * @param particle is the particle we are computed the position for
  18371. */
  18372. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18373. /**
  18374. * Clones the current emitter and returns a copy of it
  18375. * @returns the new emitter
  18376. */
  18377. clone(): PointParticleEmitter;
  18378. /**
  18379. * Called by the GPUParticleSystem to setup the update shader
  18380. * @param effect defines the update shader
  18381. */
  18382. applyToShader(effect: Effect): void;
  18383. /**
  18384. * Returns a string to use to update the GPU particles update shader
  18385. * @returns a string containng the defines string
  18386. */
  18387. getEffectDefines(): string;
  18388. /**
  18389. * Returns the string "PointParticleEmitter"
  18390. * @returns a string containing the class name
  18391. */
  18392. getClassName(): string;
  18393. /**
  18394. * Serializes the particle system to a JSON object.
  18395. * @returns the JSON object
  18396. */
  18397. serialize(): any;
  18398. /**
  18399. * Parse properties from a JSON object
  18400. * @param serializationObject defines the JSON object
  18401. */
  18402. parse(serializationObject: any): void;
  18403. }
  18404. }
  18405. declare module BABYLON {
  18406. /**
  18407. * Particle emitter emitting particles from the inside of a sphere.
  18408. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18409. */
  18410. export class SphereParticleEmitter implements IParticleEmitterType {
  18411. /**
  18412. * The radius of the emission sphere.
  18413. */
  18414. radius: number;
  18415. /**
  18416. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18417. */
  18418. radiusRange: number;
  18419. /**
  18420. * How much to randomize the particle direction [0-1].
  18421. */
  18422. directionRandomizer: number;
  18423. /**
  18424. * Creates a new instance SphereParticleEmitter
  18425. * @param radius the radius of the emission sphere (1 by default)
  18426. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18427. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18428. */
  18429. constructor(
  18430. /**
  18431. * The radius of the emission sphere.
  18432. */
  18433. radius?: number,
  18434. /**
  18435. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18436. */
  18437. radiusRange?: number,
  18438. /**
  18439. * How much to randomize the particle direction [0-1].
  18440. */
  18441. directionRandomizer?: number);
  18442. /**
  18443. * Called by the particle System when the direction is computed for the created particle.
  18444. * @param worldMatrix is the world matrix of the particle system
  18445. * @param directionToUpdate is the direction vector to update with the result
  18446. * @param particle is the particle we are computed the direction for
  18447. */
  18448. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18449. /**
  18450. * Called by the particle System when the position is computed for the created particle.
  18451. * @param worldMatrix is the world matrix of the particle system
  18452. * @param positionToUpdate is the position vector to update with the result
  18453. * @param particle is the particle we are computed the position for
  18454. */
  18455. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18456. /**
  18457. * Clones the current emitter and returns a copy of it
  18458. * @returns the new emitter
  18459. */
  18460. clone(): SphereParticleEmitter;
  18461. /**
  18462. * Called by the GPUParticleSystem to setup the update shader
  18463. * @param effect defines the update shader
  18464. */
  18465. applyToShader(effect: Effect): void;
  18466. /**
  18467. * Returns a string to use to update the GPU particles update shader
  18468. * @returns a string containng the defines string
  18469. */
  18470. getEffectDefines(): string;
  18471. /**
  18472. * Returns the string "SphereParticleEmitter"
  18473. * @returns a string containing the class name
  18474. */
  18475. getClassName(): string;
  18476. /**
  18477. * Serializes the particle system to a JSON object.
  18478. * @returns the JSON object
  18479. */
  18480. serialize(): any;
  18481. /**
  18482. * Parse properties from a JSON object
  18483. * @param serializationObject defines the JSON object
  18484. */
  18485. parse(serializationObject: any): void;
  18486. }
  18487. /**
  18488. * Particle emitter emitting particles from the inside of a sphere.
  18489. * It emits the particles randomly between two vectors.
  18490. */
  18491. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  18492. /**
  18493. * The min limit of the emission direction.
  18494. */
  18495. direction1: Vector3;
  18496. /**
  18497. * The max limit of the emission direction.
  18498. */
  18499. direction2: Vector3;
  18500. /**
  18501. * Creates a new instance SphereDirectedParticleEmitter
  18502. * @param radius the radius of the emission sphere (1 by default)
  18503. * @param direction1 the min limit of the emission direction (up vector by default)
  18504. * @param direction2 the max limit of the emission direction (up vector by default)
  18505. */
  18506. constructor(radius?: number,
  18507. /**
  18508. * The min limit of the emission direction.
  18509. */
  18510. direction1?: Vector3,
  18511. /**
  18512. * The max limit of the emission direction.
  18513. */
  18514. direction2?: Vector3);
  18515. /**
  18516. * Called by the particle System when the direction is computed for the created particle.
  18517. * @param worldMatrix is the world matrix of the particle system
  18518. * @param directionToUpdate is the direction vector to update with the result
  18519. * @param particle is the particle we are computed the direction for
  18520. */
  18521. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18522. /**
  18523. * Clones the current emitter and returns a copy of it
  18524. * @returns the new emitter
  18525. */
  18526. clone(): SphereDirectedParticleEmitter;
  18527. /**
  18528. * Called by the GPUParticleSystem to setup the update shader
  18529. * @param effect defines the update shader
  18530. */
  18531. applyToShader(effect: Effect): void;
  18532. /**
  18533. * Returns a string to use to update the GPU particles update shader
  18534. * @returns a string containng the defines string
  18535. */
  18536. getEffectDefines(): string;
  18537. /**
  18538. * Returns the string "SphereDirectedParticleEmitter"
  18539. * @returns a string containing the class name
  18540. */
  18541. getClassName(): string;
  18542. /**
  18543. * Serializes the particle system to a JSON object.
  18544. * @returns the JSON object
  18545. */
  18546. serialize(): any;
  18547. /**
  18548. * Parse properties from a JSON object
  18549. * @param serializationObject defines the JSON object
  18550. */
  18551. parse(serializationObject: any): void;
  18552. }
  18553. }
  18554. declare module BABYLON {
  18555. /**
  18556. * Interface representing a particle system in Babylon.js.
  18557. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18558. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18559. */
  18560. export interface IParticleSystem {
  18561. /**
  18562. * List of animations used by the particle system.
  18563. */
  18564. animations: Animation[];
  18565. /**
  18566. * The id of the Particle system.
  18567. */
  18568. id: string;
  18569. /**
  18570. * The name of the Particle system.
  18571. */
  18572. name: string;
  18573. /**
  18574. * The emitter represents the Mesh or position we are attaching the particle system to.
  18575. */
  18576. emitter: Nullable<AbstractMesh | Vector3>;
  18577. /**
  18578. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18579. */
  18580. isBillboardBased: boolean;
  18581. /**
  18582. * The rendering group used by the Particle system to chose when to render.
  18583. */
  18584. renderingGroupId: number;
  18585. /**
  18586. * The layer mask we are rendering the particles through.
  18587. */
  18588. layerMask: number;
  18589. /**
  18590. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18591. */
  18592. updateSpeed: number;
  18593. /**
  18594. * The amount of time the particle system is running (depends of the overall update speed).
  18595. */
  18596. targetStopDuration: number;
  18597. /**
  18598. * The texture used to render each particle. (this can be a spritesheet)
  18599. */
  18600. particleTexture: Nullable<Texture>;
  18601. /**
  18602. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18603. */
  18604. blendMode: number;
  18605. /**
  18606. * Minimum life time of emitting particles.
  18607. */
  18608. minLifeTime: number;
  18609. /**
  18610. * Maximum life time of emitting particles.
  18611. */
  18612. maxLifeTime: number;
  18613. /**
  18614. * Minimum Size of emitting particles.
  18615. */
  18616. minSize: number;
  18617. /**
  18618. * Maximum Size of emitting particles.
  18619. */
  18620. maxSize: number;
  18621. /**
  18622. * Minimum scale of emitting particles on X axis.
  18623. */
  18624. minScaleX: number;
  18625. /**
  18626. * Maximum scale of emitting particles on X axis.
  18627. */
  18628. maxScaleX: number;
  18629. /**
  18630. * Minimum scale of emitting particles on Y axis.
  18631. */
  18632. minScaleY: number;
  18633. /**
  18634. * Maximum scale of emitting particles on Y axis.
  18635. */
  18636. maxScaleY: number;
  18637. /**
  18638. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18639. */
  18640. color1: Color4;
  18641. /**
  18642. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18643. */
  18644. color2: Color4;
  18645. /**
  18646. * Color the particle will have at the end of its lifetime.
  18647. */
  18648. colorDead: Color4;
  18649. /**
  18650. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18651. */
  18652. emitRate: number;
  18653. /**
  18654. * You can use gravity if you want to give an orientation to your particles.
  18655. */
  18656. gravity: Vector3;
  18657. /**
  18658. * Minimum power of emitting particles.
  18659. */
  18660. minEmitPower: number;
  18661. /**
  18662. * Maximum power of emitting particles.
  18663. */
  18664. maxEmitPower: number;
  18665. /**
  18666. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18667. */
  18668. minAngularSpeed: number;
  18669. /**
  18670. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18671. */
  18672. maxAngularSpeed: number;
  18673. /**
  18674. * Gets or sets the minimal initial rotation in radians.
  18675. */
  18676. minInitialRotation: number;
  18677. /**
  18678. * Gets or sets the maximal initial rotation in radians.
  18679. */
  18680. maxInitialRotation: number;
  18681. /**
  18682. * The particle emitter type defines the emitter used by the particle system.
  18683. * It can be for example box, sphere, or cone...
  18684. */
  18685. particleEmitterType: Nullable<IParticleEmitterType>;
  18686. /**
  18687. * Defines the delay in milliseconds before starting the system (0 by default)
  18688. */
  18689. startDelay: number;
  18690. /**
  18691. * 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
  18692. */
  18693. preWarmCycles: number;
  18694. /**
  18695. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  18696. */
  18697. preWarmStepOffset: number;
  18698. /**
  18699. * 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)
  18700. */
  18701. spriteCellChangeSpeed: number;
  18702. /**
  18703. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18704. */
  18705. startSpriteCellID: number;
  18706. /**
  18707. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18708. */
  18709. endSpriteCellID: number;
  18710. /**
  18711. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18712. */
  18713. spriteCellWidth: number;
  18714. /**
  18715. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18716. */
  18717. spriteCellHeight: number;
  18718. /**
  18719. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18720. */
  18721. spriteRandomStartCell: boolean;
  18722. /**
  18723. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  18724. */
  18725. isAnimationSheetEnabled: boolean;
  18726. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18727. translationPivot: Vector2;
  18728. /**
  18729. * Gets or sets a texture used to add random noise to particle positions
  18730. */
  18731. noiseTexture: Nullable<BaseTexture>;
  18732. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  18733. noiseStrength: Vector3;
  18734. /**
  18735. * Gets or sets the billboard mode to use when isBillboardBased = true.
  18736. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  18737. */
  18738. billboardMode: number;
  18739. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  18740. limitVelocityDamping: number;
  18741. /**
  18742. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  18743. */
  18744. beginAnimationOnStart: boolean;
  18745. /**
  18746. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  18747. */
  18748. beginAnimationFrom: number;
  18749. /**
  18750. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  18751. */
  18752. beginAnimationTo: number;
  18753. /**
  18754. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  18755. */
  18756. beginAnimationLoop: boolean;
  18757. /**
  18758. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  18759. */
  18760. disposeOnStop: boolean;
  18761. /**
  18762. * Gets the maximum number of particles active at the same time.
  18763. * @returns The max number of active particles.
  18764. */
  18765. getCapacity(): number;
  18766. /**
  18767. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18768. * @returns True if it has been started, otherwise false.
  18769. */
  18770. isStarted(): boolean;
  18771. /**
  18772. * Animates the particle system for this frame.
  18773. */
  18774. animate(): void;
  18775. /**
  18776. * Renders the particle system in its current state.
  18777. * @returns the current number of particles
  18778. */
  18779. render(): number;
  18780. /**
  18781. * Dispose the particle system and frees its associated resources.
  18782. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18783. */
  18784. dispose(disposeTexture?: boolean): void;
  18785. /**
  18786. * Clones the particle system.
  18787. * @param name The name of the cloned object
  18788. * @param newEmitter The new emitter to use
  18789. * @returns the cloned particle system
  18790. */
  18791. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  18792. /**
  18793. * Serializes the particle system to a JSON object.
  18794. * @returns the JSON object
  18795. */
  18796. serialize(): any;
  18797. /**
  18798. * Rebuild the particle system
  18799. */
  18800. rebuild(): void;
  18801. /**
  18802. * Starts the particle system and begins to emit
  18803. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  18804. */
  18805. start(delay?: number): void;
  18806. /**
  18807. * Stops the particle system.
  18808. */
  18809. stop(): void;
  18810. /**
  18811. * Remove all active particles
  18812. */
  18813. reset(): void;
  18814. /**
  18815. * Is this system ready to be used/rendered
  18816. * @return true if the system is ready
  18817. */
  18818. isReady(): boolean;
  18819. /**
  18820. * Adds a new color gradient
  18821. * @param gradient defines the gradient to use (between 0 and 1)
  18822. * @param color1 defines the color to affect to the specified gradient
  18823. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  18824. * @returns the current particle system
  18825. */
  18826. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  18827. /**
  18828. * Remove a specific color gradient
  18829. * @param gradient defines the gradient to remove
  18830. * @returns the current particle system
  18831. */
  18832. removeColorGradient(gradient: number): IParticleSystem;
  18833. /**
  18834. * Adds a new size gradient
  18835. * @param gradient defines the gradient to use (between 0 and 1)
  18836. * @param factor defines the size factor to affect to the specified gradient
  18837. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18838. * @returns the current particle system
  18839. */
  18840. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18841. /**
  18842. * Remove a specific size gradient
  18843. * @param gradient defines the gradient to remove
  18844. * @returns the current particle system
  18845. */
  18846. removeSizeGradient(gradient: number): IParticleSystem;
  18847. /**
  18848. * Gets the current list of color gradients.
  18849. * You must use addColorGradient and removeColorGradient to udpate this list
  18850. * @returns the list of color gradients
  18851. */
  18852. getColorGradients(): Nullable<Array<ColorGradient>>;
  18853. /**
  18854. * Gets the current list of size gradients.
  18855. * You must use addSizeGradient and removeSizeGradient to udpate this list
  18856. * @returns the list of size gradients
  18857. */
  18858. getSizeGradients(): Nullable<Array<FactorGradient>>;
  18859. /**
  18860. * Gets the current list of angular speed gradients.
  18861. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  18862. * @returns the list of angular speed gradients
  18863. */
  18864. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  18865. /**
  18866. * Adds a new angular speed gradient
  18867. * @param gradient defines the gradient to use (between 0 and 1)
  18868. * @param factor defines the angular speed to affect to the specified gradient
  18869. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18870. * @returns the current particle system
  18871. */
  18872. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18873. /**
  18874. * Remove a specific angular speed gradient
  18875. * @param gradient defines the gradient to remove
  18876. * @returns the current particle system
  18877. */
  18878. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  18879. /**
  18880. * Gets the current list of velocity gradients.
  18881. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  18882. * @returns the list of velocity gradients
  18883. */
  18884. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  18885. /**
  18886. * Adds a new velocity gradient
  18887. * @param gradient defines the gradient to use (between 0 and 1)
  18888. * @param factor defines the velocity to affect to the specified gradient
  18889. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18890. * @returns the current particle system
  18891. */
  18892. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18893. /**
  18894. * Remove a specific velocity gradient
  18895. * @param gradient defines the gradient to remove
  18896. * @returns the current particle system
  18897. */
  18898. removeVelocityGradient(gradient: number): IParticleSystem;
  18899. /**
  18900. * Gets the current list of limit velocity gradients.
  18901. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  18902. * @returns the list of limit velocity gradients
  18903. */
  18904. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  18905. /**
  18906. * Adds a new limit velocity gradient
  18907. * @param gradient defines the gradient to use (between 0 and 1)
  18908. * @param factor defines the limit velocity to affect to the specified gradient
  18909. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18910. * @returns the current particle system
  18911. */
  18912. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18913. /**
  18914. * Remove a specific limit velocity gradient
  18915. * @param gradient defines the gradient to remove
  18916. * @returns the current particle system
  18917. */
  18918. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  18919. /**
  18920. * Adds a new drag gradient
  18921. * @param gradient defines the gradient to use (between 0 and 1)
  18922. * @param factor defines the drag to affect to the specified gradient
  18923. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18924. * @returns the current particle system
  18925. */
  18926. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18927. /**
  18928. * Remove a specific drag gradient
  18929. * @param gradient defines the gradient to remove
  18930. * @returns the current particle system
  18931. */
  18932. removeDragGradient(gradient: number): IParticleSystem;
  18933. /**
  18934. * Gets the current list of drag gradients.
  18935. * You must use addDragGradient and removeDragGradient to udpate this list
  18936. * @returns the list of drag gradients
  18937. */
  18938. getDragGradients(): Nullable<Array<FactorGradient>>;
  18939. /**
  18940. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  18941. * @param gradient defines the gradient to use (between 0 and 1)
  18942. * @param factor defines the emit rate to affect to the specified gradient
  18943. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18944. * @returns the current particle system
  18945. */
  18946. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18947. /**
  18948. * Remove a specific emit rate gradient
  18949. * @param gradient defines the gradient to remove
  18950. * @returns the current particle system
  18951. */
  18952. removeEmitRateGradient(gradient: number): IParticleSystem;
  18953. /**
  18954. * Gets the current list of emit rate gradients.
  18955. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  18956. * @returns the list of emit rate gradients
  18957. */
  18958. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  18959. /**
  18960. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  18961. * @param gradient defines the gradient to use (between 0 and 1)
  18962. * @param factor defines the start size to affect to the specified gradient
  18963. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18964. * @returns the current particle system
  18965. */
  18966. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18967. /**
  18968. * Remove a specific start size gradient
  18969. * @param gradient defines the gradient to remove
  18970. * @returns the current particle system
  18971. */
  18972. removeStartSizeGradient(gradient: number): IParticleSystem;
  18973. /**
  18974. * Gets the current list of start size gradients.
  18975. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  18976. * @returns the list of start size gradients
  18977. */
  18978. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  18979. /**
  18980. * Adds a new life time gradient
  18981. * @param gradient defines the gradient to use (between 0 and 1)
  18982. * @param factor defines the life time factor to affect to the specified gradient
  18983. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18984. * @returns the current particle system
  18985. */
  18986. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18987. /**
  18988. * Remove a specific life time gradient
  18989. * @param gradient defines the gradient to remove
  18990. * @returns the current particle system
  18991. */
  18992. removeLifeTimeGradient(gradient: number): IParticleSystem;
  18993. /**
  18994. * Gets the current list of life time gradients.
  18995. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  18996. * @returns the list of life time gradients
  18997. */
  18998. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  18999. /**
  19000. * Gets the current list of color gradients.
  19001. * You must use addColorGradient and removeColorGradient to udpate this list
  19002. * @returns the list of color gradients
  19003. */
  19004. getColorGradients(): Nullable<Array<ColorGradient>>;
  19005. /**
  19006. * Adds a new ramp gradient used to remap particle colors
  19007. * @param gradient defines the gradient to use (between 0 and 1)
  19008. * @param color defines the color to affect to the specified gradient
  19009. * @returns the current particle system
  19010. */
  19011. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  19012. /**
  19013. * Gets the current list of ramp gradients.
  19014. * You must use addRampGradient and removeRampGradient to udpate this list
  19015. * @returns the list of ramp gradients
  19016. */
  19017. getRampGradients(): Nullable<Array<Color3Gradient>>;
  19018. /** Gets or sets a boolean indicating that ramp gradients must be used
  19019. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  19020. */
  19021. useRampGradients: boolean;
  19022. /**
  19023. * Adds a new color remap gradient
  19024. * @param gradient defines the gradient to use (between 0 and 1)
  19025. * @param min defines the color remap minimal range
  19026. * @param max defines the color remap maximal range
  19027. * @returns the current particle system
  19028. */
  19029. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19030. /**
  19031. * Gets the current list of color remap gradients.
  19032. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  19033. * @returns the list of color remap gradients
  19034. */
  19035. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  19036. /**
  19037. * Adds a new alpha remap gradient
  19038. * @param gradient defines the gradient to use (between 0 and 1)
  19039. * @param min defines the alpha remap minimal range
  19040. * @param max defines the alpha remap maximal range
  19041. * @returns the current particle system
  19042. */
  19043. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19044. /**
  19045. * Gets the current list of alpha remap gradients.
  19046. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  19047. * @returns the list of alpha remap gradients
  19048. */
  19049. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  19050. /**
  19051. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  19052. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19053. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19054. * @returns the emitter
  19055. */
  19056. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  19057. /**
  19058. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  19059. * @param radius The radius of the hemisphere to emit from
  19060. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19061. * @returns the emitter
  19062. */
  19063. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  19064. /**
  19065. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  19066. * @param radius The radius of the sphere to emit from
  19067. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19068. * @returns the emitter
  19069. */
  19070. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  19071. /**
  19072. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  19073. * @param radius The radius of the sphere to emit from
  19074. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  19075. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  19076. * @returns the emitter
  19077. */
  19078. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19079. /**
  19080. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  19081. * @param radius The radius of the emission cylinder
  19082. * @param height The height of the emission cylinder
  19083. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  19084. * @param directionRandomizer How much to randomize the particle direction [0-1]
  19085. * @returns the emitter
  19086. */
  19087. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  19088. /**
  19089. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  19090. * @param radius The radius of the cylinder to emit from
  19091. * @param height The height of the emission cylinder
  19092. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  19093. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  19094. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  19095. * @returns the emitter
  19096. */
  19097. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19098. /**
  19099. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  19100. * @param radius The radius of the cone to emit from
  19101. * @param angle The base angle of the cone
  19102. * @returns the emitter
  19103. */
  19104. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  19105. /**
  19106. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  19107. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19108. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19109. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19110. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19111. * @returns the emitter
  19112. */
  19113. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  19114. /**
  19115. * Get hosting scene
  19116. * @returns the scene
  19117. */
  19118. getScene(): Scene;
  19119. }
  19120. }
  19121. declare module BABYLON {
  19122. /**
  19123. * Creates an instance based on a source mesh.
  19124. */
  19125. export class InstancedMesh extends AbstractMesh {
  19126. private _sourceMesh;
  19127. private _currentLOD;
  19128. /** @hidden */
  19129. _indexInSourceMeshInstanceArray: number;
  19130. constructor(name: string, source: Mesh);
  19131. /**
  19132. * Returns the string "InstancedMesh".
  19133. */
  19134. getClassName(): string;
  19135. /** Gets the list of lights affecting that mesh */
  19136. get lightSources(): Light[];
  19137. _resyncLightSources(): void;
  19138. _resyncLightSource(light: Light): void;
  19139. _removeLightSource(light: Light, dispose: boolean): void;
  19140. /**
  19141. * If the source mesh receives shadows
  19142. */
  19143. get receiveShadows(): boolean;
  19144. /**
  19145. * The material of the source mesh
  19146. */
  19147. get material(): Nullable<Material>;
  19148. /**
  19149. * Visibility of the source mesh
  19150. */
  19151. get visibility(): number;
  19152. /**
  19153. * Skeleton of the source mesh
  19154. */
  19155. get skeleton(): Nullable<Skeleton>;
  19156. /**
  19157. * Rendering ground id of the source mesh
  19158. */
  19159. get renderingGroupId(): number;
  19160. set renderingGroupId(value: number);
  19161. /**
  19162. * Returns the total number of vertices (integer).
  19163. */
  19164. getTotalVertices(): number;
  19165. /**
  19166. * Returns a positive integer : the total number of indices in this mesh geometry.
  19167. * @returns the numner of indices or zero if the mesh has no geometry.
  19168. */
  19169. getTotalIndices(): number;
  19170. /**
  19171. * The source mesh of the instance
  19172. */
  19173. get sourceMesh(): Mesh;
  19174. /**
  19175. * Is this node ready to be used/rendered
  19176. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19177. * @return {boolean} is it ready
  19178. */
  19179. isReady(completeCheck?: boolean): boolean;
  19180. /**
  19181. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19182. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  19183. * @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.
  19184. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  19185. */
  19186. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  19187. /**
  19188. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19189. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19190. * The `data` are either a numeric array either a Float32Array.
  19191. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  19192. * 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).
  19193. * Note that a new underlying VertexBuffer object is created each call.
  19194. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19195. *
  19196. * Possible `kind` values :
  19197. * - VertexBuffer.PositionKind
  19198. * - VertexBuffer.UVKind
  19199. * - VertexBuffer.UV2Kind
  19200. * - VertexBuffer.UV3Kind
  19201. * - VertexBuffer.UV4Kind
  19202. * - VertexBuffer.UV5Kind
  19203. * - VertexBuffer.UV6Kind
  19204. * - VertexBuffer.ColorKind
  19205. * - VertexBuffer.MatricesIndicesKind
  19206. * - VertexBuffer.MatricesIndicesExtraKind
  19207. * - VertexBuffer.MatricesWeightsKind
  19208. * - VertexBuffer.MatricesWeightsExtraKind
  19209. *
  19210. * Returns the Mesh.
  19211. */
  19212. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  19213. /**
  19214. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19215. * If the mesh has no geometry, it is simply returned as it is.
  19216. * The `data` are either a numeric array either a Float32Array.
  19217. * No new underlying VertexBuffer object is created.
  19218. * 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.
  19219. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  19220. *
  19221. * Possible `kind` values :
  19222. * - VertexBuffer.PositionKind
  19223. * - VertexBuffer.UVKind
  19224. * - VertexBuffer.UV2Kind
  19225. * - VertexBuffer.UV3Kind
  19226. * - VertexBuffer.UV4Kind
  19227. * - VertexBuffer.UV5Kind
  19228. * - VertexBuffer.UV6Kind
  19229. * - VertexBuffer.ColorKind
  19230. * - VertexBuffer.MatricesIndicesKind
  19231. * - VertexBuffer.MatricesIndicesExtraKind
  19232. * - VertexBuffer.MatricesWeightsKind
  19233. * - VertexBuffer.MatricesWeightsExtraKind
  19234. *
  19235. * Returns the Mesh.
  19236. */
  19237. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19238. /**
  19239. * Sets the mesh indices.
  19240. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  19241. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19242. * This method creates a new index buffer each call.
  19243. * Returns the Mesh.
  19244. */
  19245. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  19246. /**
  19247. * Boolean : True if the mesh owns the requested kind of data.
  19248. */
  19249. isVerticesDataPresent(kind: string): boolean;
  19250. /**
  19251. * Returns an array of indices (IndicesArray).
  19252. */
  19253. getIndices(): Nullable<IndicesArray>;
  19254. get _positions(): Nullable<Vector3[]>;
  19255. /**
  19256. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19257. * This means the mesh underlying bounding box and sphere are recomputed.
  19258. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19259. * @returns the current mesh
  19260. */
  19261. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  19262. /** @hidden */
  19263. _preActivate(): InstancedMesh;
  19264. /** @hidden */
  19265. _activate(renderId: number, intermediateRendering: boolean): boolean;
  19266. /** @hidden */
  19267. _postActivate(): void;
  19268. getWorldMatrix(): Matrix;
  19269. get isAnInstance(): boolean;
  19270. /**
  19271. * Returns the current associated LOD AbstractMesh.
  19272. */
  19273. getLOD(camera: Camera): AbstractMesh;
  19274. /** @hidden */
  19275. _syncSubMeshes(): InstancedMesh;
  19276. /** @hidden */
  19277. _generatePointsArray(): boolean;
  19278. /**
  19279. * Creates a new InstancedMesh from the current mesh.
  19280. * - name (string) : the cloned mesh name
  19281. * - newParent (optional Node) : the optional Node to parent the clone to.
  19282. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  19283. *
  19284. * Returns the clone.
  19285. */
  19286. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19287. /**
  19288. * Disposes the InstancedMesh.
  19289. * Returns nothing.
  19290. */
  19291. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19292. }
  19293. interface Mesh {
  19294. /**
  19295. * Register a custom buffer that will be instanced
  19296. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19297. * @param kind defines the buffer kind
  19298. * @param stride defines the stride in floats
  19299. */
  19300. registerInstancedBuffer(kind: string, stride: number): void;
  19301. /** @hidden */
  19302. _userInstancedBuffersStorage: {
  19303. data: {
  19304. [key: string]: Float32Array;
  19305. };
  19306. sizes: {
  19307. [key: string]: number;
  19308. };
  19309. vertexBuffers: {
  19310. [key: string]: Nullable<VertexBuffer>;
  19311. };
  19312. strides: {
  19313. [key: string]: number;
  19314. };
  19315. };
  19316. }
  19317. interface AbstractMesh {
  19318. /**
  19319. * Object used to store instanced buffers defined by user
  19320. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19321. */
  19322. instancedBuffers: {
  19323. [key: string]: any;
  19324. };
  19325. }
  19326. }
  19327. declare module BABYLON {
  19328. /**
  19329. * Defines the options associated with the creation of a shader material.
  19330. */
  19331. export interface IShaderMaterialOptions {
  19332. /**
  19333. * Does the material work in alpha blend mode
  19334. */
  19335. needAlphaBlending: boolean;
  19336. /**
  19337. * Does the material work in alpha test mode
  19338. */
  19339. needAlphaTesting: boolean;
  19340. /**
  19341. * The list of attribute names used in the shader
  19342. */
  19343. attributes: string[];
  19344. /**
  19345. * The list of unifrom names used in the shader
  19346. */
  19347. uniforms: string[];
  19348. /**
  19349. * The list of UBO names used in the shader
  19350. */
  19351. uniformBuffers: string[];
  19352. /**
  19353. * The list of sampler names used in the shader
  19354. */
  19355. samplers: string[];
  19356. /**
  19357. * The list of defines used in the shader
  19358. */
  19359. defines: string[];
  19360. }
  19361. /**
  19362. * 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.
  19363. *
  19364. * This returned material effects how the mesh will look based on the code in the shaders.
  19365. *
  19366. * @see http://doc.babylonjs.com/how_to/shader_material
  19367. */
  19368. export class ShaderMaterial extends Material {
  19369. private _shaderPath;
  19370. private _options;
  19371. private _textures;
  19372. private _textureArrays;
  19373. private _floats;
  19374. private _ints;
  19375. private _floatsArrays;
  19376. private _colors3;
  19377. private _colors3Arrays;
  19378. private _colors4;
  19379. private _colors4Arrays;
  19380. private _vectors2;
  19381. private _vectors3;
  19382. private _vectors4;
  19383. private _matrices;
  19384. private _matrixArrays;
  19385. private _matrices3x3;
  19386. private _matrices2x2;
  19387. private _vectors2Arrays;
  19388. private _vectors3Arrays;
  19389. private _vectors4Arrays;
  19390. private _cachedWorldViewMatrix;
  19391. private _cachedWorldViewProjectionMatrix;
  19392. private _renderId;
  19393. private _multiview;
  19394. /**
  19395. * Instantiate a new shader material.
  19396. * 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.
  19397. * This returned material effects how the mesh will look based on the code in the shaders.
  19398. * @see http://doc.babylonjs.com/how_to/shader_material
  19399. * @param name Define the name of the material in the scene
  19400. * @param scene Define the scene the material belongs to
  19401. * @param shaderPath Defines the route to the shader code in one of three ways:
  19402. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  19403. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  19404. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  19405. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19406. * @param options Define the options used to create the shader
  19407. */
  19408. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19409. /**
  19410. * Gets the shader path used to define the shader code
  19411. * It can be modified to trigger a new compilation
  19412. */
  19413. get shaderPath(): any;
  19414. /**
  19415. * Sets the shader path used to define the shader code
  19416. * It can be modified to trigger a new compilation
  19417. */
  19418. set shaderPath(shaderPath: any);
  19419. /**
  19420. * Gets the options used to compile the shader.
  19421. * They can be modified to trigger a new compilation
  19422. */
  19423. get options(): IShaderMaterialOptions;
  19424. /**
  19425. * Gets the current class name of the material e.g. "ShaderMaterial"
  19426. * Mainly use in serialization.
  19427. * @returns the class name
  19428. */
  19429. getClassName(): string;
  19430. /**
  19431. * Specifies if the material will require alpha blending
  19432. * @returns a boolean specifying if alpha blending is needed
  19433. */
  19434. needAlphaBlending(): boolean;
  19435. /**
  19436. * Specifies if this material should be rendered in alpha test mode
  19437. * @returns a boolean specifying if an alpha test is needed.
  19438. */
  19439. needAlphaTesting(): boolean;
  19440. private _checkUniform;
  19441. /**
  19442. * Set a texture in the shader.
  19443. * @param name Define the name of the uniform samplers as defined in the shader
  19444. * @param texture Define the texture to bind to this sampler
  19445. * @return the material itself allowing "fluent" like uniform updates
  19446. */
  19447. setTexture(name: string, texture: Texture): ShaderMaterial;
  19448. /**
  19449. * Set a texture array in the shader.
  19450. * @param name Define the name of the uniform sampler array as defined in the shader
  19451. * @param textures Define the list of textures to bind to this sampler
  19452. * @return the material itself allowing "fluent" like uniform updates
  19453. */
  19454. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19455. /**
  19456. * Set a float in the shader.
  19457. * @param name Define the name of the uniform as defined in the shader
  19458. * @param value Define the value to give to the uniform
  19459. * @return the material itself allowing "fluent" like uniform updates
  19460. */
  19461. setFloat(name: string, value: number): ShaderMaterial;
  19462. /**
  19463. * Set a int in the shader.
  19464. * @param name Define the name of the uniform as defined in the shader
  19465. * @param value Define the value to give to the uniform
  19466. * @return the material itself allowing "fluent" like uniform updates
  19467. */
  19468. setInt(name: string, value: number): ShaderMaterial;
  19469. /**
  19470. * Set an array of floats in the shader.
  19471. * @param name Define the name of the uniform as defined in the shader
  19472. * @param value Define the value to give to the uniform
  19473. * @return the material itself allowing "fluent" like uniform updates
  19474. */
  19475. setFloats(name: string, value: number[]): ShaderMaterial;
  19476. /**
  19477. * Set a vec3 in the shader from a Color3.
  19478. * @param name Define the name of the uniform as defined in the shader
  19479. * @param value Define the value to give to the uniform
  19480. * @return the material itself allowing "fluent" like uniform updates
  19481. */
  19482. setColor3(name: string, value: Color3): ShaderMaterial;
  19483. /**
  19484. * Set a vec3 array in the shader from a Color3 array.
  19485. * @param name Define the name of the uniform as defined in the shader
  19486. * @param value Define the value to give to the uniform
  19487. * @return the material itself allowing "fluent" like uniform updates
  19488. */
  19489. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19490. /**
  19491. * Set a vec4 in the shader from a Color4.
  19492. * @param name Define the name of the uniform as defined in the shader
  19493. * @param value Define the value to give to the uniform
  19494. * @return the material itself allowing "fluent" like uniform updates
  19495. */
  19496. setColor4(name: string, value: Color4): ShaderMaterial;
  19497. /**
  19498. * Set a vec4 array in the shader from a Color4 array.
  19499. * @param name Define the name of the uniform as defined in the shader
  19500. * @param value Define the value to give to the uniform
  19501. * @return the material itself allowing "fluent" like uniform updates
  19502. */
  19503. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  19504. /**
  19505. * Set a vec2 in the shader from a Vector2.
  19506. * @param name Define the name of the uniform as defined in the shader
  19507. * @param value Define the value to give to the uniform
  19508. * @return the material itself allowing "fluent" like uniform updates
  19509. */
  19510. setVector2(name: string, value: Vector2): ShaderMaterial;
  19511. /**
  19512. * Set a vec3 in the shader from a Vector3.
  19513. * @param name Define the name of the uniform as defined in the shader
  19514. * @param value Define the value to give to the uniform
  19515. * @return the material itself allowing "fluent" like uniform updates
  19516. */
  19517. setVector3(name: string, value: Vector3): ShaderMaterial;
  19518. /**
  19519. * Set a vec4 in the shader from a Vector4.
  19520. * @param name Define the name of the uniform as defined in the shader
  19521. * @param value Define the value to give to the uniform
  19522. * @return the material itself allowing "fluent" like uniform updates
  19523. */
  19524. setVector4(name: string, value: Vector4): ShaderMaterial;
  19525. /**
  19526. * Set a mat4 in the shader from a Matrix.
  19527. * @param name Define the name of the uniform as defined in the shader
  19528. * @param value Define the value to give to the uniform
  19529. * @return the material itself allowing "fluent" like uniform updates
  19530. */
  19531. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19532. /**
  19533. * Set a float32Array in the shader from a matrix array.
  19534. * @param name Define the name of the uniform as defined in the shader
  19535. * @param value Define the value to give to the uniform
  19536. * @return the material itself allowing "fluent" like uniform updates
  19537. */
  19538. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  19539. /**
  19540. * Set a mat3 in the shader from a Float32Array.
  19541. * @param name Define the name of the uniform as defined in the shader
  19542. * @param value Define the value to give to the uniform
  19543. * @return the material itself allowing "fluent" like uniform updates
  19544. */
  19545. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19546. /**
  19547. * Set a mat2 in the shader from a Float32Array.
  19548. * @param name Define the name of the uniform as defined in the shader
  19549. * @param value Define the value to give to the uniform
  19550. * @return the material itself allowing "fluent" like uniform updates
  19551. */
  19552. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19553. /**
  19554. * Set a vec2 array in the shader from a number array.
  19555. * @param name Define the name of the uniform as defined in the shader
  19556. * @param value Define the value to give to the uniform
  19557. * @return the material itself allowing "fluent" like uniform updates
  19558. */
  19559. setArray2(name: string, value: number[]): ShaderMaterial;
  19560. /**
  19561. * Set a vec3 array in the shader from a number array.
  19562. * @param name Define the name of the uniform as defined in the shader
  19563. * @param value Define the value to give to the uniform
  19564. * @return the material itself allowing "fluent" like uniform updates
  19565. */
  19566. setArray3(name: string, value: number[]): ShaderMaterial;
  19567. /**
  19568. * Set a vec4 array in the shader from a number array.
  19569. * @param name Define the name of the uniform as defined in the shader
  19570. * @param value Define the value to give to the uniform
  19571. * @return the material itself allowing "fluent" like uniform updates
  19572. */
  19573. setArray4(name: string, value: number[]): ShaderMaterial;
  19574. private _checkCache;
  19575. /**
  19576. * Specifies that the submesh is ready to be used
  19577. * @param mesh defines the mesh to check
  19578. * @param subMesh defines which submesh to check
  19579. * @param useInstances specifies that instances should be used
  19580. * @returns a boolean indicating that the submesh is ready or not
  19581. */
  19582. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  19583. /**
  19584. * Checks if the material is ready to render the requested mesh
  19585. * @param mesh Define the mesh to render
  19586. * @param useInstances Define whether or not the material is used with instances
  19587. * @returns true if ready, otherwise false
  19588. */
  19589. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19590. /**
  19591. * Binds the world matrix to the material
  19592. * @param world defines the world transformation matrix
  19593. */
  19594. bindOnlyWorldMatrix(world: Matrix): void;
  19595. /**
  19596. * Binds the material to the mesh
  19597. * @param world defines the world transformation matrix
  19598. * @param mesh defines the mesh to bind the material to
  19599. */
  19600. bind(world: Matrix, mesh?: Mesh): void;
  19601. /**
  19602. * Gets the active textures from the material
  19603. * @returns an array of textures
  19604. */
  19605. getActiveTextures(): BaseTexture[];
  19606. /**
  19607. * Specifies if the material uses a texture
  19608. * @param texture defines the texture to check against the material
  19609. * @returns a boolean specifying if the material uses the texture
  19610. */
  19611. hasTexture(texture: BaseTexture): boolean;
  19612. /**
  19613. * Makes a duplicate of the material, and gives it a new name
  19614. * @param name defines the new name for the duplicated material
  19615. * @returns the cloned material
  19616. */
  19617. clone(name: string): ShaderMaterial;
  19618. /**
  19619. * Disposes the material
  19620. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19621. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19622. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19623. */
  19624. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19625. /**
  19626. * Serializes this material in a JSON representation
  19627. * @returns the serialized material object
  19628. */
  19629. serialize(): any;
  19630. /**
  19631. * Creates a shader material from parsed shader material data
  19632. * @param source defines the JSON represnetation of the material
  19633. * @param scene defines the hosting scene
  19634. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19635. * @returns a new material
  19636. */
  19637. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19638. }
  19639. }
  19640. declare module BABYLON {
  19641. /** @hidden */
  19642. export var colorPixelShader: {
  19643. name: string;
  19644. shader: string;
  19645. };
  19646. }
  19647. declare module BABYLON {
  19648. /** @hidden */
  19649. export var colorVertexShader: {
  19650. name: string;
  19651. shader: string;
  19652. };
  19653. }
  19654. declare module BABYLON {
  19655. /**
  19656. * Line mesh
  19657. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  19658. */
  19659. export class LinesMesh extends Mesh {
  19660. /**
  19661. * If vertex color should be applied to the mesh
  19662. */
  19663. readonly useVertexColor?: boolean | undefined;
  19664. /**
  19665. * If vertex alpha should be applied to the mesh
  19666. */
  19667. readonly useVertexAlpha?: boolean | undefined;
  19668. /**
  19669. * Color of the line (Default: White)
  19670. */
  19671. color: Color3;
  19672. /**
  19673. * Alpha of the line (Default: 1)
  19674. */
  19675. alpha: number;
  19676. /**
  19677. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19678. * This margin is expressed in world space coordinates, so its value may vary.
  19679. * Default value is 0.1
  19680. */
  19681. intersectionThreshold: number;
  19682. private _colorShader;
  19683. private color4;
  19684. /**
  19685. * Creates a new LinesMesh
  19686. * @param name defines the name
  19687. * @param scene defines the hosting scene
  19688. * @param parent defines the parent mesh if any
  19689. * @param source defines the optional source LinesMesh used to clone data from
  19690. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19691. * When false, achieved by calling a clone(), also passing False.
  19692. * This will make creation of children, recursive.
  19693. * @param useVertexColor defines if this LinesMesh supports vertex color
  19694. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  19695. */
  19696. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  19697. /**
  19698. * If vertex color should be applied to the mesh
  19699. */
  19700. useVertexColor?: boolean | undefined,
  19701. /**
  19702. * If vertex alpha should be applied to the mesh
  19703. */
  19704. useVertexAlpha?: boolean | undefined);
  19705. private _addClipPlaneDefine;
  19706. private _removeClipPlaneDefine;
  19707. isReady(): boolean;
  19708. /**
  19709. * Returns the string "LineMesh"
  19710. */
  19711. getClassName(): string;
  19712. /**
  19713. * @hidden
  19714. */
  19715. get material(): Material;
  19716. /**
  19717. * @hidden
  19718. */
  19719. set material(value: Material);
  19720. /**
  19721. * @hidden
  19722. */
  19723. get checkCollisions(): boolean;
  19724. /** @hidden */
  19725. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  19726. /** @hidden */
  19727. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  19728. /**
  19729. * Disposes of the line mesh
  19730. * @param doNotRecurse If children should be disposed
  19731. */
  19732. dispose(doNotRecurse?: boolean): void;
  19733. /**
  19734. * Returns a new LineMesh object cloned from the current one.
  19735. */
  19736. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19737. /**
  19738. * Creates a new InstancedLinesMesh object from the mesh model.
  19739. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19740. * @param name defines the name of the new instance
  19741. * @returns a new InstancedLinesMesh
  19742. */
  19743. createInstance(name: string): InstancedLinesMesh;
  19744. }
  19745. /**
  19746. * Creates an instance based on a source LinesMesh
  19747. */
  19748. export class InstancedLinesMesh extends InstancedMesh {
  19749. /**
  19750. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19751. * This margin is expressed in world space coordinates, so its value may vary.
  19752. * Initilized with the intersectionThreshold value of the source LinesMesh
  19753. */
  19754. intersectionThreshold: number;
  19755. constructor(name: string, source: LinesMesh);
  19756. /**
  19757. * Returns the string "InstancedLinesMesh".
  19758. */
  19759. getClassName(): string;
  19760. }
  19761. }
  19762. declare module BABYLON {
  19763. /** @hidden */
  19764. export var linePixelShader: {
  19765. name: string;
  19766. shader: string;
  19767. };
  19768. }
  19769. declare module BABYLON {
  19770. /** @hidden */
  19771. export var lineVertexShader: {
  19772. name: string;
  19773. shader: string;
  19774. };
  19775. }
  19776. declare module BABYLON {
  19777. interface AbstractMesh {
  19778. /**
  19779. * Gets the edgesRenderer associated with the mesh
  19780. */
  19781. edgesRenderer: Nullable<EdgesRenderer>;
  19782. }
  19783. interface LinesMesh {
  19784. /**
  19785. * Enables the edge rendering mode on the mesh.
  19786. * This mode makes the mesh edges visible
  19787. * @param epsilon defines the maximal distance between two angles to detect a face
  19788. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19789. * @returns the currentAbstractMesh
  19790. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19791. */
  19792. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  19793. }
  19794. interface InstancedLinesMesh {
  19795. /**
  19796. * Enables the edge rendering mode on the mesh.
  19797. * This mode makes the mesh edges visible
  19798. * @param epsilon defines the maximal distance between two angles to detect a face
  19799. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19800. * @returns the current InstancedLinesMesh
  19801. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19802. */
  19803. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  19804. }
  19805. /**
  19806. * Defines the minimum contract an Edges renderer should follow.
  19807. */
  19808. export interface IEdgesRenderer extends IDisposable {
  19809. /**
  19810. * Gets or sets a boolean indicating if the edgesRenderer is active
  19811. */
  19812. isEnabled: boolean;
  19813. /**
  19814. * Renders the edges of the attached mesh,
  19815. */
  19816. render(): void;
  19817. /**
  19818. * Checks wether or not the edges renderer is ready to render.
  19819. * @return true if ready, otherwise false.
  19820. */
  19821. isReady(): boolean;
  19822. }
  19823. /**
  19824. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  19825. */
  19826. export class EdgesRenderer implements IEdgesRenderer {
  19827. /**
  19828. * Define the size of the edges with an orthographic camera
  19829. */
  19830. edgesWidthScalerForOrthographic: number;
  19831. /**
  19832. * Define the size of the edges with a perspective camera
  19833. */
  19834. edgesWidthScalerForPerspective: number;
  19835. protected _source: AbstractMesh;
  19836. protected _linesPositions: number[];
  19837. protected _linesNormals: number[];
  19838. protected _linesIndices: number[];
  19839. protected _epsilon: number;
  19840. protected _indicesCount: number;
  19841. protected _lineShader: ShaderMaterial;
  19842. protected _ib: DataBuffer;
  19843. protected _buffers: {
  19844. [key: string]: Nullable<VertexBuffer>;
  19845. };
  19846. protected _checkVerticesInsteadOfIndices: boolean;
  19847. private _meshRebuildObserver;
  19848. private _meshDisposeObserver;
  19849. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  19850. isEnabled: boolean;
  19851. /**
  19852. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  19853. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  19854. * @param source Mesh used to create edges
  19855. * @param epsilon sum of angles in adjacency to check for edge
  19856. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  19857. * @param generateEdgesLines - should generate Lines or only prepare resources.
  19858. */
  19859. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  19860. protected _prepareRessources(): void;
  19861. /** @hidden */
  19862. _rebuild(): void;
  19863. /**
  19864. * Releases the required resources for the edges renderer
  19865. */
  19866. dispose(): void;
  19867. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  19868. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  19869. /**
  19870. * Checks if the pair of p0 and p1 is en edge
  19871. * @param faceIndex
  19872. * @param edge
  19873. * @param faceNormals
  19874. * @param p0
  19875. * @param p1
  19876. * @private
  19877. */
  19878. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  19879. /**
  19880. * push line into the position, normal and index buffer
  19881. * @protected
  19882. */
  19883. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  19884. /**
  19885. * Generates lines edges from adjacencjes
  19886. * @private
  19887. */
  19888. _generateEdgesLines(): void;
  19889. /**
  19890. * Checks wether or not the edges renderer is ready to render.
  19891. * @return true if ready, otherwise false.
  19892. */
  19893. isReady(): boolean;
  19894. /**
  19895. * Renders the edges of the attached mesh,
  19896. */
  19897. render(): void;
  19898. }
  19899. /**
  19900. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  19901. */
  19902. export class LineEdgesRenderer extends EdgesRenderer {
  19903. /**
  19904. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  19905. * @param source LineMesh used to generate edges
  19906. * @param epsilon not important (specified angle for edge detection)
  19907. * @param checkVerticesInsteadOfIndices not important for LineMesh
  19908. */
  19909. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  19910. /**
  19911. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  19912. */
  19913. _generateEdgesLines(): void;
  19914. }
  19915. }
  19916. declare module BABYLON {
  19917. /**
  19918. * This represents the object necessary to create a rendering group.
  19919. * This is exclusively used and created by the rendering manager.
  19920. * To modify the behavior, you use the available helpers in your scene or meshes.
  19921. * @hidden
  19922. */
  19923. export class RenderingGroup {
  19924. index: number;
  19925. private static _zeroVector;
  19926. private _scene;
  19927. private _opaqueSubMeshes;
  19928. private _transparentSubMeshes;
  19929. private _alphaTestSubMeshes;
  19930. private _depthOnlySubMeshes;
  19931. private _particleSystems;
  19932. private _spriteManagers;
  19933. private _opaqueSortCompareFn;
  19934. private _alphaTestSortCompareFn;
  19935. private _transparentSortCompareFn;
  19936. private _renderOpaque;
  19937. private _renderAlphaTest;
  19938. private _renderTransparent;
  19939. /** @hidden */
  19940. _edgesRenderers: SmartArray<IEdgesRenderer>;
  19941. onBeforeTransparentRendering: () => void;
  19942. /**
  19943. * Set the opaque sort comparison function.
  19944. * If null the sub meshes will be render in the order they were created
  19945. */
  19946. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  19947. /**
  19948. * Set the alpha test sort comparison function.
  19949. * If null the sub meshes will be render in the order they were created
  19950. */
  19951. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  19952. /**
  19953. * Set the transparent sort comparison function.
  19954. * If null the sub meshes will be render in the order they were created
  19955. */
  19956. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  19957. /**
  19958. * Creates a new rendering group.
  19959. * @param index The rendering group index
  19960. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  19961. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  19962. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  19963. */
  19964. 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>);
  19965. /**
  19966. * Render all the sub meshes contained in the group.
  19967. * @param customRenderFunction Used to override the default render behaviour of the group.
  19968. * @returns true if rendered some submeshes.
  19969. */
  19970. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  19971. /**
  19972. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  19973. * @param subMeshes The submeshes to render
  19974. */
  19975. private renderOpaqueSorted;
  19976. /**
  19977. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  19978. * @param subMeshes The submeshes to render
  19979. */
  19980. private renderAlphaTestSorted;
  19981. /**
  19982. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  19983. * @param subMeshes The submeshes to render
  19984. */
  19985. private renderTransparentSorted;
  19986. /**
  19987. * Renders the submeshes in a specified order.
  19988. * @param subMeshes The submeshes to sort before render
  19989. * @param sortCompareFn The comparison function use to sort
  19990. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  19991. * @param transparent Specifies to activate blending if true
  19992. */
  19993. private static renderSorted;
  19994. /**
  19995. * Renders the submeshes in the order they were dispatched (no sort applied).
  19996. * @param subMeshes The submeshes to render
  19997. */
  19998. private static renderUnsorted;
  19999. /**
  20000. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20001. * are rendered back to front if in the same alpha index.
  20002. *
  20003. * @param a The first submesh
  20004. * @param b The second submesh
  20005. * @returns The result of the comparison
  20006. */
  20007. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  20008. /**
  20009. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20010. * are rendered back to front.
  20011. *
  20012. * @param a The first submesh
  20013. * @param b The second submesh
  20014. * @returns The result of the comparison
  20015. */
  20016. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  20017. /**
  20018. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20019. * are rendered front to back (prevent overdraw).
  20020. *
  20021. * @param a The first submesh
  20022. * @param b The second submesh
  20023. * @returns The result of the comparison
  20024. */
  20025. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  20026. /**
  20027. * Resets the different lists of submeshes to prepare a new frame.
  20028. */
  20029. prepare(): void;
  20030. dispose(): void;
  20031. /**
  20032. * Inserts the submesh in its correct queue depending on its material.
  20033. * @param subMesh The submesh to dispatch
  20034. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20035. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20036. */
  20037. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20038. dispatchSprites(spriteManager: ISpriteManager): void;
  20039. dispatchParticles(particleSystem: IParticleSystem): void;
  20040. private _renderParticles;
  20041. private _renderSprites;
  20042. }
  20043. }
  20044. declare module BABYLON {
  20045. /**
  20046. * Interface describing the different options available in the rendering manager
  20047. * regarding Auto Clear between groups.
  20048. */
  20049. export interface IRenderingManagerAutoClearSetup {
  20050. /**
  20051. * Defines whether or not autoclear is enable.
  20052. */
  20053. autoClear: boolean;
  20054. /**
  20055. * Defines whether or not to autoclear the depth buffer.
  20056. */
  20057. depth: boolean;
  20058. /**
  20059. * Defines whether or not to autoclear the stencil buffer.
  20060. */
  20061. stencil: boolean;
  20062. }
  20063. /**
  20064. * This class is used by the onRenderingGroupObservable
  20065. */
  20066. export class RenderingGroupInfo {
  20067. /**
  20068. * The Scene that being rendered
  20069. */
  20070. scene: Scene;
  20071. /**
  20072. * The camera currently used for the rendering pass
  20073. */
  20074. camera: Nullable<Camera>;
  20075. /**
  20076. * The ID of the renderingGroup being processed
  20077. */
  20078. renderingGroupId: number;
  20079. }
  20080. /**
  20081. * This is the manager responsible of all the rendering for meshes sprites and particles.
  20082. * It is enable to manage the different groups as well as the different necessary sort functions.
  20083. * This should not be used directly aside of the few static configurations
  20084. */
  20085. export class RenderingManager {
  20086. /**
  20087. * The max id used for rendering groups (not included)
  20088. */
  20089. static MAX_RENDERINGGROUPS: number;
  20090. /**
  20091. * The min id used for rendering groups (included)
  20092. */
  20093. static MIN_RENDERINGGROUPS: number;
  20094. /**
  20095. * Used to globally prevent autoclearing scenes.
  20096. */
  20097. static AUTOCLEAR: boolean;
  20098. /**
  20099. * @hidden
  20100. */
  20101. _useSceneAutoClearSetup: boolean;
  20102. private _scene;
  20103. private _renderingGroups;
  20104. private _depthStencilBufferAlreadyCleaned;
  20105. private _autoClearDepthStencil;
  20106. private _customOpaqueSortCompareFn;
  20107. private _customAlphaTestSortCompareFn;
  20108. private _customTransparentSortCompareFn;
  20109. private _renderingGroupInfo;
  20110. /**
  20111. * Instantiates a new rendering group for a particular scene
  20112. * @param scene Defines the scene the groups belongs to
  20113. */
  20114. constructor(scene: Scene);
  20115. private _clearDepthStencilBuffer;
  20116. /**
  20117. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  20118. * @hidden
  20119. */
  20120. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  20121. /**
  20122. * Resets the different information of the group to prepare a new frame
  20123. * @hidden
  20124. */
  20125. reset(): void;
  20126. /**
  20127. * Dispose and release the group and its associated resources.
  20128. * @hidden
  20129. */
  20130. dispose(): void;
  20131. /**
  20132. * Clear the info related to rendering groups preventing retention points during dispose.
  20133. */
  20134. freeRenderingGroups(): void;
  20135. private _prepareRenderingGroup;
  20136. /**
  20137. * Add a sprite manager to the rendering manager in order to render it this frame.
  20138. * @param spriteManager Define the sprite manager to render
  20139. */
  20140. dispatchSprites(spriteManager: ISpriteManager): void;
  20141. /**
  20142. * Add a particle system to the rendering manager in order to render it this frame.
  20143. * @param particleSystem Define the particle system to render
  20144. */
  20145. dispatchParticles(particleSystem: IParticleSystem): void;
  20146. /**
  20147. * Add a submesh to the manager in order to render it this frame
  20148. * @param subMesh The submesh to dispatch
  20149. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20150. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20151. */
  20152. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20153. /**
  20154. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20155. * This allowed control for front to back rendering or reversly depending of the special needs.
  20156. *
  20157. * @param renderingGroupId The rendering group id corresponding to its index
  20158. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20159. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20160. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20161. */
  20162. 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;
  20163. /**
  20164. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20165. *
  20166. * @param renderingGroupId The rendering group id corresponding to its index
  20167. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20168. * @param depth Automatically clears depth between groups if true and autoClear is true.
  20169. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  20170. */
  20171. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  20172. /**
  20173. * Gets the current auto clear configuration for one rendering group of the rendering
  20174. * manager.
  20175. * @param index the rendering group index to get the information for
  20176. * @returns The auto clear setup for the requested rendering group
  20177. */
  20178. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  20179. }
  20180. }
  20181. declare module BABYLON {
  20182. /**
  20183. * This Helps creating a texture that will be created from a camera in your scene.
  20184. * It is basically a dynamic texture that could be used to create special effects for instance.
  20185. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20186. */
  20187. export class RenderTargetTexture extends Texture {
  20188. isCube: boolean;
  20189. /**
  20190. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20191. */
  20192. static readonly REFRESHRATE_RENDER_ONCE: number;
  20193. /**
  20194. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20195. */
  20196. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20197. /**
  20198. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20199. * the central point of your effect and can save a lot of performances.
  20200. */
  20201. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20202. /**
  20203. * Use this predicate to dynamically define the list of mesh you want to render.
  20204. * If set, the renderList property will be overwritten.
  20205. */
  20206. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20207. private _renderList;
  20208. /**
  20209. * Use this list to define the list of mesh you want to render.
  20210. */
  20211. get renderList(): Nullable<Array<AbstractMesh>>;
  20212. set renderList(value: Nullable<Array<AbstractMesh>>);
  20213. private _hookArray;
  20214. /**
  20215. * Define if particles should be rendered in your texture.
  20216. */
  20217. renderParticles: boolean;
  20218. /**
  20219. * Define if sprites should be rendered in your texture.
  20220. */
  20221. renderSprites: boolean;
  20222. /**
  20223. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20224. */
  20225. coordinatesMode: number;
  20226. /**
  20227. * Define the camera used to render the texture.
  20228. */
  20229. activeCamera: Nullable<Camera>;
  20230. /**
  20231. * Override the render function of the texture with your own one.
  20232. */
  20233. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20234. /**
  20235. * Define if camera post processes should be use while rendering the texture.
  20236. */
  20237. useCameraPostProcesses: boolean;
  20238. /**
  20239. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20240. */
  20241. ignoreCameraViewport: boolean;
  20242. private _postProcessManager;
  20243. private _postProcesses;
  20244. private _resizeObserver;
  20245. /**
  20246. * An event triggered when the texture is unbind.
  20247. */
  20248. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20249. /**
  20250. * An event triggered when the texture is unbind.
  20251. */
  20252. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20253. private _onAfterUnbindObserver;
  20254. /**
  20255. * Set a after unbind callback in the texture.
  20256. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20257. */
  20258. set onAfterUnbind(callback: () => void);
  20259. /**
  20260. * An event triggered before rendering the texture
  20261. */
  20262. onBeforeRenderObservable: Observable<number>;
  20263. private _onBeforeRenderObserver;
  20264. /**
  20265. * Set a before render callback in the texture.
  20266. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20267. */
  20268. set onBeforeRender(callback: (faceIndex: number) => void);
  20269. /**
  20270. * An event triggered after rendering the texture
  20271. */
  20272. onAfterRenderObservable: Observable<number>;
  20273. private _onAfterRenderObserver;
  20274. /**
  20275. * Set a after render callback in the texture.
  20276. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20277. */
  20278. set onAfterRender(callback: (faceIndex: number) => void);
  20279. /**
  20280. * An event triggered after the texture clear
  20281. */
  20282. onClearObservable: Observable<Engine>;
  20283. private _onClearObserver;
  20284. /**
  20285. * Set a clear callback in the texture.
  20286. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20287. */
  20288. set onClear(callback: (Engine: Engine) => void);
  20289. /**
  20290. * An event triggered when the texture is resized.
  20291. */
  20292. onResizeObservable: Observable<RenderTargetTexture>;
  20293. /**
  20294. * Define the clear color of the Render Target if it should be different from the scene.
  20295. */
  20296. clearColor: Color4;
  20297. protected _size: number | {
  20298. width: number;
  20299. height: number;
  20300. };
  20301. protected _initialSizeParameter: number | {
  20302. width: number;
  20303. height: number;
  20304. } | {
  20305. ratio: number;
  20306. };
  20307. protected _sizeRatio: Nullable<number>;
  20308. /** @hidden */
  20309. _generateMipMaps: boolean;
  20310. protected _renderingManager: RenderingManager;
  20311. /** @hidden */
  20312. _waitingRenderList: string[];
  20313. protected _doNotChangeAspectRatio: boolean;
  20314. protected _currentRefreshId: number;
  20315. protected _refreshRate: number;
  20316. protected _textureMatrix: Matrix;
  20317. protected _samples: number;
  20318. protected _renderTargetOptions: RenderTargetCreationOptions;
  20319. /**
  20320. * Gets render target creation options that were used.
  20321. */
  20322. get renderTargetOptions(): RenderTargetCreationOptions;
  20323. protected _engine: Engine;
  20324. protected _onRatioRescale(): void;
  20325. /**
  20326. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20327. * It must define where the camera used to render the texture is set
  20328. */
  20329. boundingBoxPosition: Vector3;
  20330. private _boundingBoxSize;
  20331. /**
  20332. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20333. * When defined, the cubemap will switch to local mode
  20334. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20335. * @example https://www.babylonjs-playground.com/#RNASML
  20336. */
  20337. set boundingBoxSize(value: Vector3);
  20338. get boundingBoxSize(): Vector3;
  20339. /**
  20340. * In case the RTT has been created with a depth texture, get the associated
  20341. * depth texture.
  20342. * Otherwise, return null.
  20343. */
  20344. depthStencilTexture: Nullable<InternalTexture>;
  20345. /**
  20346. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20347. * or used a shadow, depth texture...
  20348. * @param name The friendly name of the texture
  20349. * @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)
  20350. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20351. * @param generateMipMaps True if mip maps need to be generated after render.
  20352. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20353. * @param type The type of the buffer in the RTT (int, half float, float...)
  20354. * @param isCube True if a cube texture needs to be created
  20355. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20356. * @param generateDepthBuffer True to generate a depth buffer
  20357. * @param generateStencilBuffer True to generate a stencil buffer
  20358. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20359. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20360. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20361. */
  20362. constructor(name: string, size: number | {
  20363. width: number;
  20364. height: number;
  20365. } | {
  20366. ratio: number;
  20367. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20368. /**
  20369. * Creates a depth stencil texture.
  20370. * This is only available in WebGL 2 or with the depth texture extension available.
  20371. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20372. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20373. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20374. */
  20375. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20376. private _processSizeParameter;
  20377. /**
  20378. * Define the number of samples to use in case of MSAA.
  20379. * It defaults to one meaning no MSAA has been enabled.
  20380. */
  20381. get samples(): number;
  20382. set samples(value: number);
  20383. /**
  20384. * Resets the refresh counter of the texture and start bak from scratch.
  20385. * Could be useful to regenerate the texture if it is setup to render only once.
  20386. */
  20387. resetRefreshCounter(): void;
  20388. /**
  20389. * Define the refresh rate of the texture or the rendering frequency.
  20390. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20391. */
  20392. get refreshRate(): number;
  20393. set refreshRate(value: number);
  20394. /**
  20395. * Adds a post process to the render target rendering passes.
  20396. * @param postProcess define the post process to add
  20397. */
  20398. addPostProcess(postProcess: PostProcess): void;
  20399. /**
  20400. * Clear all the post processes attached to the render target
  20401. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20402. */
  20403. clearPostProcesses(dispose?: boolean): void;
  20404. /**
  20405. * Remove one of the post process from the list of attached post processes to the texture
  20406. * @param postProcess define the post process to remove from the list
  20407. */
  20408. removePostProcess(postProcess: PostProcess): void;
  20409. /** @hidden */
  20410. _shouldRender(): boolean;
  20411. /**
  20412. * Gets the actual render size of the texture.
  20413. * @returns the width of the render size
  20414. */
  20415. getRenderSize(): number;
  20416. /**
  20417. * Gets the actual render width of the texture.
  20418. * @returns the width of the render size
  20419. */
  20420. getRenderWidth(): number;
  20421. /**
  20422. * Gets the actual render height of the texture.
  20423. * @returns the height of the render size
  20424. */
  20425. getRenderHeight(): number;
  20426. /**
  20427. * Get if the texture can be rescaled or not.
  20428. */
  20429. get canRescale(): boolean;
  20430. /**
  20431. * Resize the texture using a ratio.
  20432. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20433. */
  20434. scale(ratio: number): void;
  20435. /**
  20436. * Get the texture reflection matrix used to rotate/transform the reflection.
  20437. * @returns the reflection matrix
  20438. */
  20439. getReflectionTextureMatrix(): Matrix;
  20440. /**
  20441. * Resize the texture to a new desired size.
  20442. * Be carrefull as it will recreate all the data in the new texture.
  20443. * @param size Define the new size. It can be:
  20444. * - a number for squared texture,
  20445. * - an object containing { width: number, height: number }
  20446. * - or an object containing a ratio { ratio: number }
  20447. */
  20448. resize(size: number | {
  20449. width: number;
  20450. height: number;
  20451. } | {
  20452. ratio: number;
  20453. }): void;
  20454. /**
  20455. * Renders all the objects from the render list into the texture.
  20456. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20457. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20458. */
  20459. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20460. private _bestReflectionRenderTargetDimension;
  20461. /**
  20462. * @hidden
  20463. * @param faceIndex face index to bind to if this is a cubetexture
  20464. */
  20465. _bindFrameBuffer(faceIndex?: number): void;
  20466. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20467. private renderToTarget;
  20468. /**
  20469. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20470. * This allowed control for front to back rendering or reversly depending of the special needs.
  20471. *
  20472. * @param renderingGroupId The rendering group id corresponding to its index
  20473. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20474. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20475. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20476. */
  20477. 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;
  20478. /**
  20479. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20480. *
  20481. * @param renderingGroupId The rendering group id corresponding to its index
  20482. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20483. */
  20484. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20485. /**
  20486. * Clones the texture.
  20487. * @returns the cloned texture
  20488. */
  20489. clone(): RenderTargetTexture;
  20490. /**
  20491. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20492. * @returns The JSON representation of the texture
  20493. */
  20494. serialize(): any;
  20495. /**
  20496. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20497. */
  20498. disposeFramebufferObjects(): void;
  20499. /**
  20500. * Dispose the texture and release its associated resources.
  20501. */
  20502. dispose(): void;
  20503. /** @hidden */
  20504. _rebuild(): void;
  20505. /**
  20506. * Clear the info related to rendering groups preventing retention point in material dispose.
  20507. */
  20508. freeRenderingGroups(): void;
  20509. /**
  20510. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20511. * @returns the view count
  20512. */
  20513. getViewCount(): number;
  20514. }
  20515. }
  20516. declare module BABYLON {
  20517. /**
  20518. * Options for compiling materials.
  20519. */
  20520. export interface IMaterialCompilationOptions {
  20521. /**
  20522. * Defines whether clip planes are enabled.
  20523. */
  20524. clipPlane: boolean;
  20525. /**
  20526. * Defines whether instances are enabled.
  20527. */
  20528. useInstances: boolean;
  20529. }
  20530. /**
  20531. * Base class for the main features of a material in Babylon.js
  20532. */
  20533. export class Material implements IAnimatable {
  20534. /**
  20535. * Returns the triangle fill mode
  20536. */
  20537. static readonly TriangleFillMode: number;
  20538. /**
  20539. * Returns the wireframe mode
  20540. */
  20541. static readonly WireFrameFillMode: number;
  20542. /**
  20543. * Returns the point fill mode
  20544. */
  20545. static readonly PointFillMode: number;
  20546. /**
  20547. * Returns the point list draw mode
  20548. */
  20549. static readonly PointListDrawMode: number;
  20550. /**
  20551. * Returns the line list draw mode
  20552. */
  20553. static readonly LineListDrawMode: number;
  20554. /**
  20555. * Returns the line loop draw mode
  20556. */
  20557. static readonly LineLoopDrawMode: number;
  20558. /**
  20559. * Returns the line strip draw mode
  20560. */
  20561. static readonly LineStripDrawMode: number;
  20562. /**
  20563. * Returns the triangle strip draw mode
  20564. */
  20565. static readonly TriangleStripDrawMode: number;
  20566. /**
  20567. * Returns the triangle fan draw mode
  20568. */
  20569. static readonly TriangleFanDrawMode: number;
  20570. /**
  20571. * Stores the clock-wise side orientation
  20572. */
  20573. static readonly ClockWiseSideOrientation: number;
  20574. /**
  20575. * Stores the counter clock-wise side orientation
  20576. */
  20577. static readonly CounterClockWiseSideOrientation: number;
  20578. /**
  20579. * The dirty texture flag value
  20580. */
  20581. static readonly TextureDirtyFlag: number;
  20582. /**
  20583. * The dirty light flag value
  20584. */
  20585. static readonly LightDirtyFlag: number;
  20586. /**
  20587. * The dirty fresnel flag value
  20588. */
  20589. static readonly FresnelDirtyFlag: number;
  20590. /**
  20591. * The dirty attribute flag value
  20592. */
  20593. static readonly AttributesDirtyFlag: number;
  20594. /**
  20595. * The dirty misc flag value
  20596. */
  20597. static readonly MiscDirtyFlag: number;
  20598. /**
  20599. * The all dirty flag value
  20600. */
  20601. static readonly AllDirtyFlag: number;
  20602. /**
  20603. * The ID of the material
  20604. */
  20605. id: string;
  20606. /**
  20607. * Gets or sets the unique id of the material
  20608. */
  20609. uniqueId: number;
  20610. /**
  20611. * The name of the material
  20612. */
  20613. name: string;
  20614. /**
  20615. * Gets or sets user defined metadata
  20616. */
  20617. metadata: any;
  20618. /**
  20619. * For internal use only. Please do not use.
  20620. */
  20621. reservedDataStore: any;
  20622. /**
  20623. * Specifies if the ready state should be checked on each call
  20624. */
  20625. checkReadyOnEveryCall: boolean;
  20626. /**
  20627. * Specifies if the ready state should be checked once
  20628. */
  20629. checkReadyOnlyOnce: boolean;
  20630. /**
  20631. * The state of the material
  20632. */
  20633. state: string;
  20634. /**
  20635. * The alpha value of the material
  20636. */
  20637. protected _alpha: number;
  20638. /**
  20639. * List of inspectable custom properties (used by the Inspector)
  20640. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20641. */
  20642. inspectableCustomProperties: IInspectable[];
  20643. /**
  20644. * Sets the alpha value of the material
  20645. */
  20646. set alpha(value: number);
  20647. /**
  20648. * Gets the alpha value of the material
  20649. */
  20650. get alpha(): number;
  20651. /**
  20652. * Specifies if back face culling is enabled
  20653. */
  20654. protected _backFaceCulling: boolean;
  20655. /**
  20656. * Sets the back-face culling state
  20657. */
  20658. set backFaceCulling(value: boolean);
  20659. /**
  20660. * Gets the back-face culling state
  20661. */
  20662. get backFaceCulling(): boolean;
  20663. /**
  20664. * Stores the value for side orientation
  20665. */
  20666. sideOrientation: number;
  20667. /**
  20668. * Callback triggered when the material is compiled
  20669. */
  20670. onCompiled: Nullable<(effect: Effect) => void>;
  20671. /**
  20672. * Callback triggered when an error occurs
  20673. */
  20674. onError: Nullable<(effect: Effect, errors: string) => void>;
  20675. /**
  20676. * Callback triggered to get the render target textures
  20677. */
  20678. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20679. /**
  20680. * Gets a boolean indicating that current material needs to register RTT
  20681. */
  20682. get hasRenderTargetTextures(): boolean;
  20683. /**
  20684. * Specifies if the material should be serialized
  20685. */
  20686. doNotSerialize: boolean;
  20687. /**
  20688. * @hidden
  20689. */
  20690. _storeEffectOnSubMeshes: boolean;
  20691. /**
  20692. * Stores the animations for the material
  20693. */
  20694. animations: Nullable<Array<Animation>>;
  20695. /**
  20696. * An event triggered when the material is disposed
  20697. */
  20698. onDisposeObservable: Observable<Material>;
  20699. /**
  20700. * An observer which watches for dispose events
  20701. */
  20702. private _onDisposeObserver;
  20703. private _onUnBindObservable;
  20704. /**
  20705. * Called during a dispose event
  20706. */
  20707. set onDispose(callback: () => void);
  20708. private _onBindObservable;
  20709. /**
  20710. * An event triggered when the material is bound
  20711. */
  20712. get onBindObservable(): Observable<AbstractMesh>;
  20713. /**
  20714. * An observer which watches for bind events
  20715. */
  20716. private _onBindObserver;
  20717. /**
  20718. * Called during a bind event
  20719. */
  20720. set onBind(callback: (Mesh: AbstractMesh) => void);
  20721. /**
  20722. * An event triggered when the material is unbound
  20723. */
  20724. get onUnBindObservable(): Observable<Material>;
  20725. /**
  20726. * Stores the value of the alpha mode
  20727. */
  20728. private _alphaMode;
  20729. /**
  20730. * Sets the value of the alpha mode.
  20731. *
  20732. * | Value | Type | Description |
  20733. * | --- | --- | --- |
  20734. * | 0 | ALPHA_DISABLE | |
  20735. * | 1 | ALPHA_ADD | |
  20736. * | 2 | ALPHA_COMBINE | |
  20737. * | 3 | ALPHA_SUBTRACT | |
  20738. * | 4 | ALPHA_MULTIPLY | |
  20739. * | 5 | ALPHA_MAXIMIZED | |
  20740. * | 6 | ALPHA_ONEONE | |
  20741. * | 7 | ALPHA_PREMULTIPLIED | |
  20742. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20743. * | 9 | ALPHA_INTERPOLATE | |
  20744. * | 10 | ALPHA_SCREENMODE | |
  20745. *
  20746. */
  20747. set alphaMode(value: number);
  20748. /**
  20749. * Gets the value of the alpha mode
  20750. */
  20751. get alphaMode(): number;
  20752. /**
  20753. * Stores the state of the need depth pre-pass value
  20754. */
  20755. private _needDepthPrePass;
  20756. /**
  20757. * Sets the need depth pre-pass value
  20758. */
  20759. set needDepthPrePass(value: boolean);
  20760. /**
  20761. * Gets the depth pre-pass value
  20762. */
  20763. get needDepthPrePass(): boolean;
  20764. /**
  20765. * Specifies if depth writing should be disabled
  20766. */
  20767. disableDepthWrite: boolean;
  20768. /**
  20769. * Specifies if depth writing should be forced
  20770. */
  20771. forceDepthWrite: boolean;
  20772. /**
  20773. * Specifies the depth function that should be used. 0 means the default engine function
  20774. */
  20775. depthFunction: number;
  20776. /**
  20777. * Specifies if there should be a separate pass for culling
  20778. */
  20779. separateCullingPass: boolean;
  20780. /**
  20781. * Stores the state specifing if fog should be enabled
  20782. */
  20783. private _fogEnabled;
  20784. /**
  20785. * Sets the state for enabling fog
  20786. */
  20787. set fogEnabled(value: boolean);
  20788. /**
  20789. * Gets the value of the fog enabled state
  20790. */
  20791. get fogEnabled(): boolean;
  20792. /**
  20793. * Stores the size of points
  20794. */
  20795. pointSize: number;
  20796. /**
  20797. * Stores the z offset value
  20798. */
  20799. zOffset: number;
  20800. /**
  20801. * Gets a value specifying if wireframe mode is enabled
  20802. */
  20803. get wireframe(): boolean;
  20804. /**
  20805. * Sets the state of wireframe mode
  20806. */
  20807. set wireframe(value: boolean);
  20808. /**
  20809. * Gets the value specifying if point clouds are enabled
  20810. */
  20811. get pointsCloud(): boolean;
  20812. /**
  20813. * Sets the state of point cloud mode
  20814. */
  20815. set pointsCloud(value: boolean);
  20816. /**
  20817. * Gets the material fill mode
  20818. */
  20819. get fillMode(): number;
  20820. /**
  20821. * Sets the material fill mode
  20822. */
  20823. set fillMode(value: number);
  20824. /**
  20825. * @hidden
  20826. * Stores the effects for the material
  20827. */
  20828. _effect: Nullable<Effect>;
  20829. /**
  20830. * @hidden
  20831. * Specifies if the material was previously ready
  20832. */
  20833. _wasPreviouslyReady: boolean;
  20834. /**
  20835. * Specifies if uniform buffers should be used
  20836. */
  20837. private _useUBO;
  20838. /**
  20839. * Stores a reference to the scene
  20840. */
  20841. private _scene;
  20842. /**
  20843. * Stores the fill mode state
  20844. */
  20845. private _fillMode;
  20846. /**
  20847. * Specifies if the depth write state should be cached
  20848. */
  20849. private _cachedDepthWriteState;
  20850. /**
  20851. * Specifies if the depth function state should be cached
  20852. */
  20853. private _cachedDepthFunctionState;
  20854. /**
  20855. * Stores the uniform buffer
  20856. */
  20857. protected _uniformBuffer: UniformBuffer;
  20858. /** @hidden */
  20859. _indexInSceneMaterialArray: number;
  20860. /** @hidden */
  20861. meshMap: Nullable<{
  20862. [id: string]: AbstractMesh | undefined;
  20863. }>;
  20864. /**
  20865. * Creates a material instance
  20866. * @param name defines the name of the material
  20867. * @param scene defines the scene to reference
  20868. * @param doNotAdd specifies if the material should be added to the scene
  20869. */
  20870. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  20871. /**
  20872. * Returns a string representation of the current material
  20873. * @param fullDetails defines a boolean indicating which levels of logging is desired
  20874. * @returns a string with material information
  20875. */
  20876. toString(fullDetails?: boolean): string;
  20877. /**
  20878. * Gets the class name of the material
  20879. * @returns a string with the class name of the material
  20880. */
  20881. getClassName(): string;
  20882. /**
  20883. * Specifies if updates for the material been locked
  20884. */
  20885. get isFrozen(): boolean;
  20886. /**
  20887. * Locks updates for the material
  20888. */
  20889. freeze(): void;
  20890. /**
  20891. * Unlocks updates for the material
  20892. */
  20893. unfreeze(): void;
  20894. /**
  20895. * Specifies if the material is ready to be used
  20896. * @param mesh defines the mesh to check
  20897. * @param useInstances specifies if instances should be used
  20898. * @returns a boolean indicating if the material is ready to be used
  20899. */
  20900. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  20901. /**
  20902. * Specifies that the submesh is ready to be used
  20903. * @param mesh defines the mesh to check
  20904. * @param subMesh defines which submesh to check
  20905. * @param useInstances specifies that instances should be used
  20906. * @returns a boolean indicating that the submesh is ready or not
  20907. */
  20908. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20909. /**
  20910. * Returns the material effect
  20911. * @returns the effect associated with the material
  20912. */
  20913. getEffect(): Nullable<Effect>;
  20914. /**
  20915. * Returns the current scene
  20916. * @returns a Scene
  20917. */
  20918. getScene(): Scene;
  20919. /**
  20920. * Specifies if the material will require alpha blending
  20921. * @returns a boolean specifying if alpha blending is needed
  20922. */
  20923. needAlphaBlending(): boolean;
  20924. /**
  20925. * Specifies if the mesh will require alpha blending
  20926. * @param mesh defines the mesh to check
  20927. * @returns a boolean specifying if alpha blending is needed for the mesh
  20928. */
  20929. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  20930. /**
  20931. * Specifies if this material should be rendered in alpha test mode
  20932. * @returns a boolean specifying if an alpha test is needed.
  20933. */
  20934. needAlphaTesting(): boolean;
  20935. /**
  20936. * Gets the texture used for the alpha test
  20937. * @returns the texture to use for alpha testing
  20938. */
  20939. getAlphaTestTexture(): Nullable<BaseTexture>;
  20940. /**
  20941. * Marks the material to indicate that it needs to be re-calculated
  20942. */
  20943. markDirty(): void;
  20944. /** @hidden */
  20945. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  20946. /**
  20947. * Binds the material to the mesh
  20948. * @param world defines the world transformation matrix
  20949. * @param mesh defines the mesh to bind the material to
  20950. */
  20951. bind(world: Matrix, mesh?: Mesh): void;
  20952. /**
  20953. * Binds the submesh to the material
  20954. * @param world defines the world transformation matrix
  20955. * @param mesh defines the mesh containing the submesh
  20956. * @param subMesh defines the submesh to bind the material to
  20957. */
  20958. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  20959. /**
  20960. * Binds the world matrix to the material
  20961. * @param world defines the world transformation matrix
  20962. */
  20963. bindOnlyWorldMatrix(world: Matrix): void;
  20964. /**
  20965. * Binds the scene's uniform buffer to the effect.
  20966. * @param effect defines the effect to bind to the scene uniform buffer
  20967. * @param sceneUbo defines the uniform buffer storing scene data
  20968. */
  20969. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  20970. /**
  20971. * Binds the view matrix to the effect
  20972. * @param effect defines the effect to bind the view matrix to
  20973. */
  20974. bindView(effect: Effect): void;
  20975. /**
  20976. * Binds the view projection matrix to the effect
  20977. * @param effect defines the effect to bind the view projection matrix to
  20978. */
  20979. bindViewProjection(effect: Effect): void;
  20980. /**
  20981. * Specifies if material alpha testing should be turned on for the mesh
  20982. * @param mesh defines the mesh to check
  20983. */
  20984. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  20985. /**
  20986. * Processes to execute after binding the material to a mesh
  20987. * @param mesh defines the rendered mesh
  20988. */
  20989. protected _afterBind(mesh?: Mesh): void;
  20990. /**
  20991. * Unbinds the material from the mesh
  20992. */
  20993. unbind(): void;
  20994. /**
  20995. * Gets the active textures from the material
  20996. * @returns an array of textures
  20997. */
  20998. getActiveTextures(): BaseTexture[];
  20999. /**
  21000. * Specifies if the material uses a texture
  21001. * @param texture defines the texture to check against the material
  21002. * @returns a boolean specifying if the material uses the texture
  21003. */
  21004. hasTexture(texture: BaseTexture): boolean;
  21005. /**
  21006. * Makes a duplicate of the material, and gives it a new name
  21007. * @param name defines the new name for the duplicated material
  21008. * @returns the cloned material
  21009. */
  21010. clone(name: string): Nullable<Material>;
  21011. /**
  21012. * Gets the meshes bound to the material
  21013. * @returns an array of meshes bound to the material
  21014. */
  21015. getBindedMeshes(): AbstractMesh[];
  21016. /**
  21017. * Force shader compilation
  21018. * @param mesh defines the mesh associated with this material
  21019. * @param onCompiled defines a function to execute once the material is compiled
  21020. * @param options defines the options to configure the compilation
  21021. * @param onError defines a function to execute if the material fails compiling
  21022. */
  21023. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  21024. /**
  21025. * Force shader compilation
  21026. * @param mesh defines the mesh that will use this material
  21027. * @param options defines additional options for compiling the shaders
  21028. * @returns a promise that resolves when the compilation completes
  21029. */
  21030. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  21031. private static readonly _AllDirtyCallBack;
  21032. private static readonly _ImageProcessingDirtyCallBack;
  21033. private static readonly _TextureDirtyCallBack;
  21034. private static readonly _FresnelDirtyCallBack;
  21035. private static readonly _MiscDirtyCallBack;
  21036. private static readonly _LightsDirtyCallBack;
  21037. private static readonly _AttributeDirtyCallBack;
  21038. private static _FresnelAndMiscDirtyCallBack;
  21039. private static _TextureAndMiscDirtyCallBack;
  21040. private static readonly _DirtyCallbackArray;
  21041. private static readonly _RunDirtyCallBacks;
  21042. /**
  21043. * Marks a define in the material to indicate that it needs to be re-computed
  21044. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21045. */
  21046. markAsDirty(flag: number): void;
  21047. /**
  21048. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21049. * @param func defines a function which checks material defines against the submeshes
  21050. */
  21051. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21052. /**
  21053. * Indicates that we need to re-calculated for all submeshes
  21054. */
  21055. protected _markAllSubMeshesAsAllDirty(): void;
  21056. /**
  21057. * Indicates that image processing needs to be re-calculated for all submeshes
  21058. */
  21059. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21060. /**
  21061. * Indicates that textures need to be re-calculated for all submeshes
  21062. */
  21063. protected _markAllSubMeshesAsTexturesDirty(): void;
  21064. /**
  21065. * Indicates that fresnel needs to be re-calculated for all submeshes
  21066. */
  21067. protected _markAllSubMeshesAsFresnelDirty(): void;
  21068. /**
  21069. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21070. */
  21071. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21072. /**
  21073. * Indicates that lights need to be re-calculated for all submeshes
  21074. */
  21075. protected _markAllSubMeshesAsLightsDirty(): void;
  21076. /**
  21077. * Indicates that attributes need to be re-calculated for all submeshes
  21078. */
  21079. protected _markAllSubMeshesAsAttributesDirty(): void;
  21080. /**
  21081. * Indicates that misc needs to be re-calculated for all submeshes
  21082. */
  21083. protected _markAllSubMeshesAsMiscDirty(): void;
  21084. /**
  21085. * Indicates that textures and misc need to be re-calculated for all submeshes
  21086. */
  21087. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21088. /**
  21089. * Disposes the material
  21090. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21091. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21092. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21093. */
  21094. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21095. /** @hidden */
  21096. private releaseVertexArrayObject;
  21097. /**
  21098. * Serializes this material
  21099. * @returns the serialized material object
  21100. */
  21101. serialize(): any;
  21102. /**
  21103. * Creates a material from parsed material data
  21104. * @param parsedMaterial defines parsed material data
  21105. * @param scene defines the hosting scene
  21106. * @param rootUrl defines the root URL to use to load textures
  21107. * @returns a new material
  21108. */
  21109. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21110. }
  21111. }
  21112. declare module BABYLON {
  21113. /**
  21114. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21115. * separate meshes. This can be use to improve performances.
  21116. * @see http://doc.babylonjs.com/how_to/multi_materials
  21117. */
  21118. export class MultiMaterial extends Material {
  21119. private _subMaterials;
  21120. /**
  21121. * Gets or Sets the list of Materials used within the multi material.
  21122. * They need to be ordered according to the submeshes order in the associated mesh
  21123. */
  21124. get subMaterials(): Nullable<Material>[];
  21125. set subMaterials(value: Nullable<Material>[]);
  21126. /**
  21127. * Function used to align with Node.getChildren()
  21128. * @returns the list of Materials used within the multi material
  21129. */
  21130. getChildren(): Nullable<Material>[];
  21131. /**
  21132. * Instantiates a new Multi Material
  21133. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21134. * separate meshes. This can be use to improve performances.
  21135. * @see http://doc.babylonjs.com/how_to/multi_materials
  21136. * @param name Define the name in the scene
  21137. * @param scene Define the scene the material belongs to
  21138. */
  21139. constructor(name: string, scene: Scene);
  21140. private _hookArray;
  21141. /**
  21142. * Get one of the submaterial by its index in the submaterials array
  21143. * @param index The index to look the sub material at
  21144. * @returns The Material if the index has been defined
  21145. */
  21146. getSubMaterial(index: number): Nullable<Material>;
  21147. /**
  21148. * Get the list of active textures for the whole sub materials list.
  21149. * @returns All the textures that will be used during the rendering
  21150. */
  21151. getActiveTextures(): BaseTexture[];
  21152. /**
  21153. * Gets the current class name of the material e.g. "MultiMaterial"
  21154. * Mainly use in serialization.
  21155. * @returns the class name
  21156. */
  21157. getClassName(): string;
  21158. /**
  21159. * Checks if the material is ready to render the requested sub mesh
  21160. * @param mesh Define the mesh the submesh belongs to
  21161. * @param subMesh Define the sub mesh to look readyness for
  21162. * @param useInstances Define whether or not the material is used with instances
  21163. * @returns true if ready, otherwise false
  21164. */
  21165. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21166. /**
  21167. * Clones the current material and its related sub materials
  21168. * @param name Define the name of the newly cloned material
  21169. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21170. * @returns the cloned material
  21171. */
  21172. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21173. /**
  21174. * Serializes the materials into a JSON representation.
  21175. * @returns the JSON representation
  21176. */
  21177. serialize(): any;
  21178. /**
  21179. * Dispose the material and release its associated resources
  21180. * @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)
  21181. * @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)
  21182. * @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)
  21183. */
  21184. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21185. /**
  21186. * Creates a MultiMaterial from parsed MultiMaterial data.
  21187. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21188. * @param scene defines the hosting scene
  21189. * @returns a new MultiMaterial
  21190. */
  21191. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21192. }
  21193. }
  21194. declare module BABYLON {
  21195. /**
  21196. * Base class for submeshes
  21197. */
  21198. export class BaseSubMesh {
  21199. /** @hidden */
  21200. _materialDefines: Nullable<MaterialDefines>;
  21201. /** @hidden */
  21202. _materialEffect: Nullable<Effect>;
  21203. /**
  21204. * Gets material defines used by the effect associated to the sub mesh
  21205. */
  21206. get materialDefines(): Nullable<MaterialDefines>;
  21207. /**
  21208. * Sets material defines used by the effect associated to the sub mesh
  21209. */
  21210. set materialDefines(defines: Nullable<MaterialDefines>);
  21211. /**
  21212. * Gets associated effect
  21213. */
  21214. get effect(): Nullable<Effect>;
  21215. /**
  21216. * Sets associated effect (effect used to render this submesh)
  21217. * @param effect defines the effect to associate with
  21218. * @param defines defines the set of defines used to compile this effect
  21219. */
  21220. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21221. }
  21222. /**
  21223. * Defines a subdivision inside a mesh
  21224. */
  21225. export class SubMesh extends BaseSubMesh implements ICullable {
  21226. /** the material index to use */
  21227. materialIndex: number;
  21228. /** vertex index start */
  21229. verticesStart: number;
  21230. /** vertices count */
  21231. verticesCount: number;
  21232. /** index start */
  21233. indexStart: number;
  21234. /** indices count */
  21235. indexCount: number;
  21236. /** @hidden */
  21237. _linesIndexCount: number;
  21238. private _mesh;
  21239. private _renderingMesh;
  21240. private _boundingInfo;
  21241. private _linesIndexBuffer;
  21242. /** @hidden */
  21243. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21244. /** @hidden */
  21245. _trianglePlanes: Plane[];
  21246. /** @hidden */
  21247. _lastColliderTransformMatrix: Nullable<Matrix>;
  21248. /** @hidden */
  21249. _renderId: number;
  21250. /** @hidden */
  21251. _alphaIndex: number;
  21252. /** @hidden */
  21253. _distanceToCamera: number;
  21254. /** @hidden */
  21255. _id: number;
  21256. private _currentMaterial;
  21257. /**
  21258. * Add a new submesh to a mesh
  21259. * @param materialIndex defines the material index to use
  21260. * @param verticesStart defines vertex index start
  21261. * @param verticesCount defines vertices count
  21262. * @param indexStart defines index start
  21263. * @param indexCount defines indices count
  21264. * @param mesh defines the parent mesh
  21265. * @param renderingMesh defines an optional rendering mesh
  21266. * @param createBoundingBox defines if bounding box should be created for this submesh
  21267. * @returns the new submesh
  21268. */
  21269. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21270. /**
  21271. * Creates a new submesh
  21272. * @param materialIndex defines the material index to use
  21273. * @param verticesStart defines vertex index start
  21274. * @param verticesCount defines vertices count
  21275. * @param indexStart defines index start
  21276. * @param indexCount defines indices count
  21277. * @param mesh defines the parent mesh
  21278. * @param renderingMesh defines an optional rendering mesh
  21279. * @param createBoundingBox defines if bounding box should be created for this submesh
  21280. */
  21281. constructor(
  21282. /** the material index to use */
  21283. materialIndex: number,
  21284. /** vertex index start */
  21285. verticesStart: number,
  21286. /** vertices count */
  21287. verticesCount: number,
  21288. /** index start */
  21289. indexStart: number,
  21290. /** indices count */
  21291. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21292. /**
  21293. * Returns true if this submesh covers the entire parent mesh
  21294. * @ignorenaming
  21295. */
  21296. get IsGlobal(): boolean;
  21297. /**
  21298. * Returns the submesh BoudingInfo object
  21299. * @returns current bounding info (or mesh's one if the submesh is global)
  21300. */
  21301. getBoundingInfo(): BoundingInfo;
  21302. /**
  21303. * Sets the submesh BoundingInfo
  21304. * @param boundingInfo defines the new bounding info to use
  21305. * @returns the SubMesh
  21306. */
  21307. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21308. /**
  21309. * Returns the mesh of the current submesh
  21310. * @return the parent mesh
  21311. */
  21312. getMesh(): AbstractMesh;
  21313. /**
  21314. * Returns the rendering mesh of the submesh
  21315. * @returns the rendering mesh (could be different from parent mesh)
  21316. */
  21317. getRenderingMesh(): Mesh;
  21318. /**
  21319. * Returns the submesh material
  21320. * @returns null or the current material
  21321. */
  21322. getMaterial(): Nullable<Material>;
  21323. /**
  21324. * Sets a new updated BoundingInfo object to the submesh
  21325. * @param data defines an optional position array to use to determine the bounding info
  21326. * @returns the SubMesh
  21327. */
  21328. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21329. /** @hidden */
  21330. _checkCollision(collider: Collider): boolean;
  21331. /**
  21332. * Updates the submesh BoundingInfo
  21333. * @param world defines the world matrix to use to update the bounding info
  21334. * @returns the submesh
  21335. */
  21336. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21337. /**
  21338. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21339. * @param frustumPlanes defines the frustum planes
  21340. * @returns true if the submesh is intersecting with the frustum
  21341. */
  21342. isInFrustum(frustumPlanes: Plane[]): boolean;
  21343. /**
  21344. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21345. * @param frustumPlanes defines the frustum planes
  21346. * @returns true if the submesh is inside the frustum
  21347. */
  21348. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21349. /**
  21350. * Renders the submesh
  21351. * @param enableAlphaMode defines if alpha needs to be used
  21352. * @returns the submesh
  21353. */
  21354. render(enableAlphaMode: boolean): SubMesh;
  21355. /**
  21356. * @hidden
  21357. */
  21358. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21359. /**
  21360. * Checks if the submesh intersects with a ray
  21361. * @param ray defines the ray to test
  21362. * @returns true is the passed ray intersects the submesh bounding box
  21363. */
  21364. canIntersects(ray: Ray): boolean;
  21365. /**
  21366. * Intersects current submesh with a ray
  21367. * @param ray defines the ray to test
  21368. * @param positions defines mesh's positions array
  21369. * @param indices defines mesh's indices array
  21370. * @param fastCheck defines if only bounding info should be used
  21371. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21372. * @returns intersection info or null if no intersection
  21373. */
  21374. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21375. /** @hidden */
  21376. private _intersectLines;
  21377. /** @hidden */
  21378. private _intersectUnIndexedLines;
  21379. /** @hidden */
  21380. private _intersectTriangles;
  21381. /** @hidden */
  21382. private _intersectUnIndexedTriangles;
  21383. /** @hidden */
  21384. _rebuild(): void;
  21385. /**
  21386. * Creates a new submesh from the passed mesh
  21387. * @param newMesh defines the new hosting mesh
  21388. * @param newRenderingMesh defines an optional rendering mesh
  21389. * @returns the new submesh
  21390. */
  21391. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21392. /**
  21393. * Release associated resources
  21394. */
  21395. dispose(): void;
  21396. /**
  21397. * Gets the class name
  21398. * @returns the string "SubMesh".
  21399. */
  21400. getClassName(): string;
  21401. /**
  21402. * Creates a new submesh from indices data
  21403. * @param materialIndex the index of the main mesh material
  21404. * @param startIndex the index where to start the copy in the mesh indices array
  21405. * @param indexCount the number of indices to copy then from the startIndex
  21406. * @param mesh the main mesh to create the submesh from
  21407. * @param renderingMesh the optional rendering mesh
  21408. * @returns a new submesh
  21409. */
  21410. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21411. }
  21412. }
  21413. declare module BABYLON {
  21414. /**
  21415. * Class used to represent data loading progression
  21416. */
  21417. export class SceneLoaderFlags {
  21418. private static _ForceFullSceneLoadingForIncremental;
  21419. private static _ShowLoadingScreen;
  21420. private static _CleanBoneMatrixWeights;
  21421. private static _loggingLevel;
  21422. /**
  21423. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21424. */
  21425. static get ForceFullSceneLoadingForIncremental(): boolean;
  21426. static set ForceFullSceneLoadingForIncremental(value: boolean);
  21427. /**
  21428. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21429. */
  21430. static get ShowLoadingScreen(): boolean;
  21431. static set ShowLoadingScreen(value: boolean);
  21432. /**
  21433. * Defines the current logging level (while loading the scene)
  21434. * @ignorenaming
  21435. */
  21436. static get loggingLevel(): number;
  21437. static set loggingLevel(value: number);
  21438. /**
  21439. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21440. */
  21441. static get CleanBoneMatrixWeights(): boolean;
  21442. static set CleanBoneMatrixWeights(value: boolean);
  21443. }
  21444. }
  21445. declare module BABYLON {
  21446. /**
  21447. * Class used to store geometry data (vertex buffers + index buffer)
  21448. */
  21449. export class Geometry implements IGetSetVerticesData {
  21450. /**
  21451. * Gets or sets the ID of the geometry
  21452. */
  21453. id: string;
  21454. /**
  21455. * Gets or sets the unique ID of the geometry
  21456. */
  21457. uniqueId: number;
  21458. /**
  21459. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21460. */
  21461. delayLoadState: number;
  21462. /**
  21463. * Gets the file containing the data to load when running in delay load state
  21464. */
  21465. delayLoadingFile: Nullable<string>;
  21466. /**
  21467. * Callback called when the geometry is updated
  21468. */
  21469. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21470. private _scene;
  21471. private _engine;
  21472. private _meshes;
  21473. private _totalVertices;
  21474. /** @hidden */
  21475. _indices: IndicesArray;
  21476. /** @hidden */
  21477. _vertexBuffers: {
  21478. [key: string]: VertexBuffer;
  21479. };
  21480. private _isDisposed;
  21481. private _extend;
  21482. private _boundingBias;
  21483. /** @hidden */
  21484. _delayInfo: Array<string>;
  21485. private _indexBuffer;
  21486. private _indexBufferIsUpdatable;
  21487. /** @hidden */
  21488. _boundingInfo: Nullable<BoundingInfo>;
  21489. /** @hidden */
  21490. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21491. /** @hidden */
  21492. _softwareSkinningFrameId: number;
  21493. private _vertexArrayObjects;
  21494. private _updatable;
  21495. /** @hidden */
  21496. _positions: Nullable<Vector3[]>;
  21497. /**
  21498. * 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
  21499. */
  21500. get boundingBias(): Vector2;
  21501. /**
  21502. * 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
  21503. */
  21504. set boundingBias(value: Vector2);
  21505. /**
  21506. * Static function used to attach a new empty geometry to a mesh
  21507. * @param mesh defines the mesh to attach the geometry to
  21508. * @returns the new Geometry
  21509. */
  21510. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21511. /**
  21512. * Creates a new geometry
  21513. * @param id defines the unique ID
  21514. * @param scene defines the hosting scene
  21515. * @param vertexData defines the VertexData used to get geometry data
  21516. * @param updatable defines if geometry must be updatable (false by default)
  21517. * @param mesh defines the mesh that will be associated with the geometry
  21518. */
  21519. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21520. /**
  21521. * Gets the current extend of the geometry
  21522. */
  21523. get extend(): {
  21524. minimum: Vector3;
  21525. maximum: Vector3;
  21526. };
  21527. /**
  21528. * Gets the hosting scene
  21529. * @returns the hosting Scene
  21530. */
  21531. getScene(): Scene;
  21532. /**
  21533. * Gets the hosting engine
  21534. * @returns the hosting Engine
  21535. */
  21536. getEngine(): Engine;
  21537. /**
  21538. * Defines if the geometry is ready to use
  21539. * @returns true if the geometry is ready to be used
  21540. */
  21541. isReady(): boolean;
  21542. /**
  21543. * Gets a value indicating that the geometry should not be serialized
  21544. */
  21545. get doNotSerialize(): boolean;
  21546. /** @hidden */
  21547. _rebuild(): void;
  21548. /**
  21549. * Affects all geometry data in one call
  21550. * @param vertexData defines the geometry data
  21551. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21552. */
  21553. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21554. /**
  21555. * Set specific vertex data
  21556. * @param kind defines the data kind (Position, normal, etc...)
  21557. * @param data defines the vertex data to use
  21558. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21559. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21560. */
  21561. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21562. /**
  21563. * Removes a specific vertex data
  21564. * @param kind defines the data kind (Position, normal, etc...)
  21565. */
  21566. removeVerticesData(kind: string): void;
  21567. /**
  21568. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21569. * @param buffer defines the vertex buffer to use
  21570. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21571. */
  21572. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21573. /**
  21574. * Update a specific vertex buffer
  21575. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  21576. * It will do nothing if the buffer is not updatable
  21577. * @param kind defines the data kind (Position, normal, etc...)
  21578. * @param data defines the data to use
  21579. * @param offset defines the offset in the target buffer where to store the data
  21580. * @param useBytes set to true if the offset is in bytes
  21581. */
  21582. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21583. /**
  21584. * Update a specific vertex buffer
  21585. * This function will create a new buffer if the current one is not updatable
  21586. * @param kind defines the data kind (Position, normal, etc...)
  21587. * @param data defines the data to use
  21588. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21589. */
  21590. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21591. private _updateBoundingInfo;
  21592. /** @hidden */
  21593. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  21594. /**
  21595. * Gets total number of vertices
  21596. * @returns the total number of vertices
  21597. */
  21598. getTotalVertices(): number;
  21599. /**
  21600. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21601. * @param kind defines the data kind (Position, normal, etc...)
  21602. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21603. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21604. * @returns a float array containing vertex data
  21605. */
  21606. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21607. /**
  21608. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21609. * @param kind defines the data kind (Position, normal, etc...)
  21610. * @returns true if the vertex buffer with the specified kind is updatable
  21611. */
  21612. isVertexBufferUpdatable(kind: string): boolean;
  21613. /**
  21614. * Gets a specific vertex buffer
  21615. * @param kind defines the data kind (Position, normal, etc...)
  21616. * @returns a VertexBuffer
  21617. */
  21618. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21619. /**
  21620. * Returns all vertex buffers
  21621. * @return an object holding all vertex buffers indexed by kind
  21622. */
  21623. getVertexBuffers(): Nullable<{
  21624. [key: string]: VertexBuffer;
  21625. }>;
  21626. /**
  21627. * Gets a boolean indicating if specific vertex buffer is present
  21628. * @param kind defines the data kind (Position, normal, etc...)
  21629. * @returns true if data is present
  21630. */
  21631. isVerticesDataPresent(kind: string): boolean;
  21632. /**
  21633. * Gets a list of all attached data kinds (Position, normal, etc...)
  21634. * @returns a list of string containing all kinds
  21635. */
  21636. getVerticesDataKinds(): string[];
  21637. /**
  21638. * Update index buffer
  21639. * @param indices defines the indices to store in the index buffer
  21640. * @param offset defines the offset in the target buffer where to store the data
  21641. * @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)
  21642. */
  21643. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  21644. /**
  21645. * Creates a new index buffer
  21646. * @param indices defines the indices to store in the index buffer
  21647. * @param totalVertices defines the total number of vertices (could be null)
  21648. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21649. */
  21650. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21651. /**
  21652. * Return the total number of indices
  21653. * @returns the total number of indices
  21654. */
  21655. getTotalIndices(): number;
  21656. /**
  21657. * Gets the index buffer array
  21658. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21659. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21660. * @returns the index buffer array
  21661. */
  21662. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21663. /**
  21664. * Gets the index buffer
  21665. * @return the index buffer
  21666. */
  21667. getIndexBuffer(): Nullable<DataBuffer>;
  21668. /** @hidden */
  21669. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21670. /**
  21671. * Release the associated resources for a specific mesh
  21672. * @param mesh defines the source mesh
  21673. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21674. */
  21675. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21676. /**
  21677. * Apply current geometry to a given mesh
  21678. * @param mesh defines the mesh to apply geometry to
  21679. */
  21680. applyToMesh(mesh: Mesh): void;
  21681. private _updateExtend;
  21682. private _applyToMesh;
  21683. private notifyUpdate;
  21684. /**
  21685. * Load the geometry if it was flagged as delay loaded
  21686. * @param scene defines the hosting scene
  21687. * @param onLoaded defines a callback called when the geometry is loaded
  21688. */
  21689. load(scene: Scene, onLoaded?: () => void): void;
  21690. private _queueLoad;
  21691. /**
  21692. * Invert the geometry to move from a right handed system to a left handed one.
  21693. */
  21694. toLeftHanded(): void;
  21695. /** @hidden */
  21696. _resetPointsArrayCache(): void;
  21697. /** @hidden */
  21698. _generatePointsArray(): boolean;
  21699. /**
  21700. * Gets a value indicating if the geometry is disposed
  21701. * @returns true if the geometry was disposed
  21702. */
  21703. isDisposed(): boolean;
  21704. private _disposeVertexArrayObjects;
  21705. /**
  21706. * Free all associated resources
  21707. */
  21708. dispose(): void;
  21709. /**
  21710. * Clone the current geometry into a new geometry
  21711. * @param id defines the unique ID of the new geometry
  21712. * @returns a new geometry object
  21713. */
  21714. copy(id: string): Geometry;
  21715. /**
  21716. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21717. * @return a JSON representation of the current geometry data (without the vertices data)
  21718. */
  21719. serialize(): any;
  21720. private toNumberArray;
  21721. /**
  21722. * Serialize all vertices data into a JSON oject
  21723. * @returns a JSON representation of the current geometry data
  21724. */
  21725. serializeVerticeData(): any;
  21726. /**
  21727. * Extracts a clone of a mesh geometry
  21728. * @param mesh defines the source mesh
  21729. * @param id defines the unique ID of the new geometry object
  21730. * @returns the new geometry object
  21731. */
  21732. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21733. /**
  21734. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21735. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21736. * Be aware Math.random() could cause collisions, but:
  21737. * "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"
  21738. * @returns a string containing a new GUID
  21739. */
  21740. static RandomId(): string;
  21741. /** @hidden */
  21742. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21743. private static _CleanMatricesWeights;
  21744. /**
  21745. * Create a new geometry from persisted data (Using .babylon file format)
  21746. * @param parsedVertexData defines the persisted data
  21747. * @param scene defines the hosting scene
  21748. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21749. * @returns the new geometry object
  21750. */
  21751. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21752. }
  21753. }
  21754. declare module BABYLON {
  21755. /**
  21756. * Define an interface for all classes that will get and set the data on vertices
  21757. */
  21758. export interface IGetSetVerticesData {
  21759. /**
  21760. * Gets a boolean indicating if specific vertex data is present
  21761. * @param kind defines the vertex data kind to use
  21762. * @returns true is data kind is present
  21763. */
  21764. isVerticesDataPresent(kind: string): boolean;
  21765. /**
  21766. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21767. * @param kind defines the data kind (Position, normal, etc...)
  21768. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21769. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21770. * @returns a float array containing vertex data
  21771. */
  21772. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21773. /**
  21774. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21775. * @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.
  21776. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21777. * @returns the indices array or an empty array if the mesh has no geometry
  21778. */
  21779. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21780. /**
  21781. * Set specific vertex data
  21782. * @param kind defines the data kind (Position, normal, etc...)
  21783. * @param data defines the vertex data to use
  21784. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21785. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21786. */
  21787. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21788. /**
  21789. * Update a specific associated vertex buffer
  21790. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21791. * - VertexBuffer.PositionKind
  21792. * - VertexBuffer.UVKind
  21793. * - VertexBuffer.UV2Kind
  21794. * - VertexBuffer.UV3Kind
  21795. * - VertexBuffer.UV4Kind
  21796. * - VertexBuffer.UV5Kind
  21797. * - VertexBuffer.UV6Kind
  21798. * - VertexBuffer.ColorKind
  21799. * - VertexBuffer.MatricesIndicesKind
  21800. * - VertexBuffer.MatricesIndicesExtraKind
  21801. * - VertexBuffer.MatricesWeightsKind
  21802. * - VertexBuffer.MatricesWeightsExtraKind
  21803. * @param data defines the data source
  21804. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21805. * @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)
  21806. */
  21807. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21808. /**
  21809. * Creates a new index buffer
  21810. * @param indices defines the indices to store in the index buffer
  21811. * @param totalVertices defines the total number of vertices (could be null)
  21812. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21813. */
  21814. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21815. }
  21816. /**
  21817. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21818. */
  21819. export class VertexData {
  21820. /**
  21821. * Mesh side orientation : usually the external or front surface
  21822. */
  21823. static readonly FRONTSIDE: number;
  21824. /**
  21825. * Mesh side orientation : usually the internal or back surface
  21826. */
  21827. static readonly BACKSIDE: number;
  21828. /**
  21829. * Mesh side orientation : both internal and external or front and back surfaces
  21830. */
  21831. static readonly DOUBLESIDE: number;
  21832. /**
  21833. * Mesh side orientation : by default, `FRONTSIDE`
  21834. */
  21835. static readonly DEFAULTSIDE: number;
  21836. /**
  21837. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  21838. */
  21839. positions: Nullable<FloatArray>;
  21840. /**
  21841. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  21842. */
  21843. normals: Nullable<FloatArray>;
  21844. /**
  21845. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  21846. */
  21847. tangents: Nullable<FloatArray>;
  21848. /**
  21849. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21850. */
  21851. uvs: Nullable<FloatArray>;
  21852. /**
  21853. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21854. */
  21855. uvs2: Nullable<FloatArray>;
  21856. /**
  21857. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21858. */
  21859. uvs3: Nullable<FloatArray>;
  21860. /**
  21861. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21862. */
  21863. uvs4: Nullable<FloatArray>;
  21864. /**
  21865. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21866. */
  21867. uvs5: Nullable<FloatArray>;
  21868. /**
  21869. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21870. */
  21871. uvs6: Nullable<FloatArray>;
  21872. /**
  21873. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  21874. */
  21875. colors: Nullable<FloatArray>;
  21876. /**
  21877. * 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).
  21878. */
  21879. matricesIndices: Nullable<FloatArray>;
  21880. /**
  21881. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  21882. */
  21883. matricesWeights: Nullable<FloatArray>;
  21884. /**
  21885. * An array extending the number of possible indices
  21886. */
  21887. matricesIndicesExtra: Nullable<FloatArray>;
  21888. /**
  21889. * An array extending the number of possible weights when the number of indices is extended
  21890. */
  21891. matricesWeightsExtra: Nullable<FloatArray>;
  21892. /**
  21893. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  21894. */
  21895. indices: Nullable<IndicesArray>;
  21896. /**
  21897. * Uses the passed data array to set the set the values for the specified kind of data
  21898. * @param data a linear array of floating numbers
  21899. * @param kind the type of data that is being set, eg positions, colors etc
  21900. */
  21901. set(data: FloatArray, kind: string): void;
  21902. /**
  21903. * Associates the vertexData to the passed Mesh.
  21904. * Sets it as updatable or not (default `false`)
  21905. * @param mesh the mesh the vertexData is applied to
  21906. * @param updatable when used and having the value true allows new data to update the vertexData
  21907. * @returns the VertexData
  21908. */
  21909. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  21910. /**
  21911. * Associates the vertexData to the passed Geometry.
  21912. * Sets it as updatable or not (default `false`)
  21913. * @param geometry the geometry the vertexData is applied to
  21914. * @param updatable when used and having the value true allows new data to update the vertexData
  21915. * @returns VertexData
  21916. */
  21917. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  21918. /**
  21919. * Updates the associated mesh
  21920. * @param mesh the mesh to be updated
  21921. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21922. * @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
  21923. * @returns VertexData
  21924. */
  21925. updateMesh(mesh: Mesh): VertexData;
  21926. /**
  21927. * Updates the associated geometry
  21928. * @param geometry the geometry to be updated
  21929. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21930. * @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
  21931. * @returns VertexData.
  21932. */
  21933. updateGeometry(geometry: Geometry): VertexData;
  21934. private _applyTo;
  21935. private _update;
  21936. /**
  21937. * Transforms each position and each normal of the vertexData according to the passed Matrix
  21938. * @param matrix the transforming matrix
  21939. * @returns the VertexData
  21940. */
  21941. transform(matrix: Matrix): VertexData;
  21942. /**
  21943. * Merges the passed VertexData into the current one
  21944. * @param other the VertexData to be merged into the current one
  21945. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  21946. * @returns the modified VertexData
  21947. */
  21948. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  21949. private _mergeElement;
  21950. private _validate;
  21951. /**
  21952. * Serializes the VertexData
  21953. * @returns a serialized object
  21954. */
  21955. serialize(): any;
  21956. /**
  21957. * Extracts the vertexData from a mesh
  21958. * @param mesh the mesh from which to extract the VertexData
  21959. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  21960. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21961. * @returns the object VertexData associated to the passed mesh
  21962. */
  21963. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21964. /**
  21965. * Extracts the vertexData from the geometry
  21966. * @param geometry the geometry from which to extract the VertexData
  21967. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  21968. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21969. * @returns the object VertexData associated to the passed mesh
  21970. */
  21971. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21972. private static _ExtractFrom;
  21973. /**
  21974. * Creates the VertexData for a Ribbon
  21975. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  21976. * * pathArray array of paths, each of which an array of successive Vector3
  21977. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  21978. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  21979. * * 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
  21980. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21981. * * 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)
  21982. * * 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)
  21983. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  21984. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  21985. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  21986. * @returns the VertexData of the ribbon
  21987. */
  21988. static CreateRibbon(options: {
  21989. pathArray: Vector3[][];
  21990. closeArray?: boolean;
  21991. closePath?: boolean;
  21992. offset?: number;
  21993. sideOrientation?: number;
  21994. frontUVs?: Vector4;
  21995. backUVs?: Vector4;
  21996. invertUV?: boolean;
  21997. uvs?: Vector2[];
  21998. colors?: Color4[];
  21999. }): VertexData;
  22000. /**
  22001. * Creates the VertexData for a box
  22002. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22003. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22004. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22005. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22006. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22007. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22008. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22009. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22010. * * 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)
  22011. * * 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)
  22012. * @returns the VertexData of the box
  22013. */
  22014. static CreateBox(options: {
  22015. size?: number;
  22016. width?: number;
  22017. height?: number;
  22018. depth?: number;
  22019. faceUV?: Vector4[];
  22020. faceColors?: Color4[];
  22021. sideOrientation?: number;
  22022. frontUVs?: Vector4;
  22023. backUVs?: Vector4;
  22024. }): VertexData;
  22025. /**
  22026. * Creates the VertexData for a tiled box
  22027. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22028. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22029. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22030. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22031. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22032. * @returns the VertexData of the box
  22033. */
  22034. static CreateTiledBox(options: {
  22035. pattern?: number;
  22036. width?: number;
  22037. height?: number;
  22038. depth?: number;
  22039. tileSize?: number;
  22040. tileWidth?: number;
  22041. tileHeight?: number;
  22042. alignHorizontal?: number;
  22043. alignVertical?: number;
  22044. faceUV?: Vector4[];
  22045. faceColors?: Color4[];
  22046. sideOrientation?: number;
  22047. }): VertexData;
  22048. /**
  22049. * Creates the VertexData for a tiled plane
  22050. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22051. * * pattern a limited pattern arrangement depending on the number
  22052. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22053. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22054. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22055. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22056. * * 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)
  22057. * * 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)
  22058. * @returns the VertexData of the tiled plane
  22059. */
  22060. static CreateTiledPlane(options: {
  22061. pattern?: number;
  22062. tileSize?: number;
  22063. tileWidth?: number;
  22064. tileHeight?: number;
  22065. size?: number;
  22066. width?: number;
  22067. height?: number;
  22068. alignHorizontal?: number;
  22069. alignVertical?: number;
  22070. sideOrientation?: number;
  22071. frontUVs?: Vector4;
  22072. backUVs?: Vector4;
  22073. }): VertexData;
  22074. /**
  22075. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22076. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22077. * * segments sets the number of horizontal strips optional, default 32
  22078. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22079. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22080. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22081. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22082. * * 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
  22083. * * 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
  22084. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22085. * * 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)
  22086. * * 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)
  22087. * @returns the VertexData of the ellipsoid
  22088. */
  22089. static CreateSphere(options: {
  22090. segments?: number;
  22091. diameter?: number;
  22092. diameterX?: number;
  22093. diameterY?: number;
  22094. diameterZ?: number;
  22095. arc?: number;
  22096. slice?: number;
  22097. sideOrientation?: number;
  22098. frontUVs?: Vector4;
  22099. backUVs?: Vector4;
  22100. }): VertexData;
  22101. /**
  22102. * Creates the VertexData for a cylinder, cone or prism
  22103. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22104. * * height sets the height (y direction) of the cylinder, optional, default 2
  22105. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22106. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22107. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22108. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22109. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22110. * * 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
  22111. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22112. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22113. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22114. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22115. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22116. * * 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)
  22117. * * 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)
  22118. * @returns the VertexData of the cylinder, cone or prism
  22119. */
  22120. static CreateCylinder(options: {
  22121. height?: number;
  22122. diameterTop?: number;
  22123. diameterBottom?: number;
  22124. diameter?: number;
  22125. tessellation?: number;
  22126. subdivisions?: number;
  22127. arc?: number;
  22128. faceColors?: Color4[];
  22129. faceUV?: Vector4[];
  22130. hasRings?: boolean;
  22131. enclose?: boolean;
  22132. sideOrientation?: number;
  22133. frontUVs?: Vector4;
  22134. backUVs?: Vector4;
  22135. }): VertexData;
  22136. /**
  22137. * Creates the VertexData for a torus
  22138. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22139. * * diameter the diameter of the torus, optional default 1
  22140. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22141. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22142. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22143. * * 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)
  22144. * * 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)
  22145. * @returns the VertexData of the torus
  22146. */
  22147. static CreateTorus(options: {
  22148. diameter?: number;
  22149. thickness?: number;
  22150. tessellation?: number;
  22151. sideOrientation?: number;
  22152. frontUVs?: Vector4;
  22153. backUVs?: Vector4;
  22154. }): VertexData;
  22155. /**
  22156. * Creates the VertexData of the LineSystem
  22157. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22158. * - lines an array of lines, each line being an array of successive Vector3
  22159. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22160. * @returns the VertexData of the LineSystem
  22161. */
  22162. static CreateLineSystem(options: {
  22163. lines: Vector3[][];
  22164. colors?: Nullable<Color4[][]>;
  22165. }): VertexData;
  22166. /**
  22167. * Create the VertexData for a DashedLines
  22168. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22169. * - points an array successive Vector3
  22170. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22171. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22172. * - dashNb the intended total number of dashes, optional, default 200
  22173. * @returns the VertexData for the DashedLines
  22174. */
  22175. static CreateDashedLines(options: {
  22176. points: Vector3[];
  22177. dashSize?: number;
  22178. gapSize?: number;
  22179. dashNb?: number;
  22180. }): VertexData;
  22181. /**
  22182. * Creates the VertexData for a Ground
  22183. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22184. * - width the width (x direction) of the ground, optional, default 1
  22185. * - height the height (z direction) of the ground, optional, default 1
  22186. * - subdivisions the number of subdivisions per side, optional, default 1
  22187. * @returns the VertexData of the Ground
  22188. */
  22189. static CreateGround(options: {
  22190. width?: number;
  22191. height?: number;
  22192. subdivisions?: number;
  22193. subdivisionsX?: number;
  22194. subdivisionsY?: number;
  22195. }): VertexData;
  22196. /**
  22197. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22198. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22199. * * xmin the ground minimum X coordinate, optional, default -1
  22200. * * zmin the ground minimum Z coordinate, optional, default -1
  22201. * * xmax the ground maximum X coordinate, optional, default 1
  22202. * * zmax the ground maximum Z coordinate, optional, default 1
  22203. * * 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}
  22204. * * 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}
  22205. * @returns the VertexData of the TiledGround
  22206. */
  22207. static CreateTiledGround(options: {
  22208. xmin: number;
  22209. zmin: number;
  22210. xmax: number;
  22211. zmax: number;
  22212. subdivisions?: {
  22213. w: number;
  22214. h: number;
  22215. };
  22216. precision?: {
  22217. w: number;
  22218. h: number;
  22219. };
  22220. }): VertexData;
  22221. /**
  22222. * Creates the VertexData of the Ground designed from a heightmap
  22223. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22224. * * width the width (x direction) of the ground
  22225. * * height the height (z direction) of the ground
  22226. * * subdivisions the number of subdivisions per side
  22227. * * minHeight the minimum altitude on the ground, optional, default 0
  22228. * * maxHeight the maximum altitude on the ground, optional default 1
  22229. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22230. * * buffer the array holding the image color data
  22231. * * bufferWidth the width of image
  22232. * * bufferHeight the height of image
  22233. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22234. * @returns the VertexData of the Ground designed from a heightmap
  22235. */
  22236. static CreateGroundFromHeightMap(options: {
  22237. width: number;
  22238. height: number;
  22239. subdivisions: number;
  22240. minHeight: number;
  22241. maxHeight: number;
  22242. colorFilter: Color3;
  22243. buffer: Uint8Array;
  22244. bufferWidth: number;
  22245. bufferHeight: number;
  22246. alphaFilter: number;
  22247. }): VertexData;
  22248. /**
  22249. * Creates the VertexData for a Plane
  22250. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22251. * * size sets the width and height of the plane to the value of size, optional default 1
  22252. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22253. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22254. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22255. * * 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)
  22256. * * 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)
  22257. * @returns the VertexData of the box
  22258. */
  22259. static CreatePlane(options: {
  22260. size?: number;
  22261. width?: number;
  22262. height?: number;
  22263. sideOrientation?: number;
  22264. frontUVs?: Vector4;
  22265. backUVs?: Vector4;
  22266. }): VertexData;
  22267. /**
  22268. * Creates the VertexData of the Disc or regular Polygon
  22269. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22270. * * radius the radius of the disc, optional default 0.5
  22271. * * tessellation the number of polygon sides, optional, default 64
  22272. * * 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
  22273. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22274. * * 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)
  22275. * * 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)
  22276. * @returns the VertexData of the box
  22277. */
  22278. static CreateDisc(options: {
  22279. radius?: number;
  22280. tessellation?: number;
  22281. arc?: number;
  22282. sideOrientation?: number;
  22283. frontUVs?: Vector4;
  22284. backUVs?: Vector4;
  22285. }): VertexData;
  22286. /**
  22287. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22288. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22289. * @param polygon a mesh built from polygonTriangulation.build()
  22290. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22291. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22292. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22293. * @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)
  22294. * @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)
  22295. * @returns the VertexData of the Polygon
  22296. */
  22297. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22298. /**
  22299. * Creates the VertexData of the IcoSphere
  22300. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22301. * * radius the radius of the IcoSphere, optional default 1
  22302. * * radiusX allows stretching in the x direction, optional, default radius
  22303. * * radiusY allows stretching in the y direction, optional, default radius
  22304. * * radiusZ allows stretching in the z direction, optional, default radius
  22305. * * flat when true creates a flat shaded mesh, optional, default true
  22306. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22307. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22308. * * 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)
  22309. * * 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)
  22310. * @returns the VertexData of the IcoSphere
  22311. */
  22312. static CreateIcoSphere(options: {
  22313. radius?: number;
  22314. radiusX?: number;
  22315. radiusY?: number;
  22316. radiusZ?: number;
  22317. flat?: boolean;
  22318. subdivisions?: number;
  22319. sideOrientation?: number;
  22320. frontUVs?: Vector4;
  22321. backUVs?: Vector4;
  22322. }): VertexData;
  22323. /**
  22324. * Creates the VertexData for a Polyhedron
  22325. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22326. * * type provided types are:
  22327. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22328. * * 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)
  22329. * * size the size of the IcoSphere, optional default 1
  22330. * * sizeX allows stretching in the x direction, optional, default size
  22331. * * sizeY allows stretching in the y direction, optional, default size
  22332. * * sizeZ allows stretching in the z direction, optional, default size
  22333. * * 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
  22334. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22335. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22336. * * flat when true creates a flat shaded mesh, optional, default true
  22337. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22338. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22339. * * 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)
  22340. * * 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)
  22341. * @returns the VertexData of the Polyhedron
  22342. */
  22343. static CreatePolyhedron(options: {
  22344. type?: number;
  22345. size?: number;
  22346. sizeX?: number;
  22347. sizeY?: number;
  22348. sizeZ?: number;
  22349. custom?: any;
  22350. faceUV?: Vector4[];
  22351. faceColors?: Color4[];
  22352. flat?: boolean;
  22353. sideOrientation?: number;
  22354. frontUVs?: Vector4;
  22355. backUVs?: Vector4;
  22356. }): VertexData;
  22357. /**
  22358. * Creates the VertexData for a TorusKnot
  22359. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22360. * * radius the radius of the torus knot, optional, default 2
  22361. * * tube the thickness of the tube, optional, default 0.5
  22362. * * radialSegments the number of sides on each tube segments, optional, default 32
  22363. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22364. * * p the number of windings around the z axis, optional, default 2
  22365. * * q the number of windings around the x axis, optional, default 3
  22366. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22367. * * 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)
  22368. * * 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)
  22369. * @returns the VertexData of the Torus Knot
  22370. */
  22371. static CreateTorusKnot(options: {
  22372. radius?: number;
  22373. tube?: number;
  22374. radialSegments?: number;
  22375. tubularSegments?: number;
  22376. p?: number;
  22377. q?: number;
  22378. sideOrientation?: number;
  22379. frontUVs?: Vector4;
  22380. backUVs?: Vector4;
  22381. }): VertexData;
  22382. /**
  22383. * Compute normals for given positions and indices
  22384. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22385. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22386. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22387. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22388. * * facetNormals : optional array of facet normals (vector3)
  22389. * * facetPositions : optional array of facet positions (vector3)
  22390. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22391. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22392. * * bInfo : optional bounding info, required for facetPartitioning computation
  22393. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22394. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22395. * * useRightHandedSystem: optional boolean to for right handed system computation
  22396. * * depthSort : optional boolean to enable the facet depth sort computation
  22397. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22398. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22399. */
  22400. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22401. facetNormals?: any;
  22402. facetPositions?: any;
  22403. facetPartitioning?: any;
  22404. ratio?: number;
  22405. bInfo?: any;
  22406. bbSize?: Vector3;
  22407. subDiv?: any;
  22408. useRightHandedSystem?: boolean;
  22409. depthSort?: boolean;
  22410. distanceTo?: Vector3;
  22411. depthSortedFacets?: any;
  22412. }): void;
  22413. /** @hidden */
  22414. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22415. /**
  22416. * Applies VertexData created from the imported parameters to the geometry
  22417. * @param parsedVertexData the parsed data from an imported file
  22418. * @param geometry the geometry to apply the VertexData to
  22419. */
  22420. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22421. }
  22422. }
  22423. declare module BABYLON {
  22424. /**
  22425. * Defines a target to use with MorphTargetManager
  22426. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22427. */
  22428. export class MorphTarget implements IAnimatable {
  22429. /** defines the name of the target */
  22430. name: string;
  22431. /**
  22432. * Gets or sets the list of animations
  22433. */
  22434. animations: Animation[];
  22435. private _scene;
  22436. private _positions;
  22437. private _normals;
  22438. private _tangents;
  22439. private _uvs;
  22440. private _influence;
  22441. private _uniqueId;
  22442. /**
  22443. * Observable raised when the influence changes
  22444. */
  22445. onInfluenceChanged: Observable<boolean>;
  22446. /** @hidden */
  22447. _onDataLayoutChanged: Observable<void>;
  22448. /**
  22449. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22450. */
  22451. get influence(): number;
  22452. set influence(influence: number);
  22453. /**
  22454. * Gets or sets the id of the morph Target
  22455. */
  22456. id: string;
  22457. private _animationPropertiesOverride;
  22458. /**
  22459. * Gets or sets the animation properties override
  22460. */
  22461. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  22462. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  22463. /**
  22464. * Creates a new MorphTarget
  22465. * @param name defines the name of the target
  22466. * @param influence defines the influence to use
  22467. * @param scene defines the scene the morphtarget belongs to
  22468. */
  22469. constructor(
  22470. /** defines the name of the target */
  22471. name: string, influence?: number, scene?: Nullable<Scene>);
  22472. /**
  22473. * Gets the unique ID of this manager
  22474. */
  22475. get uniqueId(): number;
  22476. /**
  22477. * Gets a boolean defining if the target contains position data
  22478. */
  22479. get hasPositions(): boolean;
  22480. /**
  22481. * Gets a boolean defining if the target contains normal data
  22482. */
  22483. get hasNormals(): boolean;
  22484. /**
  22485. * Gets a boolean defining if the target contains tangent data
  22486. */
  22487. get hasTangents(): boolean;
  22488. /**
  22489. * Gets a boolean defining if the target contains texture coordinates data
  22490. */
  22491. get hasUVs(): boolean;
  22492. /**
  22493. * Affects position data to this target
  22494. * @param data defines the position data to use
  22495. */
  22496. setPositions(data: Nullable<FloatArray>): void;
  22497. /**
  22498. * Gets the position data stored in this target
  22499. * @returns a FloatArray containing the position data (or null if not present)
  22500. */
  22501. getPositions(): Nullable<FloatArray>;
  22502. /**
  22503. * Affects normal data to this target
  22504. * @param data defines the normal data to use
  22505. */
  22506. setNormals(data: Nullable<FloatArray>): void;
  22507. /**
  22508. * Gets the normal data stored in this target
  22509. * @returns a FloatArray containing the normal data (or null if not present)
  22510. */
  22511. getNormals(): Nullable<FloatArray>;
  22512. /**
  22513. * Affects tangent data to this target
  22514. * @param data defines the tangent data to use
  22515. */
  22516. setTangents(data: Nullable<FloatArray>): void;
  22517. /**
  22518. * Gets the tangent data stored in this target
  22519. * @returns a FloatArray containing the tangent data (or null if not present)
  22520. */
  22521. getTangents(): Nullable<FloatArray>;
  22522. /**
  22523. * Affects texture coordinates data to this target
  22524. * @param data defines the texture coordinates data to use
  22525. */
  22526. setUVs(data: Nullable<FloatArray>): void;
  22527. /**
  22528. * Gets the texture coordinates data stored in this target
  22529. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22530. */
  22531. getUVs(): Nullable<FloatArray>;
  22532. /**
  22533. * Clone the current target
  22534. * @returns a new MorphTarget
  22535. */
  22536. clone(): MorphTarget;
  22537. /**
  22538. * Serializes the current target into a Serialization object
  22539. * @returns the serialized object
  22540. */
  22541. serialize(): any;
  22542. /**
  22543. * Returns the string "MorphTarget"
  22544. * @returns "MorphTarget"
  22545. */
  22546. getClassName(): string;
  22547. /**
  22548. * Creates a new target from serialized data
  22549. * @param serializationObject defines the serialized data to use
  22550. * @returns a new MorphTarget
  22551. */
  22552. static Parse(serializationObject: any): MorphTarget;
  22553. /**
  22554. * Creates a MorphTarget from mesh data
  22555. * @param mesh defines the source mesh
  22556. * @param name defines the name to use for the new target
  22557. * @param influence defines the influence to attach to the target
  22558. * @returns a new MorphTarget
  22559. */
  22560. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  22561. }
  22562. }
  22563. declare module BABYLON {
  22564. /**
  22565. * This class is used to deform meshes using morphing between different targets
  22566. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22567. */
  22568. export class MorphTargetManager {
  22569. private _targets;
  22570. private _targetInfluenceChangedObservers;
  22571. private _targetDataLayoutChangedObservers;
  22572. private _activeTargets;
  22573. private _scene;
  22574. private _influences;
  22575. private _supportsNormals;
  22576. private _supportsTangents;
  22577. private _supportsUVs;
  22578. private _vertexCount;
  22579. private _uniqueId;
  22580. private _tempInfluences;
  22581. /**
  22582. * Gets or sets a boolean indicating if normals must be morphed
  22583. */
  22584. enableNormalMorphing: boolean;
  22585. /**
  22586. * Gets or sets a boolean indicating if tangents must be morphed
  22587. */
  22588. enableTangentMorphing: boolean;
  22589. /**
  22590. * Gets or sets a boolean indicating if UV must be morphed
  22591. */
  22592. enableUVMorphing: boolean;
  22593. /**
  22594. * Creates a new MorphTargetManager
  22595. * @param scene defines the current scene
  22596. */
  22597. constructor(scene?: Nullable<Scene>);
  22598. /**
  22599. * Gets the unique ID of this manager
  22600. */
  22601. get uniqueId(): number;
  22602. /**
  22603. * Gets the number of vertices handled by this manager
  22604. */
  22605. get vertexCount(): number;
  22606. /**
  22607. * Gets a boolean indicating if this manager supports morphing of normals
  22608. */
  22609. get supportsNormals(): boolean;
  22610. /**
  22611. * Gets a boolean indicating if this manager supports morphing of tangents
  22612. */
  22613. get supportsTangents(): boolean;
  22614. /**
  22615. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  22616. */
  22617. get supportsUVs(): boolean;
  22618. /**
  22619. * Gets the number of targets stored in this manager
  22620. */
  22621. get numTargets(): number;
  22622. /**
  22623. * Gets the number of influencers (ie. the number of targets with influences > 0)
  22624. */
  22625. get numInfluencers(): number;
  22626. /**
  22627. * Gets the list of influences (one per target)
  22628. */
  22629. get influences(): Float32Array;
  22630. /**
  22631. * Gets the active target at specified index. An active target is a target with an influence > 0
  22632. * @param index defines the index to check
  22633. * @returns the requested target
  22634. */
  22635. getActiveTarget(index: number): MorphTarget;
  22636. /**
  22637. * Gets the target at specified index
  22638. * @param index defines the index to check
  22639. * @returns the requested target
  22640. */
  22641. getTarget(index: number): MorphTarget;
  22642. /**
  22643. * Add a new target to this manager
  22644. * @param target defines the target to add
  22645. */
  22646. addTarget(target: MorphTarget): void;
  22647. /**
  22648. * Removes a target from the manager
  22649. * @param target defines the target to remove
  22650. */
  22651. removeTarget(target: MorphTarget): void;
  22652. /**
  22653. * Clone the current manager
  22654. * @returns a new MorphTargetManager
  22655. */
  22656. clone(): MorphTargetManager;
  22657. /**
  22658. * Serializes the current manager into a Serialization object
  22659. * @returns the serialized object
  22660. */
  22661. serialize(): any;
  22662. private _syncActiveTargets;
  22663. /**
  22664. * Syncrhonize the targets with all the meshes using this morph target manager
  22665. */
  22666. synchronize(): void;
  22667. /**
  22668. * Creates a new MorphTargetManager from serialized data
  22669. * @param serializationObject defines the serialized data
  22670. * @param scene defines the hosting scene
  22671. * @returns the new MorphTargetManager
  22672. */
  22673. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  22674. }
  22675. }
  22676. declare module BABYLON {
  22677. /**
  22678. * Class used to represent a specific level of detail of a mesh
  22679. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  22680. */
  22681. export class MeshLODLevel {
  22682. /** Defines the distance where this level should start being displayed */
  22683. distance: number;
  22684. /** Defines the mesh to use to render this level */
  22685. mesh: Nullable<Mesh>;
  22686. /**
  22687. * Creates a new LOD level
  22688. * @param distance defines the distance where this level should star being displayed
  22689. * @param mesh defines the mesh to use to render this level
  22690. */
  22691. constructor(
  22692. /** Defines the distance where this level should start being displayed */
  22693. distance: number,
  22694. /** Defines the mesh to use to render this level */
  22695. mesh: Nullable<Mesh>);
  22696. }
  22697. }
  22698. declare module BABYLON {
  22699. /**
  22700. * Mesh representing the gorund
  22701. */
  22702. export class GroundMesh extends Mesh {
  22703. /** If octree should be generated */
  22704. generateOctree: boolean;
  22705. private _heightQuads;
  22706. /** @hidden */
  22707. _subdivisionsX: number;
  22708. /** @hidden */
  22709. _subdivisionsY: number;
  22710. /** @hidden */
  22711. _width: number;
  22712. /** @hidden */
  22713. _height: number;
  22714. /** @hidden */
  22715. _minX: number;
  22716. /** @hidden */
  22717. _maxX: number;
  22718. /** @hidden */
  22719. _minZ: number;
  22720. /** @hidden */
  22721. _maxZ: number;
  22722. constructor(name: string, scene: Scene);
  22723. /**
  22724. * "GroundMesh"
  22725. * @returns "GroundMesh"
  22726. */
  22727. getClassName(): string;
  22728. /**
  22729. * The minimum of x and y subdivisions
  22730. */
  22731. get subdivisions(): number;
  22732. /**
  22733. * X subdivisions
  22734. */
  22735. get subdivisionsX(): number;
  22736. /**
  22737. * Y subdivisions
  22738. */
  22739. get subdivisionsY(): number;
  22740. /**
  22741. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  22742. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  22743. * @param chunksCount the number of subdivisions for x and y
  22744. * @param octreeBlocksSize (Default: 32)
  22745. */
  22746. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  22747. /**
  22748. * Returns a height (y) value in the Worl system :
  22749. * the ground altitude at the coordinates (x, z) expressed in the World system.
  22750. * @param x x coordinate
  22751. * @param z z coordinate
  22752. * @returns the ground y position if (x, z) are outside the ground surface.
  22753. */
  22754. getHeightAtCoordinates(x: number, z: number): number;
  22755. /**
  22756. * Returns a normalized vector (Vector3) orthogonal to the ground
  22757. * at the ground coordinates (x, z) expressed in the World system.
  22758. * @param x x coordinate
  22759. * @param z z coordinate
  22760. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  22761. */
  22762. getNormalAtCoordinates(x: number, z: number): Vector3;
  22763. /**
  22764. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  22765. * at the ground coordinates (x, z) expressed in the World system.
  22766. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  22767. * @param x x coordinate
  22768. * @param z z coordinate
  22769. * @param ref vector to store the result
  22770. * @returns the GroundMesh.
  22771. */
  22772. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  22773. /**
  22774. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  22775. * if the ground has been updated.
  22776. * This can be used in the render loop.
  22777. * @returns the GroundMesh.
  22778. */
  22779. updateCoordinateHeights(): GroundMesh;
  22780. private _getFacetAt;
  22781. private _initHeightQuads;
  22782. private _computeHeightQuads;
  22783. /**
  22784. * Serializes this ground mesh
  22785. * @param serializationObject object to write serialization to
  22786. */
  22787. serialize(serializationObject: any): void;
  22788. /**
  22789. * Parses a serialized ground mesh
  22790. * @param parsedMesh the serialized mesh
  22791. * @param scene the scene to create the ground mesh in
  22792. * @returns the created ground mesh
  22793. */
  22794. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  22795. }
  22796. }
  22797. declare module BABYLON {
  22798. /**
  22799. * Interface for Physics-Joint data
  22800. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22801. */
  22802. export interface PhysicsJointData {
  22803. /**
  22804. * The main pivot of the joint
  22805. */
  22806. mainPivot?: Vector3;
  22807. /**
  22808. * The connected pivot of the joint
  22809. */
  22810. connectedPivot?: Vector3;
  22811. /**
  22812. * The main axis of the joint
  22813. */
  22814. mainAxis?: Vector3;
  22815. /**
  22816. * The connected axis of the joint
  22817. */
  22818. connectedAxis?: Vector3;
  22819. /**
  22820. * The collision of the joint
  22821. */
  22822. collision?: boolean;
  22823. /**
  22824. * Native Oimo/Cannon/Energy data
  22825. */
  22826. nativeParams?: any;
  22827. }
  22828. /**
  22829. * This is a holder class for the physics joint created by the physics plugin
  22830. * It holds a set of functions to control the underlying joint
  22831. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22832. */
  22833. export class PhysicsJoint {
  22834. /**
  22835. * The type of the physics joint
  22836. */
  22837. type: number;
  22838. /**
  22839. * The data for the physics joint
  22840. */
  22841. jointData: PhysicsJointData;
  22842. private _physicsJoint;
  22843. protected _physicsPlugin: IPhysicsEnginePlugin;
  22844. /**
  22845. * Initializes the physics joint
  22846. * @param type The type of the physics joint
  22847. * @param jointData The data for the physics joint
  22848. */
  22849. constructor(
  22850. /**
  22851. * The type of the physics joint
  22852. */
  22853. type: number,
  22854. /**
  22855. * The data for the physics joint
  22856. */
  22857. jointData: PhysicsJointData);
  22858. /**
  22859. * Gets the physics joint
  22860. */
  22861. get physicsJoint(): any;
  22862. /**
  22863. * Sets the physics joint
  22864. */
  22865. set physicsJoint(newJoint: any);
  22866. /**
  22867. * Sets the physics plugin
  22868. */
  22869. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  22870. /**
  22871. * Execute a function that is physics-plugin specific.
  22872. * @param {Function} func the function that will be executed.
  22873. * It accepts two parameters: the physics world and the physics joint
  22874. */
  22875. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  22876. /**
  22877. * Distance-Joint type
  22878. */
  22879. static DistanceJoint: number;
  22880. /**
  22881. * Hinge-Joint type
  22882. */
  22883. static HingeJoint: number;
  22884. /**
  22885. * Ball-and-Socket joint type
  22886. */
  22887. static BallAndSocketJoint: number;
  22888. /**
  22889. * Wheel-Joint type
  22890. */
  22891. static WheelJoint: number;
  22892. /**
  22893. * Slider-Joint type
  22894. */
  22895. static SliderJoint: number;
  22896. /**
  22897. * Prismatic-Joint type
  22898. */
  22899. static PrismaticJoint: number;
  22900. /**
  22901. * Universal-Joint type
  22902. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  22903. */
  22904. static UniversalJoint: number;
  22905. /**
  22906. * Hinge-Joint 2 type
  22907. */
  22908. static Hinge2Joint: number;
  22909. /**
  22910. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  22911. */
  22912. static PointToPointJoint: number;
  22913. /**
  22914. * Spring-Joint type
  22915. */
  22916. static SpringJoint: number;
  22917. /**
  22918. * Lock-Joint type
  22919. */
  22920. static LockJoint: number;
  22921. }
  22922. /**
  22923. * A class representing a physics distance joint
  22924. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22925. */
  22926. export class DistanceJoint extends PhysicsJoint {
  22927. /**
  22928. *
  22929. * @param jointData The data for the Distance-Joint
  22930. */
  22931. constructor(jointData: DistanceJointData);
  22932. /**
  22933. * Update the predefined distance.
  22934. * @param maxDistance The maximum preferred distance
  22935. * @param minDistance The minimum preferred distance
  22936. */
  22937. updateDistance(maxDistance: number, minDistance?: number): void;
  22938. }
  22939. /**
  22940. * Represents a Motor-Enabled Joint
  22941. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22942. */
  22943. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  22944. /**
  22945. * Initializes the Motor-Enabled Joint
  22946. * @param type The type of the joint
  22947. * @param jointData The physica joint data for the joint
  22948. */
  22949. constructor(type: number, jointData: PhysicsJointData);
  22950. /**
  22951. * Set the motor values.
  22952. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22953. * @param force the force to apply
  22954. * @param maxForce max force for this motor.
  22955. */
  22956. setMotor(force?: number, maxForce?: number): void;
  22957. /**
  22958. * Set the motor's limits.
  22959. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22960. * @param upperLimit The upper limit of the motor
  22961. * @param lowerLimit The lower limit of the motor
  22962. */
  22963. setLimit(upperLimit: number, lowerLimit?: number): void;
  22964. }
  22965. /**
  22966. * This class represents a single physics Hinge-Joint
  22967. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22968. */
  22969. export class HingeJoint extends MotorEnabledJoint {
  22970. /**
  22971. * Initializes the Hinge-Joint
  22972. * @param jointData The joint data for the Hinge-Joint
  22973. */
  22974. constructor(jointData: PhysicsJointData);
  22975. /**
  22976. * Set the motor values.
  22977. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22978. * @param {number} force the force to apply
  22979. * @param {number} maxForce max force for this motor.
  22980. */
  22981. setMotor(force?: number, maxForce?: number): void;
  22982. /**
  22983. * Set the motor's limits.
  22984. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22985. * @param upperLimit The upper limit of the motor
  22986. * @param lowerLimit The lower limit of the motor
  22987. */
  22988. setLimit(upperLimit: number, lowerLimit?: number): void;
  22989. }
  22990. /**
  22991. * This class represents a dual hinge physics joint (same as wheel joint)
  22992. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22993. */
  22994. export class Hinge2Joint extends MotorEnabledJoint {
  22995. /**
  22996. * Initializes the Hinge2-Joint
  22997. * @param jointData The joint data for the Hinge2-Joint
  22998. */
  22999. constructor(jointData: PhysicsJointData);
  23000. /**
  23001. * Set the motor values.
  23002. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23003. * @param {number} targetSpeed the speed the motor is to reach
  23004. * @param {number} maxForce max force for this motor.
  23005. * @param {motorIndex} the motor's index, 0 or 1.
  23006. */
  23007. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23008. /**
  23009. * Set the motor limits.
  23010. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23011. * @param {number} upperLimit the upper limit
  23012. * @param {number} lowerLimit lower limit
  23013. * @param {motorIndex} the motor's index, 0 or 1.
  23014. */
  23015. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23016. }
  23017. /**
  23018. * Interface for a motor enabled joint
  23019. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23020. */
  23021. export interface IMotorEnabledJoint {
  23022. /**
  23023. * Physics joint
  23024. */
  23025. physicsJoint: any;
  23026. /**
  23027. * Sets the motor of the motor-enabled joint
  23028. * @param force The force of the motor
  23029. * @param maxForce The maximum force of the motor
  23030. * @param motorIndex The index of the motor
  23031. */
  23032. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23033. /**
  23034. * Sets the limit of the motor
  23035. * @param upperLimit The upper limit of the motor
  23036. * @param lowerLimit The lower limit of the motor
  23037. * @param motorIndex The index of the motor
  23038. */
  23039. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23040. }
  23041. /**
  23042. * Joint data for a Distance-Joint
  23043. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23044. */
  23045. export interface DistanceJointData extends PhysicsJointData {
  23046. /**
  23047. * Max distance the 2 joint objects can be apart
  23048. */
  23049. maxDistance: number;
  23050. }
  23051. /**
  23052. * Joint data from a spring joint
  23053. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23054. */
  23055. export interface SpringJointData extends PhysicsJointData {
  23056. /**
  23057. * Length of the spring
  23058. */
  23059. length: number;
  23060. /**
  23061. * Stiffness of the spring
  23062. */
  23063. stiffness: number;
  23064. /**
  23065. * Damping of the spring
  23066. */
  23067. damping: number;
  23068. /** this callback will be called when applying the force to the impostors. */
  23069. forceApplicationCallback: () => void;
  23070. }
  23071. }
  23072. declare module BABYLON {
  23073. /**
  23074. * Holds the data for the raycast result
  23075. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23076. */
  23077. export class PhysicsRaycastResult {
  23078. private _hasHit;
  23079. private _hitDistance;
  23080. private _hitNormalWorld;
  23081. private _hitPointWorld;
  23082. private _rayFromWorld;
  23083. private _rayToWorld;
  23084. /**
  23085. * Gets if there was a hit
  23086. */
  23087. get hasHit(): boolean;
  23088. /**
  23089. * Gets the distance from the hit
  23090. */
  23091. get hitDistance(): number;
  23092. /**
  23093. * Gets the hit normal/direction in the world
  23094. */
  23095. get hitNormalWorld(): Vector3;
  23096. /**
  23097. * Gets the hit point in the world
  23098. */
  23099. get hitPointWorld(): Vector3;
  23100. /**
  23101. * Gets the ray "start point" of the ray in the world
  23102. */
  23103. get rayFromWorld(): Vector3;
  23104. /**
  23105. * Gets the ray "end point" of the ray in the world
  23106. */
  23107. get rayToWorld(): Vector3;
  23108. /**
  23109. * Sets the hit data (normal & point in world space)
  23110. * @param hitNormalWorld defines the normal in world space
  23111. * @param hitPointWorld defines the point in world space
  23112. */
  23113. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23114. /**
  23115. * Sets the distance from the start point to the hit point
  23116. * @param distance
  23117. */
  23118. setHitDistance(distance: number): void;
  23119. /**
  23120. * Calculates the distance manually
  23121. */
  23122. calculateHitDistance(): void;
  23123. /**
  23124. * Resets all the values to default
  23125. * @param from The from point on world space
  23126. * @param to The to point on world space
  23127. */
  23128. reset(from?: Vector3, to?: Vector3): void;
  23129. }
  23130. /**
  23131. * Interface for the size containing width and height
  23132. */
  23133. interface IXYZ {
  23134. /**
  23135. * X
  23136. */
  23137. x: number;
  23138. /**
  23139. * Y
  23140. */
  23141. y: number;
  23142. /**
  23143. * Z
  23144. */
  23145. z: number;
  23146. }
  23147. }
  23148. declare module BABYLON {
  23149. /**
  23150. * Interface used to describe a physics joint
  23151. */
  23152. export interface PhysicsImpostorJoint {
  23153. /** Defines the main impostor to which the joint is linked */
  23154. mainImpostor: PhysicsImpostor;
  23155. /** Defines the impostor that is connected to the main impostor using this joint */
  23156. connectedImpostor: PhysicsImpostor;
  23157. /** Defines the joint itself */
  23158. joint: PhysicsJoint;
  23159. }
  23160. /** @hidden */
  23161. export interface IPhysicsEnginePlugin {
  23162. world: any;
  23163. name: string;
  23164. setGravity(gravity: Vector3): void;
  23165. setTimeStep(timeStep: number): void;
  23166. getTimeStep(): number;
  23167. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23168. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23169. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23170. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23171. removePhysicsBody(impostor: PhysicsImpostor): void;
  23172. generateJoint(joint: PhysicsImpostorJoint): void;
  23173. removeJoint(joint: PhysicsImpostorJoint): void;
  23174. isSupported(): boolean;
  23175. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23176. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23177. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23178. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23179. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23180. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23181. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23182. getBodyMass(impostor: PhysicsImpostor): number;
  23183. getBodyFriction(impostor: PhysicsImpostor): number;
  23184. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23185. getBodyRestitution(impostor: PhysicsImpostor): number;
  23186. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23187. getBodyPressure?(impostor: PhysicsImpostor): number;
  23188. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23189. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23190. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23191. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23192. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23193. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23194. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23195. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23196. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23197. sleepBody(impostor: PhysicsImpostor): void;
  23198. wakeUpBody(impostor: PhysicsImpostor): void;
  23199. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23200. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23201. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23202. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23203. getRadius(impostor: PhysicsImpostor): number;
  23204. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23205. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23206. dispose(): void;
  23207. }
  23208. /**
  23209. * Interface used to define a physics engine
  23210. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23211. */
  23212. export interface IPhysicsEngine {
  23213. /**
  23214. * Gets the gravity vector used by the simulation
  23215. */
  23216. gravity: Vector3;
  23217. /**
  23218. * Sets the gravity vector used by the simulation
  23219. * @param gravity defines the gravity vector to use
  23220. */
  23221. setGravity(gravity: Vector3): void;
  23222. /**
  23223. * Set the time step of the physics engine.
  23224. * Default is 1/60.
  23225. * To slow it down, enter 1/600 for example.
  23226. * To speed it up, 1/30
  23227. * @param newTimeStep the new timestep to apply to this world.
  23228. */
  23229. setTimeStep(newTimeStep: number): void;
  23230. /**
  23231. * Get the time step of the physics engine.
  23232. * @returns the current time step
  23233. */
  23234. getTimeStep(): number;
  23235. /**
  23236. * Set the sub time step of the physics engine.
  23237. * Default is 0 meaning there is no sub steps
  23238. * To increase physics resolution precision, set a small value (like 1 ms)
  23239. * @param subTimeStep defines the new sub timestep used for physics resolution.
  23240. */
  23241. setSubTimeStep(subTimeStep: number): void;
  23242. /**
  23243. * Get the sub time step of the physics engine.
  23244. * @returns the current sub time step
  23245. */
  23246. getSubTimeStep(): number;
  23247. /**
  23248. * Release all resources
  23249. */
  23250. dispose(): void;
  23251. /**
  23252. * Gets the name of the current physics plugin
  23253. * @returns the name of the plugin
  23254. */
  23255. getPhysicsPluginName(): string;
  23256. /**
  23257. * Adding a new impostor for the impostor tracking.
  23258. * This will be done by the impostor itself.
  23259. * @param impostor the impostor to add
  23260. */
  23261. addImpostor(impostor: PhysicsImpostor): void;
  23262. /**
  23263. * Remove an impostor from the engine.
  23264. * This impostor and its mesh will not longer be updated by the physics engine.
  23265. * @param impostor the impostor to remove
  23266. */
  23267. removeImpostor(impostor: PhysicsImpostor): void;
  23268. /**
  23269. * Add a joint to the physics engine
  23270. * @param mainImpostor defines the main impostor to which the joint is added.
  23271. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23272. * @param joint defines the joint that will connect both impostors.
  23273. */
  23274. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23275. /**
  23276. * Removes a joint from the simulation
  23277. * @param mainImpostor defines the impostor used with the joint
  23278. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23279. * @param joint defines the joint to remove
  23280. */
  23281. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23282. /**
  23283. * Gets the current plugin used to run the simulation
  23284. * @returns current plugin
  23285. */
  23286. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23287. /**
  23288. * Gets the list of physic impostors
  23289. * @returns an array of PhysicsImpostor
  23290. */
  23291. getImpostors(): Array<PhysicsImpostor>;
  23292. /**
  23293. * Gets the impostor for a physics enabled object
  23294. * @param object defines the object impersonated by the impostor
  23295. * @returns the PhysicsImpostor or null if not found
  23296. */
  23297. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23298. /**
  23299. * Gets the impostor for a physics body object
  23300. * @param body defines physics body used by the impostor
  23301. * @returns the PhysicsImpostor or null if not found
  23302. */
  23303. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23304. /**
  23305. * Does a raycast in the physics world
  23306. * @param from when should the ray start?
  23307. * @param to when should the ray end?
  23308. * @returns PhysicsRaycastResult
  23309. */
  23310. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23311. /**
  23312. * Called by the scene. No need to call it.
  23313. * @param delta defines the timespam between frames
  23314. */
  23315. _step(delta: number): void;
  23316. }
  23317. }
  23318. declare module BABYLON {
  23319. /**
  23320. * The interface for the physics imposter parameters
  23321. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23322. */
  23323. export interface PhysicsImpostorParameters {
  23324. /**
  23325. * The mass of the physics imposter
  23326. */
  23327. mass: number;
  23328. /**
  23329. * The friction of the physics imposter
  23330. */
  23331. friction?: number;
  23332. /**
  23333. * The coefficient of restitution of the physics imposter
  23334. */
  23335. restitution?: number;
  23336. /**
  23337. * The native options of the physics imposter
  23338. */
  23339. nativeOptions?: any;
  23340. /**
  23341. * Specifies if the parent should be ignored
  23342. */
  23343. ignoreParent?: boolean;
  23344. /**
  23345. * Specifies if bi-directional transformations should be disabled
  23346. */
  23347. disableBidirectionalTransformation?: boolean;
  23348. /**
  23349. * The pressure inside the physics imposter, soft object only
  23350. */
  23351. pressure?: number;
  23352. /**
  23353. * The stiffness the physics imposter, soft object only
  23354. */
  23355. stiffness?: number;
  23356. /**
  23357. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23358. */
  23359. velocityIterations?: number;
  23360. /**
  23361. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23362. */
  23363. positionIterations?: number;
  23364. /**
  23365. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23366. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23367. * Add to fix multiple points
  23368. */
  23369. fixedPoints?: number;
  23370. /**
  23371. * The collision margin around a soft object
  23372. */
  23373. margin?: number;
  23374. /**
  23375. * The collision margin around a soft object
  23376. */
  23377. damping?: number;
  23378. /**
  23379. * The path for a rope based on an extrusion
  23380. */
  23381. path?: any;
  23382. /**
  23383. * The shape of an extrusion used for a rope based on an extrusion
  23384. */
  23385. shape?: any;
  23386. }
  23387. /**
  23388. * Interface for a physics-enabled object
  23389. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23390. */
  23391. export interface IPhysicsEnabledObject {
  23392. /**
  23393. * The position of the physics-enabled object
  23394. */
  23395. position: Vector3;
  23396. /**
  23397. * The rotation of the physics-enabled object
  23398. */
  23399. rotationQuaternion: Nullable<Quaternion>;
  23400. /**
  23401. * The scale of the physics-enabled object
  23402. */
  23403. scaling: Vector3;
  23404. /**
  23405. * The rotation of the physics-enabled object
  23406. */
  23407. rotation?: Vector3;
  23408. /**
  23409. * The parent of the physics-enabled object
  23410. */
  23411. parent?: any;
  23412. /**
  23413. * The bounding info of the physics-enabled object
  23414. * @returns The bounding info of the physics-enabled object
  23415. */
  23416. getBoundingInfo(): BoundingInfo;
  23417. /**
  23418. * Computes the world matrix
  23419. * @param force Specifies if the world matrix should be computed by force
  23420. * @returns A world matrix
  23421. */
  23422. computeWorldMatrix(force: boolean): Matrix;
  23423. /**
  23424. * Gets the world matrix
  23425. * @returns A world matrix
  23426. */
  23427. getWorldMatrix?(): Matrix;
  23428. /**
  23429. * Gets the child meshes
  23430. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23431. * @returns An array of abstract meshes
  23432. */
  23433. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23434. /**
  23435. * Gets the vertex data
  23436. * @param kind The type of vertex data
  23437. * @returns A nullable array of numbers, or a float32 array
  23438. */
  23439. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23440. /**
  23441. * Gets the indices from the mesh
  23442. * @returns A nullable array of index arrays
  23443. */
  23444. getIndices?(): Nullable<IndicesArray>;
  23445. /**
  23446. * Gets the scene from the mesh
  23447. * @returns the indices array or null
  23448. */
  23449. getScene?(): Scene;
  23450. /**
  23451. * Gets the absolute position from the mesh
  23452. * @returns the absolute position
  23453. */
  23454. getAbsolutePosition(): Vector3;
  23455. /**
  23456. * Gets the absolute pivot point from the mesh
  23457. * @returns the absolute pivot point
  23458. */
  23459. getAbsolutePivotPoint(): Vector3;
  23460. /**
  23461. * Rotates the mesh
  23462. * @param axis The axis of rotation
  23463. * @param amount The amount of rotation
  23464. * @param space The space of the rotation
  23465. * @returns The rotation transform node
  23466. */
  23467. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23468. /**
  23469. * Translates the mesh
  23470. * @param axis The axis of translation
  23471. * @param distance The distance of translation
  23472. * @param space The space of the translation
  23473. * @returns The transform node
  23474. */
  23475. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23476. /**
  23477. * Sets the absolute position of the mesh
  23478. * @param absolutePosition The absolute position of the mesh
  23479. * @returns The transform node
  23480. */
  23481. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23482. /**
  23483. * Gets the class name of the mesh
  23484. * @returns The class name
  23485. */
  23486. getClassName(): string;
  23487. }
  23488. /**
  23489. * Represents a physics imposter
  23490. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23491. */
  23492. export class PhysicsImpostor {
  23493. /**
  23494. * The physics-enabled object used as the physics imposter
  23495. */
  23496. object: IPhysicsEnabledObject;
  23497. /**
  23498. * The type of the physics imposter
  23499. */
  23500. type: number;
  23501. private _options;
  23502. private _scene?;
  23503. /**
  23504. * The default object size of the imposter
  23505. */
  23506. static DEFAULT_OBJECT_SIZE: Vector3;
  23507. /**
  23508. * The identity quaternion of the imposter
  23509. */
  23510. static IDENTITY_QUATERNION: Quaternion;
  23511. /** @hidden */
  23512. _pluginData: any;
  23513. private _physicsEngine;
  23514. private _physicsBody;
  23515. private _bodyUpdateRequired;
  23516. private _onBeforePhysicsStepCallbacks;
  23517. private _onAfterPhysicsStepCallbacks;
  23518. /** @hidden */
  23519. _onPhysicsCollideCallbacks: Array<{
  23520. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  23521. otherImpostors: Array<PhysicsImpostor>;
  23522. }>;
  23523. private _deltaPosition;
  23524. private _deltaRotation;
  23525. private _deltaRotationConjugated;
  23526. /** @hidden */
  23527. _isFromLine: boolean;
  23528. private _parent;
  23529. private _isDisposed;
  23530. private static _tmpVecs;
  23531. private static _tmpQuat;
  23532. /**
  23533. * Specifies if the physics imposter is disposed
  23534. */
  23535. get isDisposed(): boolean;
  23536. /**
  23537. * Gets the mass of the physics imposter
  23538. */
  23539. get mass(): number;
  23540. set mass(value: number);
  23541. /**
  23542. * Gets the coefficient of friction
  23543. */
  23544. get friction(): number;
  23545. /**
  23546. * Sets the coefficient of friction
  23547. */
  23548. set friction(value: number);
  23549. /**
  23550. * Gets the coefficient of restitution
  23551. */
  23552. get restitution(): number;
  23553. /**
  23554. * Sets the coefficient of restitution
  23555. */
  23556. set restitution(value: number);
  23557. /**
  23558. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  23559. */
  23560. get pressure(): number;
  23561. /**
  23562. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  23563. */
  23564. set pressure(value: number);
  23565. /**
  23566. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23567. */
  23568. get stiffness(): number;
  23569. /**
  23570. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23571. */
  23572. set stiffness(value: number);
  23573. /**
  23574. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23575. */
  23576. get velocityIterations(): number;
  23577. /**
  23578. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23579. */
  23580. set velocityIterations(value: number);
  23581. /**
  23582. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23583. */
  23584. get positionIterations(): number;
  23585. /**
  23586. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23587. */
  23588. set positionIterations(value: number);
  23589. /**
  23590. * The unique id of the physics imposter
  23591. * set by the physics engine when adding this impostor to the array
  23592. */
  23593. uniqueId: number;
  23594. /**
  23595. * @hidden
  23596. */
  23597. soft: boolean;
  23598. /**
  23599. * @hidden
  23600. */
  23601. segments: number;
  23602. private _joints;
  23603. /**
  23604. * Initializes the physics imposter
  23605. * @param object The physics-enabled object used as the physics imposter
  23606. * @param type The type of the physics imposter
  23607. * @param _options The options for the physics imposter
  23608. * @param _scene The Babylon scene
  23609. */
  23610. constructor(
  23611. /**
  23612. * The physics-enabled object used as the physics imposter
  23613. */
  23614. object: IPhysicsEnabledObject,
  23615. /**
  23616. * The type of the physics imposter
  23617. */
  23618. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  23619. /**
  23620. * This function will completly initialize this impostor.
  23621. * It will create a new body - but only if this mesh has no parent.
  23622. * If it has, this impostor will not be used other than to define the impostor
  23623. * of the child mesh.
  23624. * @hidden
  23625. */
  23626. _init(): void;
  23627. private _getPhysicsParent;
  23628. /**
  23629. * Should a new body be generated.
  23630. * @returns boolean specifying if body initialization is required
  23631. */
  23632. isBodyInitRequired(): boolean;
  23633. /**
  23634. * Sets the updated scaling
  23635. * @param updated Specifies if the scaling is updated
  23636. */
  23637. setScalingUpdated(): void;
  23638. /**
  23639. * Force a regeneration of this or the parent's impostor's body.
  23640. * Use under cautious - This will remove all joints already implemented.
  23641. */
  23642. forceUpdate(): void;
  23643. /**
  23644. * Gets the body that holds this impostor. Either its own, or its parent.
  23645. */
  23646. get physicsBody(): any;
  23647. /**
  23648. * Get the parent of the physics imposter
  23649. * @returns Physics imposter or null
  23650. */
  23651. get parent(): Nullable<PhysicsImpostor>;
  23652. /**
  23653. * Sets the parent of the physics imposter
  23654. */
  23655. set parent(value: Nullable<PhysicsImpostor>);
  23656. /**
  23657. * Set the physics body. Used mainly by the physics engine/plugin
  23658. */
  23659. set physicsBody(physicsBody: any);
  23660. /**
  23661. * Resets the update flags
  23662. */
  23663. resetUpdateFlags(): void;
  23664. /**
  23665. * Gets the object extend size
  23666. * @returns the object extend size
  23667. */
  23668. getObjectExtendSize(): Vector3;
  23669. /**
  23670. * Gets the object center
  23671. * @returns The object center
  23672. */
  23673. getObjectCenter(): Vector3;
  23674. /**
  23675. * Get a specific parametes from the options parameter
  23676. * @param paramName The object parameter name
  23677. * @returns The object parameter
  23678. */
  23679. getParam(paramName: string): any;
  23680. /**
  23681. * Sets a specific parameter in the options given to the physics plugin
  23682. * @param paramName The parameter name
  23683. * @param value The value of the parameter
  23684. */
  23685. setParam(paramName: string, value: number): void;
  23686. /**
  23687. * Specifically change the body's mass option. Won't recreate the physics body object
  23688. * @param mass The mass of the physics imposter
  23689. */
  23690. setMass(mass: number): void;
  23691. /**
  23692. * Gets the linear velocity
  23693. * @returns linear velocity or null
  23694. */
  23695. getLinearVelocity(): Nullable<Vector3>;
  23696. /**
  23697. * Sets the linear velocity
  23698. * @param velocity linear velocity or null
  23699. */
  23700. setLinearVelocity(velocity: Nullable<Vector3>): void;
  23701. /**
  23702. * Gets the angular velocity
  23703. * @returns angular velocity or null
  23704. */
  23705. getAngularVelocity(): Nullable<Vector3>;
  23706. /**
  23707. * Sets the angular velocity
  23708. * @param velocity The velocity or null
  23709. */
  23710. setAngularVelocity(velocity: Nullable<Vector3>): void;
  23711. /**
  23712. * Execute a function with the physics plugin native code
  23713. * Provide a function the will have two variables - the world object and the physics body object
  23714. * @param func The function to execute with the physics plugin native code
  23715. */
  23716. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  23717. /**
  23718. * Register a function that will be executed before the physics world is stepping forward
  23719. * @param func The function to execute before the physics world is stepped forward
  23720. */
  23721. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23722. /**
  23723. * Unregister a function that will be executed before the physics world is stepping forward
  23724. * @param func The function to execute before the physics world is stepped forward
  23725. */
  23726. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23727. /**
  23728. * Register a function that will be executed after the physics step
  23729. * @param func The function to execute after physics step
  23730. */
  23731. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23732. /**
  23733. * Unregisters a function that will be executed after the physics step
  23734. * @param func The function to execute after physics step
  23735. */
  23736. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23737. /**
  23738. * register a function that will be executed when this impostor collides against a different body
  23739. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  23740. * @param func Callback that is executed on collision
  23741. */
  23742. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  23743. /**
  23744. * Unregisters the physics imposter on contact
  23745. * @param collideAgainst The physics object to collide against
  23746. * @param func Callback to execute on collision
  23747. */
  23748. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  23749. private _tmpQuat;
  23750. private _tmpQuat2;
  23751. /**
  23752. * Get the parent rotation
  23753. * @returns The parent rotation
  23754. */
  23755. getParentsRotation(): Quaternion;
  23756. /**
  23757. * this function is executed by the physics engine.
  23758. */
  23759. beforeStep: () => void;
  23760. /**
  23761. * this function is executed by the physics engine
  23762. */
  23763. afterStep: () => void;
  23764. /**
  23765. * Legacy collision detection event support
  23766. */
  23767. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  23768. /**
  23769. * event and body object due to cannon's event-based architecture.
  23770. */
  23771. onCollide: (e: {
  23772. body: any;
  23773. }) => void;
  23774. /**
  23775. * Apply a force
  23776. * @param force The force to apply
  23777. * @param contactPoint The contact point for the force
  23778. * @returns The physics imposter
  23779. */
  23780. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23781. /**
  23782. * Apply an impulse
  23783. * @param force The impulse force
  23784. * @param contactPoint The contact point for the impulse force
  23785. * @returns The physics imposter
  23786. */
  23787. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23788. /**
  23789. * A help function to create a joint
  23790. * @param otherImpostor A physics imposter used to create a joint
  23791. * @param jointType The type of joint
  23792. * @param jointData The data for the joint
  23793. * @returns The physics imposter
  23794. */
  23795. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  23796. /**
  23797. * Add a joint to this impostor with a different impostor
  23798. * @param otherImpostor A physics imposter used to add a joint
  23799. * @param joint The joint to add
  23800. * @returns The physics imposter
  23801. */
  23802. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  23803. /**
  23804. * Add an anchor to a cloth impostor
  23805. * @param otherImpostor rigid impostor to anchor to
  23806. * @param width ratio across width from 0 to 1
  23807. * @param height ratio up height from 0 to 1
  23808. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  23809. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  23810. * @returns impostor the soft imposter
  23811. */
  23812. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23813. /**
  23814. * Add a hook to a rope impostor
  23815. * @param otherImpostor rigid impostor to anchor to
  23816. * @param length ratio across rope from 0 to 1
  23817. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  23818. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  23819. * @returns impostor the rope imposter
  23820. */
  23821. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23822. /**
  23823. * Will keep this body still, in a sleep mode.
  23824. * @returns the physics imposter
  23825. */
  23826. sleep(): PhysicsImpostor;
  23827. /**
  23828. * Wake the body up.
  23829. * @returns The physics imposter
  23830. */
  23831. wakeUp(): PhysicsImpostor;
  23832. /**
  23833. * Clones the physics imposter
  23834. * @param newObject The physics imposter clones to this physics-enabled object
  23835. * @returns A nullable physics imposter
  23836. */
  23837. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23838. /**
  23839. * Disposes the physics imposter
  23840. */
  23841. dispose(): void;
  23842. /**
  23843. * Sets the delta position
  23844. * @param position The delta position amount
  23845. */
  23846. setDeltaPosition(position: Vector3): void;
  23847. /**
  23848. * Sets the delta rotation
  23849. * @param rotation The delta rotation amount
  23850. */
  23851. setDeltaRotation(rotation: Quaternion): void;
  23852. /**
  23853. * Gets the box size of the physics imposter and stores the result in the input parameter
  23854. * @param result Stores the box size
  23855. * @returns The physics imposter
  23856. */
  23857. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  23858. /**
  23859. * Gets the radius of the physics imposter
  23860. * @returns Radius of the physics imposter
  23861. */
  23862. getRadius(): number;
  23863. /**
  23864. * Sync a bone with this impostor
  23865. * @param bone The bone to sync to the impostor.
  23866. * @param boneMesh The mesh that the bone is influencing.
  23867. * @param jointPivot The pivot of the joint / bone in local space.
  23868. * @param distToJoint Optional distance from the impostor to the joint.
  23869. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23870. */
  23871. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  23872. /**
  23873. * Sync impostor to a bone
  23874. * @param bone The bone that the impostor will be synced to.
  23875. * @param boneMesh The mesh that the bone is influencing.
  23876. * @param jointPivot The pivot of the joint / bone in local space.
  23877. * @param distToJoint Optional distance from the impostor to the joint.
  23878. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23879. * @param boneAxis Optional vector3 axis the bone is aligned with
  23880. */
  23881. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  23882. /**
  23883. * No-Imposter type
  23884. */
  23885. static NoImpostor: number;
  23886. /**
  23887. * Sphere-Imposter type
  23888. */
  23889. static SphereImpostor: number;
  23890. /**
  23891. * Box-Imposter type
  23892. */
  23893. static BoxImpostor: number;
  23894. /**
  23895. * Plane-Imposter type
  23896. */
  23897. static PlaneImpostor: number;
  23898. /**
  23899. * Mesh-imposter type
  23900. */
  23901. static MeshImpostor: number;
  23902. /**
  23903. * Capsule-Impostor type (Ammo.js plugin only)
  23904. */
  23905. static CapsuleImpostor: number;
  23906. /**
  23907. * Cylinder-Imposter type
  23908. */
  23909. static CylinderImpostor: number;
  23910. /**
  23911. * Particle-Imposter type
  23912. */
  23913. static ParticleImpostor: number;
  23914. /**
  23915. * Heightmap-Imposter type
  23916. */
  23917. static HeightmapImpostor: number;
  23918. /**
  23919. * ConvexHull-Impostor type (Ammo.js plugin only)
  23920. */
  23921. static ConvexHullImpostor: number;
  23922. /**
  23923. * Custom-Imposter type (Ammo.js plugin only)
  23924. */
  23925. static CustomImpostor: number;
  23926. /**
  23927. * Rope-Imposter type
  23928. */
  23929. static RopeImpostor: number;
  23930. /**
  23931. * Cloth-Imposter type
  23932. */
  23933. static ClothImpostor: number;
  23934. /**
  23935. * Softbody-Imposter type
  23936. */
  23937. static SoftbodyImpostor: number;
  23938. }
  23939. }
  23940. declare module BABYLON {
  23941. /**
  23942. * @hidden
  23943. **/
  23944. export class _CreationDataStorage {
  23945. closePath?: boolean;
  23946. closeArray?: boolean;
  23947. idx: number[];
  23948. dashSize: number;
  23949. gapSize: number;
  23950. path3D: Path3D;
  23951. pathArray: Vector3[][];
  23952. arc: number;
  23953. radius: number;
  23954. cap: number;
  23955. tessellation: number;
  23956. }
  23957. /**
  23958. * @hidden
  23959. **/
  23960. class _InstanceDataStorage {
  23961. visibleInstances: any;
  23962. batchCache: _InstancesBatch;
  23963. instancesBufferSize: number;
  23964. instancesBuffer: Nullable<Buffer>;
  23965. instancesData: Float32Array;
  23966. overridenInstanceCount: number;
  23967. isFrozen: boolean;
  23968. previousBatch: Nullable<_InstancesBatch>;
  23969. hardwareInstancedRendering: boolean;
  23970. sideOrientation: number;
  23971. manualUpdate: boolean;
  23972. }
  23973. /**
  23974. * @hidden
  23975. **/
  23976. export class _InstancesBatch {
  23977. mustReturn: boolean;
  23978. visibleInstances: Nullable<InstancedMesh[]>[];
  23979. renderSelf: boolean[];
  23980. hardwareInstancedRendering: boolean[];
  23981. }
  23982. /**
  23983. * Class used to represent renderable models
  23984. */
  23985. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  23986. /**
  23987. * Mesh side orientation : usually the external or front surface
  23988. */
  23989. static readonly FRONTSIDE: number;
  23990. /**
  23991. * Mesh side orientation : usually the internal or back surface
  23992. */
  23993. static readonly BACKSIDE: number;
  23994. /**
  23995. * Mesh side orientation : both internal and external or front and back surfaces
  23996. */
  23997. static readonly DOUBLESIDE: number;
  23998. /**
  23999. * Mesh side orientation : by default, `FRONTSIDE`
  24000. */
  24001. static readonly DEFAULTSIDE: number;
  24002. /**
  24003. * Mesh cap setting : no cap
  24004. */
  24005. static readonly NO_CAP: number;
  24006. /**
  24007. * Mesh cap setting : one cap at the beginning of the mesh
  24008. */
  24009. static readonly CAP_START: number;
  24010. /**
  24011. * Mesh cap setting : one cap at the end of the mesh
  24012. */
  24013. static readonly CAP_END: number;
  24014. /**
  24015. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24016. */
  24017. static readonly CAP_ALL: number;
  24018. /**
  24019. * Mesh pattern setting : no flip or rotate
  24020. */
  24021. static readonly NO_FLIP: number;
  24022. /**
  24023. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24024. */
  24025. static readonly FLIP_TILE: number;
  24026. /**
  24027. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24028. */
  24029. static readonly ROTATE_TILE: number;
  24030. /**
  24031. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24032. */
  24033. static readonly FLIP_ROW: number;
  24034. /**
  24035. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24036. */
  24037. static readonly ROTATE_ROW: number;
  24038. /**
  24039. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24040. */
  24041. static readonly FLIP_N_ROTATE_TILE: number;
  24042. /**
  24043. * Mesh pattern setting : rotate pattern and rotate
  24044. */
  24045. static readonly FLIP_N_ROTATE_ROW: number;
  24046. /**
  24047. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24048. */
  24049. static readonly CENTER: number;
  24050. /**
  24051. * Mesh tile positioning : part tiles on left
  24052. */
  24053. static readonly LEFT: number;
  24054. /**
  24055. * Mesh tile positioning : part tiles on right
  24056. */
  24057. static readonly RIGHT: number;
  24058. /**
  24059. * Mesh tile positioning : part tiles on top
  24060. */
  24061. static readonly TOP: number;
  24062. /**
  24063. * Mesh tile positioning : part tiles on bottom
  24064. */
  24065. static readonly BOTTOM: number;
  24066. /**
  24067. * Gets the default side orientation.
  24068. * @param orientation the orientation to value to attempt to get
  24069. * @returns the default orientation
  24070. * @hidden
  24071. */
  24072. static _GetDefaultSideOrientation(orientation?: number): number;
  24073. private _internalMeshDataInfo;
  24074. /**
  24075. * An event triggered before rendering the mesh
  24076. */
  24077. get onBeforeRenderObservable(): Observable<Mesh>;
  24078. /**
  24079. * An event triggered before binding the mesh
  24080. */
  24081. get onBeforeBindObservable(): Observable<Mesh>;
  24082. /**
  24083. * An event triggered after rendering the mesh
  24084. */
  24085. get onAfterRenderObservable(): Observable<Mesh>;
  24086. /**
  24087. * An event triggered before drawing the mesh
  24088. */
  24089. get onBeforeDrawObservable(): Observable<Mesh>;
  24090. private _onBeforeDrawObserver;
  24091. /**
  24092. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24093. */
  24094. set onBeforeDraw(callback: () => void);
  24095. get hasInstances(): boolean;
  24096. /**
  24097. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24098. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24099. */
  24100. delayLoadState: number;
  24101. /**
  24102. * Gets the list of instances created from this mesh
  24103. * it is not supposed to be modified manually.
  24104. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24105. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24106. */
  24107. instances: InstancedMesh[];
  24108. /**
  24109. * Gets the file containing delay loading data for this mesh
  24110. */
  24111. delayLoadingFile: string;
  24112. /** @hidden */
  24113. _binaryInfo: any;
  24114. /**
  24115. * User defined function used to change how LOD level selection is done
  24116. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24117. */
  24118. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24119. /**
  24120. * Gets or sets the morph target manager
  24121. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24122. */
  24123. get morphTargetManager(): Nullable<MorphTargetManager>;
  24124. set morphTargetManager(value: Nullable<MorphTargetManager>);
  24125. /** @hidden */
  24126. _creationDataStorage: Nullable<_CreationDataStorage>;
  24127. /** @hidden */
  24128. _geometry: Nullable<Geometry>;
  24129. /** @hidden */
  24130. _delayInfo: Array<string>;
  24131. /** @hidden */
  24132. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24133. /** @hidden */
  24134. _instanceDataStorage: _InstanceDataStorage;
  24135. private _effectiveMaterial;
  24136. /** @hidden */
  24137. _shouldGenerateFlatShading: boolean;
  24138. /** @hidden */
  24139. _originalBuilderSideOrientation: number;
  24140. /**
  24141. * Use this property to change the original side orientation defined at construction time
  24142. */
  24143. overrideMaterialSideOrientation: Nullable<number>;
  24144. /**
  24145. * Gets the source mesh (the one used to clone this one from)
  24146. */
  24147. get source(): Nullable<Mesh>;
  24148. /**
  24149. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24150. */
  24151. get isUnIndexed(): boolean;
  24152. set isUnIndexed(value: boolean);
  24153. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  24154. get worldMatrixInstancedBuffer(): Float32Array;
  24155. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  24156. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  24157. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  24158. /**
  24159. * @constructor
  24160. * @param name The value used by scene.getMeshByName() to do a lookup.
  24161. * @param scene The scene to add this mesh to.
  24162. * @param parent The parent of this mesh, if it has one
  24163. * @param source An optional Mesh from which geometry is shared, cloned.
  24164. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24165. * When false, achieved by calling a clone(), also passing False.
  24166. * This will make creation of children, recursive.
  24167. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24168. */
  24169. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24170. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  24171. doNotInstantiate: boolean;
  24172. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  24173. /**
  24174. * Gets the class name
  24175. * @returns the string "Mesh".
  24176. */
  24177. getClassName(): string;
  24178. /** @hidden */
  24179. get _isMesh(): boolean;
  24180. /**
  24181. * Returns a description of this mesh
  24182. * @param fullDetails define if full details about this mesh must be used
  24183. * @returns a descriptive string representing this mesh
  24184. */
  24185. toString(fullDetails?: boolean): string;
  24186. /** @hidden */
  24187. _unBindEffect(): void;
  24188. /**
  24189. * Gets a boolean indicating if this mesh has LOD
  24190. */
  24191. get hasLODLevels(): boolean;
  24192. /**
  24193. * Gets the list of MeshLODLevel associated with the current mesh
  24194. * @returns an array of MeshLODLevel
  24195. */
  24196. getLODLevels(): MeshLODLevel[];
  24197. private _sortLODLevels;
  24198. /**
  24199. * Add a mesh as LOD level triggered at the given distance.
  24200. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24201. * @param distance The distance from the center of the object to show this level
  24202. * @param mesh The mesh to be added as LOD level (can be null)
  24203. * @return This mesh (for chaining)
  24204. */
  24205. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24206. /**
  24207. * Returns the LOD level mesh at the passed distance or null if not found.
  24208. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24209. * @param distance The distance from the center of the object to show this level
  24210. * @returns a Mesh or `null`
  24211. */
  24212. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24213. /**
  24214. * Remove a mesh from the LOD array
  24215. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24216. * @param mesh defines the mesh to be removed
  24217. * @return This mesh (for chaining)
  24218. */
  24219. removeLODLevel(mesh: Mesh): Mesh;
  24220. /**
  24221. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24222. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24223. * @param camera defines the camera to use to compute distance
  24224. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24225. * @return This mesh (for chaining)
  24226. */
  24227. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24228. /**
  24229. * Gets the mesh internal Geometry object
  24230. */
  24231. get geometry(): Nullable<Geometry>;
  24232. /**
  24233. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24234. * @returns the total number of vertices
  24235. */
  24236. getTotalVertices(): number;
  24237. /**
  24238. * Returns the content of an associated vertex buffer
  24239. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24240. * - VertexBuffer.PositionKind
  24241. * - VertexBuffer.UVKind
  24242. * - VertexBuffer.UV2Kind
  24243. * - VertexBuffer.UV3Kind
  24244. * - VertexBuffer.UV4Kind
  24245. * - VertexBuffer.UV5Kind
  24246. * - VertexBuffer.UV6Kind
  24247. * - VertexBuffer.ColorKind
  24248. * - VertexBuffer.MatricesIndicesKind
  24249. * - VertexBuffer.MatricesIndicesExtraKind
  24250. * - VertexBuffer.MatricesWeightsKind
  24251. * - VertexBuffer.MatricesWeightsExtraKind
  24252. * @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
  24253. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24254. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24255. */
  24256. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24257. /**
  24258. * Returns the mesh VertexBuffer object from the requested `kind`
  24259. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24260. * - VertexBuffer.PositionKind
  24261. * - VertexBuffer.NormalKind
  24262. * - VertexBuffer.UVKind
  24263. * - VertexBuffer.UV2Kind
  24264. * - VertexBuffer.UV3Kind
  24265. * - VertexBuffer.UV4Kind
  24266. * - VertexBuffer.UV5Kind
  24267. * - VertexBuffer.UV6Kind
  24268. * - VertexBuffer.ColorKind
  24269. * - VertexBuffer.MatricesIndicesKind
  24270. * - VertexBuffer.MatricesIndicesExtraKind
  24271. * - VertexBuffer.MatricesWeightsKind
  24272. * - VertexBuffer.MatricesWeightsExtraKind
  24273. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24274. */
  24275. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24276. /**
  24277. * Tests if a specific vertex buffer is associated with this mesh
  24278. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24279. * - VertexBuffer.PositionKind
  24280. * - VertexBuffer.NormalKind
  24281. * - VertexBuffer.UVKind
  24282. * - VertexBuffer.UV2Kind
  24283. * - VertexBuffer.UV3Kind
  24284. * - VertexBuffer.UV4Kind
  24285. * - VertexBuffer.UV5Kind
  24286. * - VertexBuffer.UV6Kind
  24287. * - VertexBuffer.ColorKind
  24288. * - VertexBuffer.MatricesIndicesKind
  24289. * - VertexBuffer.MatricesIndicesExtraKind
  24290. * - VertexBuffer.MatricesWeightsKind
  24291. * - VertexBuffer.MatricesWeightsExtraKind
  24292. * @returns a boolean
  24293. */
  24294. isVerticesDataPresent(kind: string): boolean;
  24295. /**
  24296. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24297. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24298. * - VertexBuffer.PositionKind
  24299. * - VertexBuffer.UVKind
  24300. * - VertexBuffer.UV2Kind
  24301. * - VertexBuffer.UV3Kind
  24302. * - VertexBuffer.UV4Kind
  24303. * - VertexBuffer.UV5Kind
  24304. * - VertexBuffer.UV6Kind
  24305. * - VertexBuffer.ColorKind
  24306. * - VertexBuffer.MatricesIndicesKind
  24307. * - VertexBuffer.MatricesIndicesExtraKind
  24308. * - VertexBuffer.MatricesWeightsKind
  24309. * - VertexBuffer.MatricesWeightsExtraKind
  24310. * @returns a boolean
  24311. */
  24312. isVertexBufferUpdatable(kind: string): boolean;
  24313. /**
  24314. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24315. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24316. * - VertexBuffer.PositionKind
  24317. * - VertexBuffer.NormalKind
  24318. * - VertexBuffer.UVKind
  24319. * - VertexBuffer.UV2Kind
  24320. * - VertexBuffer.UV3Kind
  24321. * - VertexBuffer.UV4Kind
  24322. * - VertexBuffer.UV5Kind
  24323. * - VertexBuffer.UV6Kind
  24324. * - VertexBuffer.ColorKind
  24325. * - VertexBuffer.MatricesIndicesKind
  24326. * - VertexBuffer.MatricesIndicesExtraKind
  24327. * - VertexBuffer.MatricesWeightsKind
  24328. * - VertexBuffer.MatricesWeightsExtraKind
  24329. * @returns an array of strings
  24330. */
  24331. getVerticesDataKinds(): string[];
  24332. /**
  24333. * Returns a positive integer : the total number of indices in this mesh geometry.
  24334. * @returns the numner of indices or zero if the mesh has no geometry.
  24335. */
  24336. getTotalIndices(): number;
  24337. /**
  24338. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24339. * @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.
  24340. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24341. * @returns the indices array or an empty array if the mesh has no geometry
  24342. */
  24343. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24344. get isBlocked(): boolean;
  24345. /**
  24346. * Determine if the current mesh is ready to be rendered
  24347. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24348. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24349. * @returns true if all associated assets are ready (material, textures, shaders)
  24350. */
  24351. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24352. /**
  24353. * 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.
  24354. */
  24355. get areNormalsFrozen(): boolean;
  24356. /**
  24357. * 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.
  24358. * @returns the current mesh
  24359. */
  24360. freezeNormals(): Mesh;
  24361. /**
  24362. * 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
  24363. * @returns the current mesh
  24364. */
  24365. unfreezeNormals(): Mesh;
  24366. /**
  24367. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24368. */
  24369. set overridenInstanceCount(count: number);
  24370. /** @hidden */
  24371. _preActivate(): Mesh;
  24372. /** @hidden */
  24373. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24374. /** @hidden */
  24375. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24376. /**
  24377. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24378. * This means the mesh underlying bounding box and sphere are recomputed.
  24379. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24380. * @returns the current mesh
  24381. */
  24382. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24383. /** @hidden */
  24384. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24385. /**
  24386. * This function will subdivide the mesh into multiple submeshes
  24387. * @param count defines the expected number of submeshes
  24388. */
  24389. subdivide(count: number): void;
  24390. /**
  24391. * Copy a FloatArray into a specific associated vertex buffer
  24392. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24393. * - VertexBuffer.PositionKind
  24394. * - VertexBuffer.UVKind
  24395. * - VertexBuffer.UV2Kind
  24396. * - VertexBuffer.UV3Kind
  24397. * - VertexBuffer.UV4Kind
  24398. * - VertexBuffer.UV5Kind
  24399. * - VertexBuffer.UV6Kind
  24400. * - VertexBuffer.ColorKind
  24401. * - VertexBuffer.MatricesIndicesKind
  24402. * - VertexBuffer.MatricesIndicesExtraKind
  24403. * - VertexBuffer.MatricesWeightsKind
  24404. * - VertexBuffer.MatricesWeightsExtraKind
  24405. * @param data defines the data source
  24406. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24407. * @param stride defines the data stride size (can be null)
  24408. * @returns the current mesh
  24409. */
  24410. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24411. /**
  24412. * Delete a vertex buffer associated with this mesh
  24413. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  24414. * - VertexBuffer.PositionKind
  24415. * - VertexBuffer.UVKind
  24416. * - VertexBuffer.UV2Kind
  24417. * - VertexBuffer.UV3Kind
  24418. * - VertexBuffer.UV4Kind
  24419. * - VertexBuffer.UV5Kind
  24420. * - VertexBuffer.UV6Kind
  24421. * - VertexBuffer.ColorKind
  24422. * - VertexBuffer.MatricesIndicesKind
  24423. * - VertexBuffer.MatricesIndicesExtraKind
  24424. * - VertexBuffer.MatricesWeightsKind
  24425. * - VertexBuffer.MatricesWeightsExtraKind
  24426. */
  24427. removeVerticesData(kind: string): void;
  24428. /**
  24429. * Flags an associated vertex buffer as updatable
  24430. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24431. * - VertexBuffer.PositionKind
  24432. * - VertexBuffer.UVKind
  24433. * - VertexBuffer.UV2Kind
  24434. * - VertexBuffer.UV3Kind
  24435. * - VertexBuffer.UV4Kind
  24436. * - VertexBuffer.UV5Kind
  24437. * - VertexBuffer.UV6Kind
  24438. * - VertexBuffer.ColorKind
  24439. * - VertexBuffer.MatricesIndicesKind
  24440. * - VertexBuffer.MatricesIndicesExtraKind
  24441. * - VertexBuffer.MatricesWeightsKind
  24442. * - VertexBuffer.MatricesWeightsExtraKind
  24443. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24444. */
  24445. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24446. /**
  24447. * Sets the mesh global Vertex Buffer
  24448. * @param buffer defines the buffer to use
  24449. * @returns the current mesh
  24450. */
  24451. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24452. /**
  24453. * Update a specific associated vertex buffer
  24454. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24455. * - VertexBuffer.PositionKind
  24456. * - VertexBuffer.UVKind
  24457. * - VertexBuffer.UV2Kind
  24458. * - VertexBuffer.UV3Kind
  24459. * - VertexBuffer.UV4Kind
  24460. * - VertexBuffer.UV5Kind
  24461. * - VertexBuffer.UV6Kind
  24462. * - VertexBuffer.ColorKind
  24463. * - VertexBuffer.MatricesIndicesKind
  24464. * - VertexBuffer.MatricesIndicesExtraKind
  24465. * - VertexBuffer.MatricesWeightsKind
  24466. * - VertexBuffer.MatricesWeightsExtraKind
  24467. * @param data defines the data source
  24468. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24469. * @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)
  24470. * @returns the current mesh
  24471. */
  24472. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24473. /**
  24474. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24475. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24476. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24477. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24478. * @returns the current mesh
  24479. */
  24480. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24481. /**
  24482. * Creates a un-shared specific occurence of the geometry for the mesh.
  24483. * @returns the current mesh
  24484. */
  24485. makeGeometryUnique(): Mesh;
  24486. /**
  24487. * Set the index buffer of this mesh
  24488. * @param indices defines the source data
  24489. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24490. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24491. * @returns the current mesh
  24492. */
  24493. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  24494. /**
  24495. * Update the current index buffer
  24496. * @param indices defines the source data
  24497. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24498. * @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)
  24499. * @returns the current mesh
  24500. */
  24501. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24502. /**
  24503. * Invert the geometry to move from a right handed system to a left handed one.
  24504. * @returns the current mesh
  24505. */
  24506. toLeftHanded(): Mesh;
  24507. /** @hidden */
  24508. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  24509. /** @hidden */
  24510. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  24511. /**
  24512. * Registers for this mesh a javascript function called just before the rendering process
  24513. * @param func defines the function to call before rendering this mesh
  24514. * @returns the current mesh
  24515. */
  24516. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24517. /**
  24518. * Disposes a previously registered javascript function called before the rendering
  24519. * @param func defines the function to remove
  24520. * @returns the current mesh
  24521. */
  24522. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24523. /**
  24524. * Registers for this mesh a javascript function called just after the rendering is complete
  24525. * @param func defines the function to call after rendering this mesh
  24526. * @returns the current mesh
  24527. */
  24528. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24529. /**
  24530. * Disposes a previously registered javascript function called after the rendering.
  24531. * @param func defines the function to remove
  24532. * @returns the current mesh
  24533. */
  24534. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24535. /** @hidden */
  24536. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  24537. /** @hidden */
  24538. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  24539. /** @hidden */
  24540. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  24541. /** @hidden */
  24542. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  24543. /** @hidden */
  24544. _rebuild(): void;
  24545. /** @hidden */
  24546. _freeze(): void;
  24547. /** @hidden */
  24548. _unFreeze(): void;
  24549. /**
  24550. * 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
  24551. * @param subMesh defines the subMesh to render
  24552. * @param enableAlphaMode defines if alpha mode can be changed
  24553. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  24554. * @returns the current mesh
  24555. */
  24556. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  24557. private _onBeforeDraw;
  24558. /**
  24559. * Renormalize the mesh and patch it up if there are no weights
  24560. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  24561. * However in the case of zero weights then we set just a single influence to 1.
  24562. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  24563. */
  24564. cleanMatrixWeights(): void;
  24565. private normalizeSkinFourWeights;
  24566. private normalizeSkinWeightsAndExtra;
  24567. /**
  24568. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  24569. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  24570. * the user know there was an issue with importing the mesh
  24571. * @returns a validation object with skinned, valid and report string
  24572. */
  24573. validateSkinning(): {
  24574. skinned: boolean;
  24575. valid: boolean;
  24576. report: string;
  24577. };
  24578. /** @hidden */
  24579. _checkDelayState(): Mesh;
  24580. private _queueLoad;
  24581. /**
  24582. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24583. * A mesh is in the frustum if its bounding box intersects the frustum
  24584. * @param frustumPlanes defines the frustum to test
  24585. * @returns true if the mesh is in the frustum planes
  24586. */
  24587. isInFrustum(frustumPlanes: Plane[]): boolean;
  24588. /**
  24589. * Sets the mesh material by the material or multiMaterial `id` property
  24590. * @param id is a string identifying the material or the multiMaterial
  24591. * @returns the current mesh
  24592. */
  24593. setMaterialByID(id: string): Mesh;
  24594. /**
  24595. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  24596. * @returns an array of IAnimatable
  24597. */
  24598. getAnimatables(): IAnimatable[];
  24599. /**
  24600. * Modifies the mesh geometry according to the passed transformation matrix.
  24601. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  24602. * The mesh normals are modified using the same transformation.
  24603. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24604. * @param transform defines the transform matrix to use
  24605. * @see http://doc.babylonjs.com/resources/baking_transformations
  24606. * @returns the current mesh
  24607. */
  24608. bakeTransformIntoVertices(transform: Matrix): Mesh;
  24609. /**
  24610. * Modifies the mesh geometry according to its own current World Matrix.
  24611. * The mesh World Matrix is then reset.
  24612. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  24613. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24614. * @see http://doc.babylonjs.com/resources/baking_transformations
  24615. * @returns the current mesh
  24616. */
  24617. bakeCurrentTransformIntoVertices(): Mesh;
  24618. /** @hidden */
  24619. get _positions(): Nullable<Vector3[]>;
  24620. /** @hidden */
  24621. _resetPointsArrayCache(): Mesh;
  24622. /** @hidden */
  24623. _generatePointsArray(): boolean;
  24624. /**
  24625. * Returns a new Mesh object generated from the current mesh properties.
  24626. * This method must not get confused with createInstance()
  24627. * @param name is a string, the name given to the new mesh
  24628. * @param newParent can be any Node object (default `null`)
  24629. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  24630. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  24631. * @returns a new mesh
  24632. */
  24633. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  24634. /**
  24635. * Releases resources associated with this mesh.
  24636. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24637. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24638. */
  24639. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24640. /** @hidden */
  24641. _disposeInstanceSpecificData(): void;
  24642. /**
  24643. * Modifies the mesh geometry according to a displacement map.
  24644. * 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.
  24645. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24646. * @param url is a string, the URL from the image file is to be downloaded.
  24647. * @param minHeight is the lower limit of the displacement.
  24648. * @param maxHeight is the upper limit of the displacement.
  24649. * @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.
  24650. * @param uvOffset is an optional vector2 used to offset UV.
  24651. * @param uvScale is an optional vector2 used to scale UV.
  24652. * @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.
  24653. * @returns the Mesh.
  24654. */
  24655. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24656. /**
  24657. * Modifies the mesh geometry according to a displacementMap buffer.
  24658. * 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.
  24659. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24660. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  24661. * @param heightMapWidth is the width of the buffer image.
  24662. * @param heightMapHeight is the height of the buffer image.
  24663. * @param minHeight is the lower limit of the displacement.
  24664. * @param maxHeight is the upper limit of the displacement.
  24665. * @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.
  24666. * @param uvOffset is an optional vector2 used to offset UV.
  24667. * @param uvScale is an optional vector2 used to scale UV.
  24668. * @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.
  24669. * @returns the Mesh.
  24670. */
  24671. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24672. /**
  24673. * Modify the mesh to get a flat shading rendering.
  24674. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  24675. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  24676. * @returns current mesh
  24677. */
  24678. convertToFlatShadedMesh(): Mesh;
  24679. /**
  24680. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  24681. * In other words, more vertices, no more indices and a single bigger VBO.
  24682. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  24683. * @returns current mesh
  24684. */
  24685. convertToUnIndexedMesh(): Mesh;
  24686. /**
  24687. * Inverses facet orientations.
  24688. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24689. * @param flipNormals will also inverts the normals
  24690. * @returns current mesh
  24691. */
  24692. flipFaces(flipNormals?: boolean): Mesh;
  24693. /**
  24694. * Increase the number of facets and hence vertices in a mesh
  24695. * Vertex normals are interpolated from existing vertex normals
  24696. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24697. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  24698. */
  24699. increaseVertices(numberPerEdge: number): void;
  24700. /**
  24701. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  24702. * This will undo any application of covertToFlatShadedMesh
  24703. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24704. */
  24705. forceSharedVertices(): void;
  24706. /** @hidden */
  24707. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  24708. /** @hidden */
  24709. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  24710. /**
  24711. * Creates a new InstancedMesh object from the mesh model.
  24712. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24713. * @param name defines the name of the new instance
  24714. * @returns a new InstancedMesh
  24715. */
  24716. createInstance(name: string): InstancedMesh;
  24717. /**
  24718. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  24719. * After this call, all the mesh instances have the same submeshes than the current mesh.
  24720. * @returns the current mesh
  24721. */
  24722. synchronizeInstances(): Mesh;
  24723. /**
  24724. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  24725. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  24726. * This should be used together with the simplification to avoid disappearing triangles.
  24727. * @param successCallback an optional success callback to be called after the optimization finished.
  24728. * @returns the current mesh
  24729. */
  24730. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  24731. /**
  24732. * Serialize current mesh
  24733. * @param serializationObject defines the object which will receive the serialization data
  24734. */
  24735. serialize(serializationObject: any): void;
  24736. /** @hidden */
  24737. _syncGeometryWithMorphTargetManager(): void;
  24738. /** @hidden */
  24739. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  24740. /**
  24741. * Returns a new Mesh object parsed from the source provided.
  24742. * @param parsedMesh is the source
  24743. * @param scene defines the hosting scene
  24744. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  24745. * @returns a new Mesh
  24746. */
  24747. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  24748. /**
  24749. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  24750. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24751. * @param name defines the name of the mesh to create
  24752. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  24753. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  24754. * @param closePath creates a seam between the first and the last points of each path of the path array
  24755. * @param offset is taken in account only if the `pathArray` is containing a single path
  24756. * @param scene defines the hosting scene
  24757. * @param updatable defines if the mesh must be flagged as updatable
  24758. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24759. * @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)
  24760. * @returns a new Mesh
  24761. */
  24762. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24763. /**
  24764. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  24765. * @param name defines the name of the mesh to create
  24766. * @param radius sets the radius size (float) of the polygon (default 0.5)
  24767. * @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
  24768. * @param scene defines the hosting scene
  24769. * @param updatable defines if the mesh must be flagged as updatable
  24770. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24771. * @returns a new Mesh
  24772. */
  24773. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24774. /**
  24775. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  24776. * @param name defines the name of the mesh to create
  24777. * @param size sets the size (float) of each box side (default 1)
  24778. * @param scene defines the hosting scene
  24779. * @param updatable defines if the mesh must be flagged as updatable
  24780. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24781. * @returns a new Mesh
  24782. */
  24783. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24784. /**
  24785. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  24786. * @param name defines the name of the mesh to create
  24787. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24788. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24789. * @param scene defines the hosting scene
  24790. * @param updatable defines if the mesh must be flagged as updatable
  24791. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24792. * @returns a new Mesh
  24793. */
  24794. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24795. /**
  24796. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  24797. * @param name defines the name of the mesh to create
  24798. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24799. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24800. * @param scene defines the hosting scene
  24801. * @returns a new Mesh
  24802. */
  24803. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  24804. /**
  24805. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  24806. * @param name defines the name of the mesh to create
  24807. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  24808. * @param diameterTop set the top cap diameter (floats, default 1)
  24809. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  24810. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  24811. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  24812. * @param scene defines the hosting scene
  24813. * @param updatable defines if the mesh must be flagged as updatable
  24814. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24815. * @returns a new Mesh
  24816. */
  24817. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  24818. /**
  24819. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  24820. * @param name defines the name of the mesh to create
  24821. * @param diameter sets the diameter size (float) of the torus (default 1)
  24822. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  24823. * @param tessellation sets the number of torus sides (postive integer, default 16)
  24824. * @param scene defines the hosting scene
  24825. * @param updatable defines if the mesh must be flagged as updatable
  24826. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24827. * @returns a new Mesh
  24828. */
  24829. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24830. /**
  24831. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  24832. * @param name defines the name of the mesh to create
  24833. * @param radius sets the global radius size (float) of the torus knot (default 2)
  24834. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  24835. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  24836. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  24837. * @param p the number of windings on X axis (positive integers, default 2)
  24838. * @param q the number of windings on Y axis (positive integers, default 3)
  24839. * @param scene defines the hosting scene
  24840. * @param updatable defines if the mesh must be flagged as updatable
  24841. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24842. * @returns a new Mesh
  24843. */
  24844. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24845. /**
  24846. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  24847. * @param name defines the name of the mesh to create
  24848. * @param points is an array successive Vector3
  24849. * @param scene defines the hosting scene
  24850. * @param updatable defines if the mesh must be flagged as updatable
  24851. * @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).
  24852. * @returns a new Mesh
  24853. */
  24854. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  24855. /**
  24856. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  24857. * @param name defines the name of the mesh to create
  24858. * @param points is an array successive Vector3
  24859. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  24860. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  24861. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  24862. * @param scene defines the hosting scene
  24863. * @param updatable defines if the mesh must be flagged as updatable
  24864. * @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)
  24865. * @returns a new Mesh
  24866. */
  24867. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  24868. /**
  24869. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  24870. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  24871. * 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.
  24872. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24873. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  24874. * Remember you can only change the shape positions, not their number when updating a polygon.
  24875. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  24876. * @param name defines the name of the mesh to create
  24877. * @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
  24878. * @param scene defines the hosting scene
  24879. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24880. * @param updatable defines if the mesh must be flagged as updatable
  24881. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24882. * @param earcutInjection can be used to inject your own earcut reference
  24883. * @returns a new Mesh
  24884. */
  24885. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24886. /**
  24887. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  24888. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  24889. * @param name defines the name of the mesh to create
  24890. * @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
  24891. * @param depth defines the height of extrusion
  24892. * @param scene defines the hosting scene
  24893. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24894. * @param updatable defines if the mesh must be flagged as updatable
  24895. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24896. * @param earcutInjection can be used to inject your own earcut reference
  24897. * @returns a new Mesh
  24898. */
  24899. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24900. /**
  24901. * Creates an extruded shape mesh.
  24902. * 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
  24903. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24904. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24905. * @param name defines the name of the mesh to create
  24906. * @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
  24907. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24908. * @param scale is the value to scale the shape
  24909. * @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
  24910. * @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
  24911. * @param scene defines the hosting scene
  24912. * @param updatable defines if the mesh must be flagged as updatable
  24913. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24914. * @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)
  24915. * @returns a new Mesh
  24916. */
  24917. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24918. /**
  24919. * Creates an custom extruded shape mesh.
  24920. * The custom extrusion is a parametric shape.
  24921. * It has no predefined shape. Its final shape will depend on the input parameters.
  24922. * Please consider using the same method from the MeshBuilder class instead
  24923. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24924. * @param name defines the name of the mesh to create
  24925. * @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
  24926. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24927. * @param scaleFunction is a custom Javascript function called on each path point
  24928. * @param rotationFunction is a custom Javascript function called on each path point
  24929. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  24930. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  24931. * @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
  24932. * @param scene defines the hosting scene
  24933. * @param updatable defines if the mesh must be flagged as updatable
  24934. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24935. * @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)
  24936. * @returns a new Mesh
  24937. */
  24938. 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;
  24939. /**
  24940. * Creates lathe mesh.
  24941. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  24942. * Please consider using the same method from the MeshBuilder class instead
  24943. * @param name defines the name of the mesh to create
  24944. * @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
  24945. * @param radius is the radius value of the lathe
  24946. * @param tessellation is the side number of the lathe.
  24947. * @param scene defines the hosting scene
  24948. * @param updatable defines if the mesh must be flagged as updatable
  24949. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24950. * @returns a new Mesh
  24951. */
  24952. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24953. /**
  24954. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  24955. * @param name defines the name of the mesh to create
  24956. * @param size sets the size (float) of both sides of the plane at once (default 1)
  24957. * @param scene defines the hosting scene
  24958. * @param updatable defines if the mesh must be flagged as updatable
  24959. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24960. * @returns a new Mesh
  24961. */
  24962. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24963. /**
  24964. * Creates a ground mesh.
  24965. * Please consider using the same method from the MeshBuilder class instead
  24966. * @param name defines the name of the mesh to create
  24967. * @param width set the width of the ground
  24968. * @param height set the height of the ground
  24969. * @param subdivisions sets the number of subdivisions per side
  24970. * @param scene defines the hosting scene
  24971. * @param updatable defines if the mesh must be flagged as updatable
  24972. * @returns a new Mesh
  24973. */
  24974. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  24975. /**
  24976. * Creates a tiled ground mesh.
  24977. * Please consider using the same method from the MeshBuilder class instead
  24978. * @param name defines the name of the mesh to create
  24979. * @param xmin set the ground minimum X coordinate
  24980. * @param zmin set the ground minimum Y coordinate
  24981. * @param xmax set the ground maximum X coordinate
  24982. * @param zmax set the ground maximum Z coordinate
  24983. * @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
  24984. * @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
  24985. * @param scene defines the hosting scene
  24986. * @param updatable defines if the mesh must be flagged as updatable
  24987. * @returns a new Mesh
  24988. */
  24989. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  24990. w: number;
  24991. h: number;
  24992. }, precision: {
  24993. w: number;
  24994. h: number;
  24995. }, scene: Scene, updatable?: boolean): Mesh;
  24996. /**
  24997. * Creates a ground mesh from a height map.
  24998. * Please consider using the same method from the MeshBuilder class instead
  24999. * @see http://doc.babylonjs.com/babylon101/height_map
  25000. * @param name defines the name of the mesh to create
  25001. * @param url sets the URL of the height map image resource
  25002. * @param width set the ground width size
  25003. * @param height set the ground height size
  25004. * @param subdivisions sets the number of subdivision per side
  25005. * @param minHeight is the minimum altitude on the ground
  25006. * @param maxHeight is the maximum altitude on the ground
  25007. * @param scene defines the hosting scene
  25008. * @param updatable defines if the mesh must be flagged as updatable
  25009. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25010. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25011. * @returns a new Mesh
  25012. */
  25013. 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;
  25014. /**
  25015. * Creates a tube mesh.
  25016. * The tube is a parametric shape.
  25017. * It has no predefined shape. Its final shape will depend on the input parameters.
  25018. * Please consider using the same method from the MeshBuilder class instead
  25019. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25020. * @param name defines the name of the mesh to create
  25021. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25022. * @param radius sets the tube radius size
  25023. * @param tessellation is the number of sides on the tubular surface
  25024. * @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
  25025. * @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
  25026. * @param scene defines the hosting scene
  25027. * @param updatable defines if the mesh must be flagged as updatable
  25028. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25029. * @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)
  25030. * @returns a new Mesh
  25031. */
  25032. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25033. (i: number, distance: number): number;
  25034. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25035. /**
  25036. * Creates a polyhedron mesh.
  25037. * Please consider using the same method from the MeshBuilder class instead.
  25038. * * 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
  25039. * * The parameter `size` (positive float, default 1) sets the polygon size
  25040. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25041. * * 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`
  25042. * * 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
  25043. * * 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)`)
  25044. * * 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
  25045. * * 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
  25046. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25047. * * 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
  25048. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25049. * @param name defines the name of the mesh to create
  25050. * @param options defines the options used to create the mesh
  25051. * @param scene defines the hosting scene
  25052. * @returns a new Mesh
  25053. */
  25054. static CreatePolyhedron(name: string, options: {
  25055. type?: number;
  25056. size?: number;
  25057. sizeX?: number;
  25058. sizeY?: number;
  25059. sizeZ?: number;
  25060. custom?: any;
  25061. faceUV?: Vector4[];
  25062. faceColors?: Color4[];
  25063. updatable?: boolean;
  25064. sideOrientation?: number;
  25065. }, scene: Scene): Mesh;
  25066. /**
  25067. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25068. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25069. * * 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`)
  25070. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25071. * * 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
  25072. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25073. * * 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
  25074. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25075. * @param name defines the name of the mesh
  25076. * @param options defines the options used to create the mesh
  25077. * @param scene defines the hosting scene
  25078. * @returns a new Mesh
  25079. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25080. */
  25081. static CreateIcoSphere(name: string, options: {
  25082. radius?: number;
  25083. flat?: boolean;
  25084. subdivisions?: number;
  25085. sideOrientation?: number;
  25086. updatable?: boolean;
  25087. }, scene: Scene): Mesh;
  25088. /**
  25089. * Creates a decal mesh.
  25090. * Please consider using the same method from the MeshBuilder class instead.
  25091. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25092. * @param name defines the name of the mesh
  25093. * @param sourceMesh defines the mesh receiving the decal
  25094. * @param position sets the position of the decal in world coordinates
  25095. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25096. * @param size sets the decal scaling
  25097. * @param angle sets the angle to rotate the decal
  25098. * @returns a new Mesh
  25099. */
  25100. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25101. /**
  25102. * Prepare internal position array for software CPU skinning
  25103. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25104. */
  25105. setPositionsForCPUSkinning(): Float32Array;
  25106. /**
  25107. * Prepare internal normal array for software CPU skinning
  25108. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25109. */
  25110. setNormalsForCPUSkinning(): Float32Array;
  25111. /**
  25112. * Updates the vertex buffer by applying transformation from the bones
  25113. * @param skeleton defines the skeleton to apply to current mesh
  25114. * @returns the current mesh
  25115. */
  25116. applySkeleton(skeleton: Skeleton): Mesh;
  25117. /**
  25118. * 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
  25119. * @param meshes defines the list of meshes to scan
  25120. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25121. */
  25122. static MinMax(meshes: AbstractMesh[]): {
  25123. min: Vector3;
  25124. max: Vector3;
  25125. };
  25126. /**
  25127. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25128. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25129. * @returns a vector3
  25130. */
  25131. static Center(meshesOrMinMaxVector: {
  25132. min: Vector3;
  25133. max: Vector3;
  25134. } | AbstractMesh[]): Vector3;
  25135. /**
  25136. * Merge the array of meshes into a single mesh for performance reasons.
  25137. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25138. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25139. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25140. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25141. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25142. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25143. * @returns a new mesh
  25144. */
  25145. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25146. /** @hidden */
  25147. addInstance(instance: InstancedMesh): void;
  25148. /** @hidden */
  25149. removeInstance(instance: InstancedMesh): void;
  25150. }
  25151. }
  25152. declare module BABYLON {
  25153. /**
  25154. * This is the base class of all the camera used in the application.
  25155. * @see http://doc.babylonjs.com/features/cameras
  25156. */
  25157. export class Camera extends Node {
  25158. /** @hidden */
  25159. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25160. /**
  25161. * This is the default projection mode used by the cameras.
  25162. * It helps recreating a feeling of perspective and better appreciate depth.
  25163. * This is the best way to simulate real life cameras.
  25164. */
  25165. static readonly PERSPECTIVE_CAMERA: number;
  25166. /**
  25167. * This helps creating camera with an orthographic mode.
  25168. * 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.
  25169. */
  25170. static readonly ORTHOGRAPHIC_CAMERA: number;
  25171. /**
  25172. * This is the default FOV mode for perspective cameras.
  25173. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25174. */
  25175. static readonly FOVMODE_VERTICAL_FIXED: number;
  25176. /**
  25177. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25178. */
  25179. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25180. /**
  25181. * This specifies ther is no need for a camera rig.
  25182. * Basically only one eye is rendered corresponding to the camera.
  25183. */
  25184. static readonly RIG_MODE_NONE: number;
  25185. /**
  25186. * Simulates a camera Rig with one blue eye and one red eye.
  25187. * This can be use with 3d blue and red glasses.
  25188. */
  25189. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25190. /**
  25191. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25192. */
  25193. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25194. /**
  25195. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25196. */
  25197. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25198. /**
  25199. * Defines that both eyes of the camera will be rendered over under each other.
  25200. */
  25201. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25202. /**
  25203. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25204. */
  25205. static readonly RIG_MODE_VR: number;
  25206. /**
  25207. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25208. */
  25209. static readonly RIG_MODE_WEBVR: number;
  25210. /**
  25211. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25212. */
  25213. static readonly RIG_MODE_CUSTOM: number;
  25214. /**
  25215. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25216. */
  25217. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25218. /**
  25219. * Define the input manager associated with the camera.
  25220. */
  25221. inputs: CameraInputsManager<Camera>;
  25222. /** @hidden */
  25223. _position: Vector3;
  25224. /**
  25225. * Define the current local position of the camera in the scene
  25226. */
  25227. get position(): Vector3;
  25228. set position(newPosition: Vector3);
  25229. /**
  25230. * The vector the camera should consider as up.
  25231. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25232. */
  25233. upVector: Vector3;
  25234. /**
  25235. * Define the current limit on the left side for an orthographic camera
  25236. * In scene unit
  25237. */
  25238. orthoLeft: Nullable<number>;
  25239. /**
  25240. * Define the current limit on the right side for an orthographic camera
  25241. * In scene unit
  25242. */
  25243. orthoRight: Nullable<number>;
  25244. /**
  25245. * Define the current limit on the bottom side for an orthographic camera
  25246. * In scene unit
  25247. */
  25248. orthoBottom: Nullable<number>;
  25249. /**
  25250. * Define the current limit on the top side for an orthographic camera
  25251. * In scene unit
  25252. */
  25253. orthoTop: Nullable<number>;
  25254. /**
  25255. * Field Of View is set in Radians. (default is 0.8)
  25256. */
  25257. fov: number;
  25258. /**
  25259. * Define the minimum distance the camera can see from.
  25260. * This is important to note that the depth buffer are not infinite and the closer it starts
  25261. * the more your scene might encounter depth fighting issue.
  25262. */
  25263. minZ: number;
  25264. /**
  25265. * Define the maximum distance the camera can see to.
  25266. * This is important to note that the depth buffer are not infinite and the further it end
  25267. * the more your scene might encounter depth fighting issue.
  25268. */
  25269. maxZ: number;
  25270. /**
  25271. * Define the default inertia of the camera.
  25272. * This helps giving a smooth feeling to the camera movement.
  25273. */
  25274. inertia: number;
  25275. /**
  25276. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25277. */
  25278. mode: number;
  25279. /**
  25280. * Define wether the camera is intermediate.
  25281. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25282. */
  25283. isIntermediate: boolean;
  25284. /**
  25285. * Define the viewport of the camera.
  25286. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25287. */
  25288. viewport: Viewport;
  25289. /**
  25290. * Restricts the camera to viewing objects with the same layerMask.
  25291. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25292. */
  25293. layerMask: number;
  25294. /**
  25295. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25296. */
  25297. fovMode: number;
  25298. /**
  25299. * Rig mode of the camera.
  25300. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25301. * This is normally controlled byt the camera themselves as internal use.
  25302. */
  25303. cameraRigMode: number;
  25304. /**
  25305. * Defines the distance between both "eyes" in case of a RIG
  25306. */
  25307. interaxialDistance: number;
  25308. /**
  25309. * Defines if stereoscopic rendering is done side by side or over under.
  25310. */
  25311. isStereoscopicSideBySide: boolean;
  25312. /**
  25313. * 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
  25314. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25315. * else in the scene. (Eg. security camera)
  25316. *
  25317. * 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)
  25318. */
  25319. customRenderTargets: RenderTargetTexture[];
  25320. /**
  25321. * When set, the camera will render to this render target instead of the default canvas
  25322. *
  25323. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25324. */
  25325. outputRenderTarget: Nullable<RenderTargetTexture>;
  25326. /**
  25327. * Observable triggered when the camera view matrix has changed.
  25328. */
  25329. onViewMatrixChangedObservable: Observable<Camera>;
  25330. /**
  25331. * Observable triggered when the camera Projection matrix has changed.
  25332. */
  25333. onProjectionMatrixChangedObservable: Observable<Camera>;
  25334. /**
  25335. * Observable triggered when the inputs have been processed.
  25336. */
  25337. onAfterCheckInputsObservable: Observable<Camera>;
  25338. /**
  25339. * Observable triggered when reset has been called and applied to the camera.
  25340. */
  25341. onRestoreStateObservable: Observable<Camera>;
  25342. /** @hidden */
  25343. _cameraRigParams: any;
  25344. /** @hidden */
  25345. _rigCameras: Camera[];
  25346. /** @hidden */
  25347. _rigPostProcess: Nullable<PostProcess>;
  25348. protected _webvrViewMatrix: Matrix;
  25349. /** @hidden */
  25350. _skipRendering: boolean;
  25351. /** @hidden */
  25352. _projectionMatrix: Matrix;
  25353. /** @hidden */
  25354. _postProcesses: Nullable<PostProcess>[];
  25355. /** @hidden */
  25356. _activeMeshes: SmartArray<AbstractMesh>;
  25357. protected _globalPosition: Vector3;
  25358. /** @hidden */
  25359. _computedViewMatrix: Matrix;
  25360. private _doNotComputeProjectionMatrix;
  25361. private _transformMatrix;
  25362. private _frustumPlanes;
  25363. private _refreshFrustumPlanes;
  25364. private _storedFov;
  25365. private _stateStored;
  25366. /**
  25367. * Instantiates a new camera object.
  25368. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25369. * @see http://doc.babylonjs.com/features/cameras
  25370. * @param name Defines the name of the camera in the scene
  25371. * @param position Defines the position of the camera
  25372. * @param scene Defines the scene the camera belongs too
  25373. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25374. */
  25375. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25376. /**
  25377. * Store current camera state (fov, position, etc..)
  25378. * @returns the camera
  25379. */
  25380. storeState(): Camera;
  25381. /**
  25382. * Restores the camera state values if it has been stored. You must call storeState() first
  25383. */
  25384. protected _restoreStateValues(): boolean;
  25385. /**
  25386. * Restored camera state. You must call storeState() first.
  25387. * @returns true if restored and false otherwise
  25388. */
  25389. restoreState(): boolean;
  25390. /**
  25391. * Gets the class name of the camera.
  25392. * @returns the class name
  25393. */
  25394. getClassName(): string;
  25395. /** @hidden */
  25396. readonly _isCamera: boolean;
  25397. /**
  25398. * Gets a string representation of the camera useful for debug purpose.
  25399. * @param fullDetails Defines that a more verboe level of logging is required
  25400. * @returns the string representation
  25401. */
  25402. toString(fullDetails?: boolean): string;
  25403. /**
  25404. * Gets the current world space position of the camera.
  25405. */
  25406. get globalPosition(): Vector3;
  25407. /**
  25408. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25409. * @returns the active meshe list
  25410. */
  25411. getActiveMeshes(): SmartArray<AbstractMesh>;
  25412. /**
  25413. * Check wether a mesh is part of the current active mesh list of the camera
  25414. * @param mesh Defines the mesh to check
  25415. * @returns true if active, false otherwise
  25416. */
  25417. isActiveMesh(mesh: Mesh): boolean;
  25418. /**
  25419. * Is this camera ready to be used/rendered
  25420. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25421. * @return true if the camera is ready
  25422. */
  25423. isReady(completeCheck?: boolean): boolean;
  25424. /** @hidden */
  25425. _initCache(): void;
  25426. /** @hidden */
  25427. _updateCache(ignoreParentClass?: boolean): void;
  25428. /** @hidden */
  25429. _isSynchronized(): boolean;
  25430. /** @hidden */
  25431. _isSynchronizedViewMatrix(): boolean;
  25432. /** @hidden */
  25433. _isSynchronizedProjectionMatrix(): boolean;
  25434. /**
  25435. * Attach the input controls to a specific dom element to get the input from.
  25436. * @param element Defines the element the controls should be listened from
  25437. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25438. */
  25439. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25440. /**
  25441. * Detach the current controls from the specified dom element.
  25442. * @param element Defines the element to stop listening the inputs from
  25443. */
  25444. detachControl(element: HTMLElement): void;
  25445. /**
  25446. * Update the camera state according to the different inputs gathered during the frame.
  25447. */
  25448. update(): void;
  25449. /** @hidden */
  25450. _checkInputs(): void;
  25451. /** @hidden */
  25452. get rigCameras(): Camera[];
  25453. /**
  25454. * Gets the post process used by the rig cameras
  25455. */
  25456. get rigPostProcess(): Nullable<PostProcess>;
  25457. /**
  25458. * Internal, gets the first post proces.
  25459. * @returns the first post process to be run on this camera.
  25460. */
  25461. _getFirstPostProcess(): Nullable<PostProcess>;
  25462. private _cascadePostProcessesToRigCams;
  25463. /**
  25464. * Attach a post process to the camera.
  25465. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25466. * @param postProcess The post process to attach to the camera
  25467. * @param insertAt The position of the post process in case several of them are in use in the scene
  25468. * @returns the position the post process has been inserted at
  25469. */
  25470. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25471. /**
  25472. * Detach a post process to the camera.
  25473. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25474. * @param postProcess The post process to detach from the camera
  25475. */
  25476. detachPostProcess(postProcess: PostProcess): void;
  25477. /**
  25478. * Gets the current world matrix of the camera
  25479. */
  25480. getWorldMatrix(): Matrix;
  25481. /** @hidden */
  25482. _getViewMatrix(): Matrix;
  25483. /**
  25484. * Gets the current view matrix of the camera.
  25485. * @param force forces the camera to recompute the matrix without looking at the cached state
  25486. * @returns the view matrix
  25487. */
  25488. getViewMatrix(force?: boolean): Matrix;
  25489. /**
  25490. * Freeze the projection matrix.
  25491. * It will prevent the cache check of the camera projection compute and can speed up perf
  25492. * if no parameter of the camera are meant to change
  25493. * @param projection Defines manually a projection if necessary
  25494. */
  25495. freezeProjectionMatrix(projection?: Matrix): void;
  25496. /**
  25497. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  25498. */
  25499. unfreezeProjectionMatrix(): void;
  25500. /**
  25501. * Gets the current projection matrix of the camera.
  25502. * @param force forces the camera to recompute the matrix without looking at the cached state
  25503. * @returns the projection matrix
  25504. */
  25505. getProjectionMatrix(force?: boolean): Matrix;
  25506. /**
  25507. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  25508. * @returns a Matrix
  25509. */
  25510. getTransformationMatrix(): Matrix;
  25511. private _updateFrustumPlanes;
  25512. /**
  25513. * Checks if a cullable object (mesh...) is in the camera frustum
  25514. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  25515. * @param target The object to check
  25516. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  25517. * @returns true if the object is in frustum otherwise false
  25518. */
  25519. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  25520. /**
  25521. * Checks if a cullable object (mesh...) is in the camera frustum
  25522. * Unlike isInFrustum this cheks the full bounding box
  25523. * @param target The object to check
  25524. * @returns true if the object is in frustum otherwise false
  25525. */
  25526. isCompletelyInFrustum(target: ICullable): boolean;
  25527. /**
  25528. * Gets a ray in the forward direction from the camera.
  25529. * @param length Defines the length of the ray to create
  25530. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  25531. * @param origin Defines the start point of the ray which defaults to the camera position
  25532. * @returns the forward ray
  25533. */
  25534. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  25535. /**
  25536. * Releases resources associated with this node.
  25537. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25538. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25539. */
  25540. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25541. /** @hidden */
  25542. _isLeftCamera: boolean;
  25543. /**
  25544. * Gets the left camera of a rig setup in case of Rigged Camera
  25545. */
  25546. get isLeftCamera(): boolean;
  25547. /** @hidden */
  25548. _isRightCamera: boolean;
  25549. /**
  25550. * Gets the right camera of a rig setup in case of Rigged Camera
  25551. */
  25552. get isRightCamera(): boolean;
  25553. /**
  25554. * Gets the left camera of a rig setup in case of Rigged Camera
  25555. */
  25556. get leftCamera(): Nullable<FreeCamera>;
  25557. /**
  25558. * Gets the right camera of a rig setup in case of Rigged Camera
  25559. */
  25560. get rightCamera(): Nullable<FreeCamera>;
  25561. /**
  25562. * Gets the left camera target of a rig setup in case of Rigged Camera
  25563. * @returns the target position
  25564. */
  25565. getLeftTarget(): Nullable<Vector3>;
  25566. /**
  25567. * Gets the right camera target of a rig setup in case of Rigged Camera
  25568. * @returns the target position
  25569. */
  25570. getRightTarget(): Nullable<Vector3>;
  25571. /**
  25572. * @hidden
  25573. */
  25574. setCameraRigMode(mode: number, rigParams: any): void;
  25575. /** @hidden */
  25576. static _setStereoscopicRigMode(camera: Camera): void;
  25577. /** @hidden */
  25578. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  25579. /** @hidden */
  25580. static _setVRRigMode(camera: Camera, rigParams: any): void;
  25581. /** @hidden */
  25582. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  25583. /** @hidden */
  25584. _getVRProjectionMatrix(): Matrix;
  25585. protected _updateCameraRotationMatrix(): void;
  25586. protected _updateWebVRCameraRotationMatrix(): void;
  25587. /**
  25588. * This function MUST be overwritten by the different WebVR cameras available.
  25589. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25590. * @hidden
  25591. */
  25592. _getWebVRProjectionMatrix(): Matrix;
  25593. /**
  25594. * This function MUST be overwritten by the different WebVR cameras available.
  25595. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25596. * @hidden
  25597. */
  25598. _getWebVRViewMatrix(): Matrix;
  25599. /** @hidden */
  25600. setCameraRigParameter(name: string, value: any): void;
  25601. /**
  25602. * needs to be overridden by children so sub has required properties to be copied
  25603. * @hidden
  25604. */
  25605. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  25606. /**
  25607. * May need to be overridden by children
  25608. * @hidden
  25609. */
  25610. _updateRigCameras(): void;
  25611. /** @hidden */
  25612. _setupInputs(): void;
  25613. /**
  25614. * Serialiaze the camera setup to a json represention
  25615. * @returns the JSON representation
  25616. */
  25617. serialize(): any;
  25618. /**
  25619. * Clones the current camera.
  25620. * @param name The cloned camera name
  25621. * @returns the cloned camera
  25622. */
  25623. clone(name: string): Camera;
  25624. /**
  25625. * Gets the direction of the camera relative to a given local axis.
  25626. * @param localAxis Defines the reference axis to provide a relative direction.
  25627. * @return the direction
  25628. */
  25629. getDirection(localAxis: Vector3): Vector3;
  25630. /**
  25631. * Returns the current camera absolute rotation
  25632. */
  25633. get absoluteRotation(): Quaternion;
  25634. /**
  25635. * Gets the direction of the camera relative to a given local axis into a passed vector.
  25636. * @param localAxis Defines the reference axis to provide a relative direction.
  25637. * @param result Defines the vector to store the result in
  25638. */
  25639. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  25640. /**
  25641. * Gets a camera constructor for a given camera type
  25642. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  25643. * @param name The name of the camera the result will be able to instantiate
  25644. * @param scene The scene the result will construct the camera in
  25645. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  25646. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  25647. * @returns a factory method to construc the camera
  25648. */
  25649. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  25650. /**
  25651. * Compute the world matrix of the camera.
  25652. * @returns the camera world matrix
  25653. */
  25654. computeWorldMatrix(): Matrix;
  25655. /**
  25656. * Parse a JSON and creates the camera from the parsed information
  25657. * @param parsedCamera The JSON to parse
  25658. * @param scene The scene to instantiate the camera in
  25659. * @returns the newly constructed camera
  25660. */
  25661. static Parse(parsedCamera: any, scene: Scene): Camera;
  25662. }
  25663. }
  25664. declare module BABYLON {
  25665. /**
  25666. * Class containing static functions to help procedurally build meshes
  25667. */
  25668. export class DiscBuilder {
  25669. /**
  25670. * Creates a plane polygonal mesh. By default, this is a disc
  25671. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  25672. * * 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
  25673. * * 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
  25674. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25675. * * 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
  25676. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25677. * @param name defines the name of the mesh
  25678. * @param options defines the options used to create the mesh
  25679. * @param scene defines the hosting scene
  25680. * @returns the plane polygonal mesh
  25681. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25682. */
  25683. static CreateDisc(name: string, options: {
  25684. radius?: number;
  25685. tessellation?: number;
  25686. arc?: number;
  25687. updatable?: boolean;
  25688. sideOrientation?: number;
  25689. frontUVs?: Vector4;
  25690. backUVs?: Vector4;
  25691. }, scene?: Nullable<Scene>): Mesh;
  25692. }
  25693. }
  25694. declare module BABYLON {
  25695. /**
  25696. * This represents all the required information to add a fresnel effect on a material:
  25697. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  25698. */
  25699. export class FresnelParameters {
  25700. private _isEnabled;
  25701. /**
  25702. * Define if the fresnel effect is enable or not.
  25703. */
  25704. get isEnabled(): boolean;
  25705. set isEnabled(value: boolean);
  25706. /**
  25707. * Define the color used on edges (grazing angle)
  25708. */
  25709. leftColor: Color3;
  25710. /**
  25711. * Define the color used on center
  25712. */
  25713. rightColor: Color3;
  25714. /**
  25715. * Define bias applied to computed fresnel term
  25716. */
  25717. bias: number;
  25718. /**
  25719. * Defined the power exponent applied to fresnel term
  25720. */
  25721. power: number;
  25722. /**
  25723. * Clones the current fresnel and its valuues
  25724. * @returns a clone fresnel configuration
  25725. */
  25726. clone(): FresnelParameters;
  25727. /**
  25728. * Serializes the current fresnel parameters to a JSON representation.
  25729. * @return the JSON serialization
  25730. */
  25731. serialize(): any;
  25732. /**
  25733. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  25734. * @param parsedFresnelParameters Define the JSON representation
  25735. * @returns the parsed parameters
  25736. */
  25737. static Parse(parsedFresnelParameters: any): FresnelParameters;
  25738. }
  25739. }
  25740. declare module BABYLON {
  25741. /**
  25742. * Base class of materials working in push mode in babylon JS
  25743. * @hidden
  25744. */
  25745. export class PushMaterial extends Material {
  25746. protected _activeEffect: Effect;
  25747. protected _normalMatrix: Matrix;
  25748. /**
  25749. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  25750. * This means that the material can keep using a previous shader while a new one is being compiled.
  25751. * This is mostly used when shader parallel compilation is supported (true by default)
  25752. */
  25753. allowShaderHotSwapping: boolean;
  25754. constructor(name: string, scene: Scene);
  25755. getEffect(): Effect;
  25756. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  25757. /**
  25758. * Binds the given world matrix to the active effect
  25759. *
  25760. * @param world the matrix to bind
  25761. */
  25762. bindOnlyWorldMatrix(world: Matrix): void;
  25763. /**
  25764. * Binds the given normal matrix to the active effect
  25765. *
  25766. * @param normalMatrix the matrix to bind
  25767. */
  25768. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  25769. bind(world: Matrix, mesh?: Mesh): void;
  25770. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  25771. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  25772. }
  25773. }
  25774. declare module BABYLON {
  25775. /**
  25776. * This groups all the flags used to control the materials channel.
  25777. */
  25778. export class MaterialFlags {
  25779. private static _DiffuseTextureEnabled;
  25780. /**
  25781. * Are diffuse textures enabled in the application.
  25782. */
  25783. static get DiffuseTextureEnabled(): boolean;
  25784. static set DiffuseTextureEnabled(value: boolean);
  25785. private static _AmbientTextureEnabled;
  25786. /**
  25787. * Are ambient textures enabled in the application.
  25788. */
  25789. static get AmbientTextureEnabled(): boolean;
  25790. static set AmbientTextureEnabled(value: boolean);
  25791. private static _OpacityTextureEnabled;
  25792. /**
  25793. * Are opacity textures enabled in the application.
  25794. */
  25795. static get OpacityTextureEnabled(): boolean;
  25796. static set OpacityTextureEnabled(value: boolean);
  25797. private static _ReflectionTextureEnabled;
  25798. /**
  25799. * Are reflection textures enabled in the application.
  25800. */
  25801. static get ReflectionTextureEnabled(): boolean;
  25802. static set ReflectionTextureEnabled(value: boolean);
  25803. private static _EmissiveTextureEnabled;
  25804. /**
  25805. * Are emissive textures enabled in the application.
  25806. */
  25807. static get EmissiveTextureEnabled(): boolean;
  25808. static set EmissiveTextureEnabled(value: boolean);
  25809. private static _SpecularTextureEnabled;
  25810. /**
  25811. * Are specular textures enabled in the application.
  25812. */
  25813. static get SpecularTextureEnabled(): boolean;
  25814. static set SpecularTextureEnabled(value: boolean);
  25815. private static _BumpTextureEnabled;
  25816. /**
  25817. * Are bump textures enabled in the application.
  25818. */
  25819. static get BumpTextureEnabled(): boolean;
  25820. static set BumpTextureEnabled(value: boolean);
  25821. private static _LightmapTextureEnabled;
  25822. /**
  25823. * Are lightmap textures enabled in the application.
  25824. */
  25825. static get LightmapTextureEnabled(): boolean;
  25826. static set LightmapTextureEnabled(value: boolean);
  25827. private static _RefractionTextureEnabled;
  25828. /**
  25829. * Are refraction textures enabled in the application.
  25830. */
  25831. static get RefractionTextureEnabled(): boolean;
  25832. static set RefractionTextureEnabled(value: boolean);
  25833. private static _ColorGradingTextureEnabled;
  25834. /**
  25835. * Are color grading textures enabled in the application.
  25836. */
  25837. static get ColorGradingTextureEnabled(): boolean;
  25838. static set ColorGradingTextureEnabled(value: boolean);
  25839. private static _FresnelEnabled;
  25840. /**
  25841. * Are fresnels enabled in the application.
  25842. */
  25843. static get FresnelEnabled(): boolean;
  25844. static set FresnelEnabled(value: boolean);
  25845. private static _ClearCoatTextureEnabled;
  25846. /**
  25847. * Are clear coat textures enabled in the application.
  25848. */
  25849. static get ClearCoatTextureEnabled(): boolean;
  25850. static set ClearCoatTextureEnabled(value: boolean);
  25851. private static _ClearCoatBumpTextureEnabled;
  25852. /**
  25853. * Are clear coat bump textures enabled in the application.
  25854. */
  25855. static get ClearCoatBumpTextureEnabled(): boolean;
  25856. static set ClearCoatBumpTextureEnabled(value: boolean);
  25857. private static _ClearCoatTintTextureEnabled;
  25858. /**
  25859. * Are clear coat tint textures enabled in the application.
  25860. */
  25861. static get ClearCoatTintTextureEnabled(): boolean;
  25862. static set ClearCoatTintTextureEnabled(value: boolean);
  25863. private static _SheenTextureEnabled;
  25864. /**
  25865. * Are sheen textures enabled in the application.
  25866. */
  25867. static get SheenTextureEnabled(): boolean;
  25868. static set SheenTextureEnabled(value: boolean);
  25869. private static _AnisotropicTextureEnabled;
  25870. /**
  25871. * Are anisotropic textures enabled in the application.
  25872. */
  25873. static get AnisotropicTextureEnabled(): boolean;
  25874. static set AnisotropicTextureEnabled(value: boolean);
  25875. private static _ThicknessTextureEnabled;
  25876. /**
  25877. * Are thickness textures enabled in the application.
  25878. */
  25879. static get ThicknessTextureEnabled(): boolean;
  25880. static set ThicknessTextureEnabled(value: boolean);
  25881. }
  25882. }
  25883. declare module BABYLON {
  25884. /** @hidden */
  25885. export var defaultFragmentDeclaration: {
  25886. name: string;
  25887. shader: string;
  25888. };
  25889. }
  25890. declare module BABYLON {
  25891. /** @hidden */
  25892. export var defaultUboDeclaration: {
  25893. name: string;
  25894. shader: string;
  25895. };
  25896. }
  25897. declare module BABYLON {
  25898. /** @hidden */
  25899. export var lightFragmentDeclaration: {
  25900. name: string;
  25901. shader: string;
  25902. };
  25903. }
  25904. declare module BABYLON {
  25905. /** @hidden */
  25906. export var lightUboDeclaration: {
  25907. name: string;
  25908. shader: string;
  25909. };
  25910. }
  25911. declare module BABYLON {
  25912. /** @hidden */
  25913. export var lightsFragmentFunctions: {
  25914. name: string;
  25915. shader: string;
  25916. };
  25917. }
  25918. declare module BABYLON {
  25919. /** @hidden */
  25920. export var shadowsFragmentFunctions: {
  25921. name: string;
  25922. shader: string;
  25923. };
  25924. }
  25925. declare module BABYLON {
  25926. /** @hidden */
  25927. export var fresnelFunction: {
  25928. name: string;
  25929. shader: string;
  25930. };
  25931. }
  25932. declare module BABYLON {
  25933. /** @hidden */
  25934. export var reflectionFunction: {
  25935. name: string;
  25936. shader: string;
  25937. };
  25938. }
  25939. declare module BABYLON {
  25940. /** @hidden */
  25941. export var bumpFragmentFunctions: {
  25942. name: string;
  25943. shader: string;
  25944. };
  25945. }
  25946. declare module BABYLON {
  25947. /** @hidden */
  25948. export var logDepthDeclaration: {
  25949. name: string;
  25950. shader: string;
  25951. };
  25952. }
  25953. declare module BABYLON {
  25954. /** @hidden */
  25955. export var bumpFragment: {
  25956. name: string;
  25957. shader: string;
  25958. };
  25959. }
  25960. declare module BABYLON {
  25961. /** @hidden */
  25962. export var depthPrePass: {
  25963. name: string;
  25964. shader: string;
  25965. };
  25966. }
  25967. declare module BABYLON {
  25968. /** @hidden */
  25969. export var lightFragment: {
  25970. name: string;
  25971. shader: string;
  25972. };
  25973. }
  25974. declare module BABYLON {
  25975. /** @hidden */
  25976. export var logDepthFragment: {
  25977. name: string;
  25978. shader: string;
  25979. };
  25980. }
  25981. declare module BABYLON {
  25982. /** @hidden */
  25983. export var defaultPixelShader: {
  25984. name: string;
  25985. shader: string;
  25986. };
  25987. }
  25988. declare module BABYLON {
  25989. /** @hidden */
  25990. export var defaultVertexDeclaration: {
  25991. name: string;
  25992. shader: string;
  25993. };
  25994. }
  25995. declare module BABYLON {
  25996. /** @hidden */
  25997. export var bumpVertexDeclaration: {
  25998. name: string;
  25999. shader: string;
  26000. };
  26001. }
  26002. declare module BABYLON {
  26003. /** @hidden */
  26004. export var bumpVertex: {
  26005. name: string;
  26006. shader: string;
  26007. };
  26008. }
  26009. declare module BABYLON {
  26010. /** @hidden */
  26011. export var fogVertex: {
  26012. name: string;
  26013. shader: string;
  26014. };
  26015. }
  26016. declare module BABYLON {
  26017. /** @hidden */
  26018. export var shadowsVertex: {
  26019. name: string;
  26020. shader: string;
  26021. };
  26022. }
  26023. declare module BABYLON {
  26024. /** @hidden */
  26025. export var pointCloudVertex: {
  26026. name: string;
  26027. shader: string;
  26028. };
  26029. }
  26030. declare module BABYLON {
  26031. /** @hidden */
  26032. export var logDepthVertex: {
  26033. name: string;
  26034. shader: string;
  26035. };
  26036. }
  26037. declare module BABYLON {
  26038. /** @hidden */
  26039. export var defaultVertexShader: {
  26040. name: string;
  26041. shader: string;
  26042. };
  26043. }
  26044. declare module BABYLON {
  26045. /** @hidden */
  26046. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  26047. MAINUV1: boolean;
  26048. MAINUV2: boolean;
  26049. DIFFUSE: boolean;
  26050. DIFFUSEDIRECTUV: number;
  26051. AMBIENT: boolean;
  26052. AMBIENTDIRECTUV: number;
  26053. OPACITY: boolean;
  26054. OPACITYDIRECTUV: number;
  26055. OPACITYRGB: boolean;
  26056. REFLECTION: boolean;
  26057. EMISSIVE: boolean;
  26058. EMISSIVEDIRECTUV: number;
  26059. SPECULAR: boolean;
  26060. SPECULARDIRECTUV: number;
  26061. BUMP: boolean;
  26062. BUMPDIRECTUV: number;
  26063. PARALLAX: boolean;
  26064. PARALLAXOCCLUSION: boolean;
  26065. SPECULAROVERALPHA: boolean;
  26066. CLIPPLANE: boolean;
  26067. CLIPPLANE2: boolean;
  26068. CLIPPLANE3: boolean;
  26069. CLIPPLANE4: boolean;
  26070. CLIPPLANE5: boolean;
  26071. CLIPPLANE6: boolean;
  26072. ALPHATEST: boolean;
  26073. DEPTHPREPASS: boolean;
  26074. ALPHAFROMDIFFUSE: boolean;
  26075. POINTSIZE: boolean;
  26076. FOG: boolean;
  26077. SPECULARTERM: boolean;
  26078. DIFFUSEFRESNEL: boolean;
  26079. OPACITYFRESNEL: boolean;
  26080. REFLECTIONFRESNEL: boolean;
  26081. REFRACTIONFRESNEL: boolean;
  26082. EMISSIVEFRESNEL: boolean;
  26083. FRESNEL: boolean;
  26084. NORMAL: boolean;
  26085. UV1: boolean;
  26086. UV2: boolean;
  26087. VERTEXCOLOR: boolean;
  26088. VERTEXALPHA: boolean;
  26089. NUM_BONE_INFLUENCERS: number;
  26090. BonesPerMesh: number;
  26091. BONETEXTURE: boolean;
  26092. INSTANCES: boolean;
  26093. GLOSSINESS: boolean;
  26094. ROUGHNESS: boolean;
  26095. EMISSIVEASILLUMINATION: boolean;
  26096. LINKEMISSIVEWITHDIFFUSE: boolean;
  26097. REFLECTIONFRESNELFROMSPECULAR: boolean;
  26098. LIGHTMAP: boolean;
  26099. LIGHTMAPDIRECTUV: number;
  26100. OBJECTSPACE_NORMALMAP: boolean;
  26101. USELIGHTMAPASSHADOWMAP: boolean;
  26102. REFLECTIONMAP_3D: boolean;
  26103. REFLECTIONMAP_SPHERICAL: boolean;
  26104. REFLECTIONMAP_PLANAR: boolean;
  26105. REFLECTIONMAP_CUBIC: boolean;
  26106. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  26107. REFLECTIONMAP_PROJECTION: boolean;
  26108. REFLECTIONMAP_SKYBOX: boolean;
  26109. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  26110. REFLECTIONMAP_EXPLICIT: boolean;
  26111. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  26112. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  26113. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  26114. INVERTCUBICMAP: boolean;
  26115. LOGARITHMICDEPTH: boolean;
  26116. REFRACTION: boolean;
  26117. REFRACTIONMAP_3D: boolean;
  26118. REFLECTIONOVERALPHA: boolean;
  26119. TWOSIDEDLIGHTING: boolean;
  26120. SHADOWFLOAT: boolean;
  26121. MORPHTARGETS: boolean;
  26122. MORPHTARGETS_NORMAL: boolean;
  26123. MORPHTARGETS_TANGENT: boolean;
  26124. MORPHTARGETS_UV: boolean;
  26125. NUM_MORPH_INFLUENCERS: number;
  26126. NONUNIFORMSCALING: boolean;
  26127. PREMULTIPLYALPHA: boolean;
  26128. IMAGEPROCESSING: boolean;
  26129. VIGNETTE: boolean;
  26130. VIGNETTEBLENDMODEMULTIPLY: boolean;
  26131. VIGNETTEBLENDMODEOPAQUE: boolean;
  26132. TONEMAPPING: boolean;
  26133. TONEMAPPING_ACES: boolean;
  26134. CONTRAST: boolean;
  26135. COLORCURVES: boolean;
  26136. COLORGRADING: boolean;
  26137. COLORGRADING3D: boolean;
  26138. SAMPLER3DGREENDEPTH: boolean;
  26139. SAMPLER3DBGRMAP: boolean;
  26140. IMAGEPROCESSINGPOSTPROCESS: boolean;
  26141. MULTIVIEW: boolean;
  26142. /**
  26143. * If the reflection texture on this material is in linear color space
  26144. * @hidden
  26145. */
  26146. IS_REFLECTION_LINEAR: boolean;
  26147. /**
  26148. * If the refraction texture on this material is in linear color space
  26149. * @hidden
  26150. */
  26151. IS_REFRACTION_LINEAR: boolean;
  26152. EXPOSURE: boolean;
  26153. constructor();
  26154. setReflectionMode(modeToEnable: string): void;
  26155. }
  26156. /**
  26157. * This is the default material used in Babylon. It is the best trade off between quality
  26158. * and performances.
  26159. * @see http://doc.babylonjs.com/babylon101/materials
  26160. */
  26161. export class StandardMaterial extends PushMaterial {
  26162. private _diffuseTexture;
  26163. /**
  26164. * The basic texture of the material as viewed under a light.
  26165. */
  26166. diffuseTexture: Nullable<BaseTexture>;
  26167. private _ambientTexture;
  26168. /**
  26169. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  26170. */
  26171. ambientTexture: Nullable<BaseTexture>;
  26172. private _opacityTexture;
  26173. /**
  26174. * Define the transparency of the material from a texture.
  26175. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  26176. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  26177. */
  26178. opacityTexture: Nullable<BaseTexture>;
  26179. private _reflectionTexture;
  26180. /**
  26181. * Define the texture used to display the reflection.
  26182. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26183. */
  26184. reflectionTexture: Nullable<BaseTexture>;
  26185. private _emissiveTexture;
  26186. /**
  26187. * Define texture of the material as if self lit.
  26188. * This will be mixed in the final result even in the absence of light.
  26189. */
  26190. emissiveTexture: Nullable<BaseTexture>;
  26191. private _specularTexture;
  26192. /**
  26193. * Define how the color and intensity of the highlight given by the light in the material.
  26194. */
  26195. specularTexture: Nullable<BaseTexture>;
  26196. private _bumpTexture;
  26197. /**
  26198. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  26199. * 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.
  26200. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  26201. */
  26202. bumpTexture: Nullable<BaseTexture>;
  26203. private _lightmapTexture;
  26204. /**
  26205. * Complex lighting can be computationally expensive to compute at runtime.
  26206. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  26207. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  26208. */
  26209. lightmapTexture: Nullable<BaseTexture>;
  26210. private _refractionTexture;
  26211. /**
  26212. * Define the texture used to display the refraction.
  26213. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26214. */
  26215. refractionTexture: Nullable<BaseTexture>;
  26216. /**
  26217. * The color of the material lit by the environmental background lighting.
  26218. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  26219. */
  26220. ambientColor: Color3;
  26221. /**
  26222. * The basic color of the material as viewed under a light.
  26223. */
  26224. diffuseColor: Color3;
  26225. /**
  26226. * Define how the color and intensity of the highlight given by the light in the material.
  26227. */
  26228. specularColor: Color3;
  26229. /**
  26230. * Define the color of the material as if self lit.
  26231. * This will be mixed in the final result even in the absence of light.
  26232. */
  26233. emissiveColor: Color3;
  26234. /**
  26235. * Defines how sharp are the highlights in the material.
  26236. * The bigger the value the sharper giving a more glossy feeling to the result.
  26237. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  26238. */
  26239. specularPower: number;
  26240. private _useAlphaFromDiffuseTexture;
  26241. /**
  26242. * Does the transparency come from the diffuse texture alpha channel.
  26243. */
  26244. useAlphaFromDiffuseTexture: boolean;
  26245. private _useEmissiveAsIllumination;
  26246. /**
  26247. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  26248. */
  26249. useEmissiveAsIllumination: boolean;
  26250. private _linkEmissiveWithDiffuse;
  26251. /**
  26252. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  26253. * the emissive level when the final color is close to one.
  26254. */
  26255. linkEmissiveWithDiffuse: boolean;
  26256. private _useSpecularOverAlpha;
  26257. /**
  26258. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  26259. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  26260. */
  26261. useSpecularOverAlpha: boolean;
  26262. private _useReflectionOverAlpha;
  26263. /**
  26264. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  26265. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  26266. */
  26267. useReflectionOverAlpha: boolean;
  26268. private _disableLighting;
  26269. /**
  26270. * Does lights from the scene impacts this material.
  26271. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  26272. */
  26273. disableLighting: boolean;
  26274. private _useObjectSpaceNormalMap;
  26275. /**
  26276. * Allows using an object space normal map (instead of tangent space).
  26277. */
  26278. useObjectSpaceNormalMap: boolean;
  26279. private _useParallax;
  26280. /**
  26281. * Is parallax enabled or not.
  26282. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  26283. */
  26284. useParallax: boolean;
  26285. private _useParallaxOcclusion;
  26286. /**
  26287. * Is parallax occlusion enabled or not.
  26288. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  26289. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  26290. */
  26291. useParallaxOcclusion: boolean;
  26292. /**
  26293. * 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.
  26294. */
  26295. parallaxScaleBias: number;
  26296. private _roughness;
  26297. /**
  26298. * Helps to define how blurry the reflections should appears in the material.
  26299. */
  26300. roughness: number;
  26301. /**
  26302. * In case of refraction, define the value of the index of refraction.
  26303. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26304. */
  26305. indexOfRefraction: number;
  26306. /**
  26307. * Invert the refraction texture alongside the y axis.
  26308. * It can be useful with procedural textures or probe for instance.
  26309. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26310. */
  26311. invertRefractionY: boolean;
  26312. /**
  26313. * Defines the alpha limits in alpha test mode.
  26314. */
  26315. alphaCutOff: number;
  26316. private _useLightmapAsShadowmap;
  26317. /**
  26318. * In case of light mapping, define whether the map contains light or shadow informations.
  26319. */
  26320. useLightmapAsShadowmap: boolean;
  26321. private _diffuseFresnelParameters;
  26322. /**
  26323. * Define the diffuse fresnel parameters of the material.
  26324. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26325. */
  26326. diffuseFresnelParameters: FresnelParameters;
  26327. private _opacityFresnelParameters;
  26328. /**
  26329. * Define the opacity fresnel parameters of the material.
  26330. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26331. */
  26332. opacityFresnelParameters: FresnelParameters;
  26333. private _reflectionFresnelParameters;
  26334. /**
  26335. * Define the reflection fresnel parameters of the material.
  26336. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26337. */
  26338. reflectionFresnelParameters: FresnelParameters;
  26339. private _refractionFresnelParameters;
  26340. /**
  26341. * Define the refraction fresnel parameters of the material.
  26342. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26343. */
  26344. refractionFresnelParameters: FresnelParameters;
  26345. private _emissiveFresnelParameters;
  26346. /**
  26347. * Define the emissive fresnel parameters of the material.
  26348. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26349. */
  26350. emissiveFresnelParameters: FresnelParameters;
  26351. private _useReflectionFresnelFromSpecular;
  26352. /**
  26353. * If true automatically deducts the fresnels values from the material specularity.
  26354. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26355. */
  26356. useReflectionFresnelFromSpecular: boolean;
  26357. private _useGlossinessFromSpecularMapAlpha;
  26358. /**
  26359. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  26360. */
  26361. useGlossinessFromSpecularMapAlpha: boolean;
  26362. private _maxSimultaneousLights;
  26363. /**
  26364. * Defines the maximum number of lights that can be used in the material
  26365. */
  26366. maxSimultaneousLights: number;
  26367. private _invertNormalMapX;
  26368. /**
  26369. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  26370. */
  26371. invertNormalMapX: boolean;
  26372. private _invertNormalMapY;
  26373. /**
  26374. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  26375. */
  26376. invertNormalMapY: boolean;
  26377. private _twoSidedLighting;
  26378. /**
  26379. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  26380. */
  26381. twoSidedLighting: boolean;
  26382. /**
  26383. * Default configuration related to image processing available in the standard Material.
  26384. */
  26385. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  26386. /**
  26387. * Gets the image processing configuration used either in this material.
  26388. */
  26389. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  26390. /**
  26391. * Sets the Default image processing configuration used either in the this material.
  26392. *
  26393. * If sets to null, the scene one is in use.
  26394. */
  26395. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  26396. /**
  26397. * Keep track of the image processing observer to allow dispose and replace.
  26398. */
  26399. private _imageProcessingObserver;
  26400. /**
  26401. * Attaches a new image processing configuration to the Standard Material.
  26402. * @param configuration
  26403. */
  26404. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  26405. /**
  26406. * Gets wether the color curves effect is enabled.
  26407. */
  26408. get cameraColorCurvesEnabled(): boolean;
  26409. /**
  26410. * Sets wether the color curves effect is enabled.
  26411. */
  26412. set cameraColorCurvesEnabled(value: boolean);
  26413. /**
  26414. * Gets wether the color grading effect is enabled.
  26415. */
  26416. get cameraColorGradingEnabled(): boolean;
  26417. /**
  26418. * Gets wether the color grading effect is enabled.
  26419. */
  26420. set cameraColorGradingEnabled(value: boolean);
  26421. /**
  26422. * Gets wether tonemapping is enabled or not.
  26423. */
  26424. get cameraToneMappingEnabled(): boolean;
  26425. /**
  26426. * Sets wether tonemapping is enabled or not
  26427. */
  26428. set cameraToneMappingEnabled(value: boolean);
  26429. /**
  26430. * The camera exposure used on this material.
  26431. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  26432. * This corresponds to a photographic exposure.
  26433. */
  26434. get cameraExposure(): number;
  26435. /**
  26436. * The camera exposure used on this material.
  26437. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  26438. * This corresponds to a photographic exposure.
  26439. */
  26440. set cameraExposure(value: number);
  26441. /**
  26442. * Gets The camera contrast used on this material.
  26443. */
  26444. get cameraContrast(): number;
  26445. /**
  26446. * Sets The camera contrast used on this material.
  26447. */
  26448. set cameraContrast(value: number);
  26449. /**
  26450. * Gets the Color Grading 2D Lookup Texture.
  26451. */
  26452. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  26453. /**
  26454. * Sets the Color Grading 2D Lookup Texture.
  26455. */
  26456. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  26457. /**
  26458. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  26459. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  26460. * 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;
  26461. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  26462. */
  26463. get cameraColorCurves(): Nullable<ColorCurves>;
  26464. /**
  26465. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  26466. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  26467. * 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;
  26468. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  26469. */
  26470. set cameraColorCurves(value: Nullable<ColorCurves>);
  26471. /**
  26472. * Custom callback helping to override the default shader used in the material.
  26473. */
  26474. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  26475. protected _renderTargets: SmartArray<RenderTargetTexture>;
  26476. protected _worldViewProjectionMatrix: Matrix;
  26477. protected _globalAmbientColor: Color3;
  26478. protected _useLogarithmicDepth: boolean;
  26479. protected _rebuildInParallel: boolean;
  26480. /**
  26481. * Instantiates a new standard material.
  26482. * This is the default material used in Babylon. It is the best trade off between quality
  26483. * and performances.
  26484. * @see http://doc.babylonjs.com/babylon101/materials
  26485. * @param name Define the name of the material in the scene
  26486. * @param scene Define the scene the material belong to
  26487. */
  26488. constructor(name: string, scene: Scene);
  26489. /**
  26490. * Gets a boolean indicating that current material needs to register RTT
  26491. */
  26492. get hasRenderTargetTextures(): boolean;
  26493. /**
  26494. * Gets the current class name of the material e.g. "StandardMaterial"
  26495. * Mainly use in serialization.
  26496. * @returns the class name
  26497. */
  26498. getClassName(): string;
  26499. /**
  26500. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  26501. * You can try switching to logarithmic depth.
  26502. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  26503. */
  26504. get useLogarithmicDepth(): boolean;
  26505. set useLogarithmicDepth(value: boolean);
  26506. /**
  26507. * Specifies if the material will require alpha blending
  26508. * @returns a boolean specifying if alpha blending is needed
  26509. */
  26510. needAlphaBlending(): boolean;
  26511. /**
  26512. * Specifies if this material should be rendered in alpha test mode
  26513. * @returns a boolean specifying if an alpha test is needed.
  26514. */
  26515. needAlphaTesting(): boolean;
  26516. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  26517. /**
  26518. * Get the texture used for alpha test purpose.
  26519. * @returns the diffuse texture in case of the standard material.
  26520. */
  26521. getAlphaTestTexture(): Nullable<BaseTexture>;
  26522. /**
  26523. * Get if the submesh is ready to be used and all its information available.
  26524. * Child classes can use it to update shaders
  26525. * @param mesh defines the mesh to check
  26526. * @param subMesh defines which submesh to check
  26527. * @param useInstances specifies that instances should be used
  26528. * @returns a boolean indicating that the submesh is ready or not
  26529. */
  26530. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  26531. /**
  26532. * Builds the material UBO layouts.
  26533. * Used internally during the effect preparation.
  26534. */
  26535. buildUniformLayout(): void;
  26536. /**
  26537. * Unbinds the material from the mesh
  26538. */
  26539. unbind(): void;
  26540. /**
  26541. * Binds the submesh to this material by preparing the effect and shader to draw
  26542. * @param world defines the world transformation matrix
  26543. * @param mesh defines the mesh containing the submesh
  26544. * @param subMesh defines the submesh to bind the material to
  26545. */
  26546. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  26547. /**
  26548. * Get the list of animatables in the material.
  26549. * @returns the list of animatables object used in the material
  26550. */
  26551. getAnimatables(): IAnimatable[];
  26552. /**
  26553. * Gets the active textures from the material
  26554. * @returns an array of textures
  26555. */
  26556. getActiveTextures(): BaseTexture[];
  26557. /**
  26558. * Specifies if the material uses a texture
  26559. * @param texture defines the texture to check against the material
  26560. * @returns a boolean specifying if the material uses the texture
  26561. */
  26562. hasTexture(texture: BaseTexture): boolean;
  26563. /**
  26564. * Disposes the material
  26565. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  26566. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  26567. */
  26568. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  26569. /**
  26570. * Makes a duplicate of the material, and gives it a new name
  26571. * @param name defines the new name for the duplicated material
  26572. * @returns the cloned material
  26573. */
  26574. clone(name: string): StandardMaterial;
  26575. /**
  26576. * Serializes this material in a JSON representation
  26577. * @returns the serialized material object
  26578. */
  26579. serialize(): any;
  26580. /**
  26581. * Creates a standard material from parsed material data
  26582. * @param source defines the JSON representation of the material
  26583. * @param scene defines the hosting scene
  26584. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  26585. * @returns a new standard material
  26586. */
  26587. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  26588. /**
  26589. * Are diffuse textures enabled in the application.
  26590. */
  26591. static get DiffuseTextureEnabled(): boolean;
  26592. static set DiffuseTextureEnabled(value: boolean);
  26593. /**
  26594. * Are ambient textures enabled in the application.
  26595. */
  26596. static get AmbientTextureEnabled(): boolean;
  26597. static set AmbientTextureEnabled(value: boolean);
  26598. /**
  26599. * Are opacity textures enabled in the application.
  26600. */
  26601. static get OpacityTextureEnabled(): boolean;
  26602. static set OpacityTextureEnabled(value: boolean);
  26603. /**
  26604. * Are reflection textures enabled in the application.
  26605. */
  26606. static get ReflectionTextureEnabled(): boolean;
  26607. static set ReflectionTextureEnabled(value: boolean);
  26608. /**
  26609. * Are emissive textures enabled in the application.
  26610. */
  26611. static get EmissiveTextureEnabled(): boolean;
  26612. static set EmissiveTextureEnabled(value: boolean);
  26613. /**
  26614. * Are specular textures enabled in the application.
  26615. */
  26616. static get SpecularTextureEnabled(): boolean;
  26617. static set SpecularTextureEnabled(value: boolean);
  26618. /**
  26619. * Are bump textures enabled in the application.
  26620. */
  26621. static get BumpTextureEnabled(): boolean;
  26622. static set BumpTextureEnabled(value: boolean);
  26623. /**
  26624. * Are lightmap textures enabled in the application.
  26625. */
  26626. static get LightmapTextureEnabled(): boolean;
  26627. static set LightmapTextureEnabled(value: boolean);
  26628. /**
  26629. * Are refraction textures enabled in the application.
  26630. */
  26631. static get RefractionTextureEnabled(): boolean;
  26632. static set RefractionTextureEnabled(value: boolean);
  26633. /**
  26634. * Are color grading textures enabled in the application.
  26635. */
  26636. static get ColorGradingTextureEnabled(): boolean;
  26637. static set ColorGradingTextureEnabled(value: boolean);
  26638. /**
  26639. * Are fresnels enabled in the application.
  26640. */
  26641. static get FresnelEnabled(): boolean;
  26642. static set FresnelEnabled(value: boolean);
  26643. }
  26644. }
  26645. declare module BABYLON {
  26646. /**
  26647. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  26648. *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.
  26649. * The SPS is also a particle system. It provides some methods to manage the particles.
  26650. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  26651. *
  26652. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  26653. */
  26654. export class SolidParticleSystem implements IDisposable {
  26655. /**
  26656. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  26657. * Example : var p = SPS.particles[i];
  26658. */
  26659. particles: SolidParticle[];
  26660. /**
  26661. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  26662. */
  26663. nbParticles: number;
  26664. /**
  26665. * If the particles must ever face the camera (default false). Useful for planar particles.
  26666. */
  26667. billboard: boolean;
  26668. /**
  26669. * Recompute normals when adding a shape
  26670. */
  26671. recomputeNormals: boolean;
  26672. /**
  26673. * This a counter ofr your own usage. It's not set by any SPS functions.
  26674. */
  26675. counter: number;
  26676. /**
  26677. * The SPS name. This name is also given to the underlying mesh.
  26678. */
  26679. name: string;
  26680. /**
  26681. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  26682. */
  26683. mesh: Mesh;
  26684. /**
  26685. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  26686. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  26687. */
  26688. vars: any;
  26689. /**
  26690. * This array is populated when the SPS is set as 'pickable'.
  26691. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  26692. * Each element of this array is an object `{idx: int, faceId: int}`.
  26693. * `idx` is the picked particle index in the `SPS.particles` array
  26694. * `faceId` is the picked face index counted within this particle.
  26695. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  26696. */
  26697. pickedParticles: {
  26698. idx: number;
  26699. faceId: number;
  26700. }[];
  26701. /**
  26702. * This array is populated when `enableDepthSort` is set to true.
  26703. * Each element of this array is an instance of the class DepthSortedParticle.
  26704. */
  26705. depthSortedParticles: DepthSortedParticle[];
  26706. /**
  26707. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  26708. * @hidden
  26709. */
  26710. _bSphereOnly: boolean;
  26711. /**
  26712. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  26713. * @hidden
  26714. */
  26715. _bSphereRadiusFactor: number;
  26716. private _scene;
  26717. private _positions;
  26718. private _indices;
  26719. private _normals;
  26720. private _colors;
  26721. private _uvs;
  26722. private _indices32;
  26723. private _positions32;
  26724. private _normals32;
  26725. private _fixedNormal32;
  26726. private _colors32;
  26727. private _uvs32;
  26728. private _index;
  26729. private _updatable;
  26730. private _pickable;
  26731. private _isVisibilityBoxLocked;
  26732. private _alwaysVisible;
  26733. private _depthSort;
  26734. private _expandable;
  26735. private _shapeCounter;
  26736. private _copy;
  26737. private _color;
  26738. private _computeParticleColor;
  26739. private _computeParticleTexture;
  26740. private _computeParticleRotation;
  26741. private _computeParticleVertex;
  26742. private _computeBoundingBox;
  26743. private _depthSortParticles;
  26744. private _camera;
  26745. private _mustUnrotateFixedNormals;
  26746. private _particlesIntersect;
  26747. private _needs32Bits;
  26748. private _isNotBuilt;
  26749. private _lastParticleId;
  26750. private _idxOfId;
  26751. private _multimaterialEnabled;
  26752. private _useModelMaterial;
  26753. private _indicesByMaterial;
  26754. private _materialIndexes;
  26755. private _depthSortFunction;
  26756. private _materialSortFunction;
  26757. private _materials;
  26758. private _multimaterial;
  26759. private _materialIndexesById;
  26760. private _defaultMaterial;
  26761. private _autoUpdateSubMeshes;
  26762. /**
  26763. * Creates a SPS (Solid Particle System) object.
  26764. * @param name (String) is the SPS name, this will be the underlying mesh name.
  26765. * @param scene (Scene) is the scene in which the SPS is added.
  26766. * @param options defines the options of the sps e.g.
  26767. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  26768. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  26769. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  26770. * * 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.
  26771. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  26772. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  26773. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  26774. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  26775. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  26776. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  26777. */
  26778. constructor(name: string, scene: Scene, options?: {
  26779. updatable?: boolean;
  26780. isPickable?: boolean;
  26781. enableDepthSort?: boolean;
  26782. particleIntersection?: boolean;
  26783. boundingSphereOnly?: boolean;
  26784. bSphereRadiusFactor?: number;
  26785. expandable?: boolean;
  26786. useModelMaterial?: boolean;
  26787. enableMultiMaterial?: boolean;
  26788. });
  26789. /**
  26790. * Builds the SPS underlying mesh. Returns a standard Mesh.
  26791. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  26792. * @returns the created mesh
  26793. */
  26794. buildMesh(): Mesh;
  26795. /**
  26796. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  26797. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  26798. * Thus the particles generated from `digest()` have their property `position` set yet.
  26799. * @param mesh ( Mesh ) is the mesh to be digested
  26800. * @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
  26801. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  26802. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  26803. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  26804. * @returns the current SPS
  26805. */
  26806. digest(mesh: Mesh, options?: {
  26807. facetNb?: number;
  26808. number?: number;
  26809. delta?: number;
  26810. storage?: [];
  26811. }): SolidParticleSystem;
  26812. /**
  26813. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  26814. * @hidden
  26815. */
  26816. private _unrotateFixedNormals;
  26817. /**
  26818. * Resets the temporary working copy particle
  26819. * @hidden
  26820. */
  26821. private _resetCopy;
  26822. /**
  26823. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  26824. * @param p the current index in the positions array to be updated
  26825. * @param ind the current index in the indices array
  26826. * @param shape a Vector3 array, the shape geometry
  26827. * @param positions the positions array to be updated
  26828. * @param meshInd the shape indices array
  26829. * @param indices the indices array to be updated
  26830. * @param meshUV the shape uv array
  26831. * @param uvs the uv array to be updated
  26832. * @param meshCol the shape color array
  26833. * @param colors the color array to be updated
  26834. * @param meshNor the shape normals array
  26835. * @param normals the normals array to be updated
  26836. * @param idx the particle index
  26837. * @param idxInShape the particle index in its shape
  26838. * @param options the addShape() method passed options
  26839. * @model the particle model
  26840. * @hidden
  26841. */
  26842. private _meshBuilder;
  26843. /**
  26844. * Returns a shape Vector3 array from positions float array
  26845. * @param positions float array
  26846. * @returns a vector3 array
  26847. * @hidden
  26848. */
  26849. private _posToShape;
  26850. /**
  26851. * Returns a shapeUV array from a float uvs (array deep copy)
  26852. * @param uvs as a float array
  26853. * @returns a shapeUV array
  26854. * @hidden
  26855. */
  26856. private _uvsToShapeUV;
  26857. /**
  26858. * Adds a new particle object in the particles array
  26859. * @param idx particle index in particles array
  26860. * @param id particle id
  26861. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  26862. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  26863. * @param model particle ModelShape object
  26864. * @param shapeId model shape identifier
  26865. * @param idxInShape index of the particle in the current model
  26866. * @param bInfo model bounding info object
  26867. * @param storage target storage array, if any
  26868. * @hidden
  26869. */
  26870. private _addParticle;
  26871. /**
  26872. * Adds some particles to the SPS from the model shape. Returns the shape id.
  26873. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  26874. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  26875. * @param nb (positive integer) the number of particles to be created from this model
  26876. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  26877. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  26878. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  26879. * @returns the number of shapes in the system
  26880. */
  26881. addShape(mesh: Mesh, nb: number, options?: {
  26882. positionFunction?: any;
  26883. vertexFunction?: any;
  26884. storage?: [];
  26885. }): number;
  26886. /**
  26887. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  26888. * @hidden
  26889. */
  26890. private _rebuildParticle;
  26891. /**
  26892. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  26893. * @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.
  26894. * @returns the SPS.
  26895. */
  26896. rebuildMesh(reset?: boolean): SolidParticleSystem;
  26897. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  26898. * Returns an array with the removed particles.
  26899. * 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.
  26900. * The SPS can't be empty so at least one particle needs to remain in place.
  26901. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  26902. * @param start index of the first particle to remove
  26903. * @param end index of the last particle to remove (included)
  26904. * @returns an array populated with the removed particles
  26905. */
  26906. removeParticles(start: number, end: number): SolidParticle[];
  26907. /**
  26908. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  26909. * @param solidParticleArray an array populated with Solid Particles objects
  26910. * @returns the SPS
  26911. */
  26912. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  26913. /**
  26914. * Creates a new particle and modifies the SPS mesh geometry :
  26915. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  26916. * - calls _addParticle() to populate the particle array
  26917. * factorized code from addShape() and insertParticlesFromArray()
  26918. * @param idx particle index in the particles array
  26919. * @param i particle index in its shape
  26920. * @param modelShape particle ModelShape object
  26921. * @param shape shape vertex array
  26922. * @param meshInd shape indices array
  26923. * @param meshUV shape uv array
  26924. * @param meshCol shape color array
  26925. * @param meshNor shape normals array
  26926. * @param bbInfo shape bounding info
  26927. * @param storage target particle storage
  26928. * @options addShape() passed options
  26929. * @hidden
  26930. */
  26931. private _insertNewParticle;
  26932. /**
  26933. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  26934. * This method calls `updateParticle()` for each particle of the SPS.
  26935. * For an animated SPS, it is usually called within the render loop.
  26936. * 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.
  26937. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  26938. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  26939. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  26940. * @returns the SPS.
  26941. */
  26942. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  26943. /**
  26944. * Disposes the SPS.
  26945. */
  26946. dispose(): void;
  26947. /**
  26948. * Returns a SolidParticle object from its identifier : particle.id
  26949. * @param id (integer) the particle Id
  26950. * @returns the searched particle or null if not found in the SPS.
  26951. */
  26952. getParticleById(id: number): Nullable<SolidParticle>;
  26953. /**
  26954. * Returns a new array populated with the particles having the passed shapeId.
  26955. * @param shapeId (integer) the shape identifier
  26956. * @returns a new solid particle array
  26957. */
  26958. getParticlesByShapeId(shapeId: number): SolidParticle[];
  26959. /**
  26960. * Populates the passed array "ref" with the particles having the passed shapeId.
  26961. * @param shapeId the shape identifier
  26962. * @returns the SPS
  26963. * @param ref
  26964. */
  26965. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  26966. /**
  26967. * Computes the required SubMeshes according the materials assigned to the particles.
  26968. * @returns the solid particle system.
  26969. * Does nothing if called before the SPS mesh is built.
  26970. */
  26971. computeSubMeshes(): SolidParticleSystem;
  26972. /**
  26973. * Sorts the solid particles by material when MultiMaterial is enabled.
  26974. * Updates the indices32 array.
  26975. * Updates the indicesByMaterial array.
  26976. * Updates the mesh indices array.
  26977. * @returns the SPS
  26978. * @hidden
  26979. */
  26980. private _sortParticlesByMaterial;
  26981. /**
  26982. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  26983. * @hidden
  26984. */
  26985. private _setMaterialIndexesById;
  26986. /**
  26987. * Returns an array with unique values of Materials from the passed array
  26988. * @param array the material array to be checked and filtered
  26989. * @hidden
  26990. */
  26991. private _filterUniqueMaterialId;
  26992. /**
  26993. * Sets a new Standard Material as _defaultMaterial if not already set.
  26994. * @hidden
  26995. */
  26996. private _setDefaultMaterial;
  26997. /**
  26998. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  26999. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27000. * @returns the SPS.
  27001. */
  27002. refreshVisibleSize(): SolidParticleSystem;
  27003. /**
  27004. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  27005. * @param size the size (float) of the visibility box
  27006. * note : this doesn't lock the SPS mesh bounding box.
  27007. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27008. */
  27009. setVisibilityBox(size: number): void;
  27010. /**
  27011. * Gets whether the SPS as always visible or not
  27012. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27013. */
  27014. get isAlwaysVisible(): boolean;
  27015. /**
  27016. * Sets the SPS as always visible or not
  27017. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27018. */
  27019. set isAlwaysVisible(val: boolean);
  27020. /**
  27021. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27022. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27023. */
  27024. set isVisibilityBoxLocked(val: boolean);
  27025. /**
  27026. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27027. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27028. */
  27029. get isVisibilityBoxLocked(): boolean;
  27030. /**
  27031. * Tells to `setParticles()` to compute the particle rotations or not.
  27032. * Default value : true. The SPS is faster when it's set to false.
  27033. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27034. */
  27035. set computeParticleRotation(val: boolean);
  27036. /**
  27037. * Tells to `setParticles()` to compute the particle colors or not.
  27038. * Default value : true. The SPS is faster when it's set to false.
  27039. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27040. */
  27041. set computeParticleColor(val: boolean);
  27042. set computeParticleTexture(val: boolean);
  27043. /**
  27044. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  27045. * Default value : false. The SPS is faster when it's set to false.
  27046. * Note : the particle custom vertex positions aren't stored values.
  27047. */
  27048. set computeParticleVertex(val: boolean);
  27049. /**
  27050. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  27051. */
  27052. set computeBoundingBox(val: boolean);
  27053. /**
  27054. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  27055. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27056. * Default : `true`
  27057. */
  27058. set depthSortParticles(val: boolean);
  27059. /**
  27060. * Gets if `setParticles()` computes the particle rotations or not.
  27061. * Default value : true. The SPS is faster when it's set to false.
  27062. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27063. */
  27064. get computeParticleRotation(): boolean;
  27065. /**
  27066. * Gets if `setParticles()` computes the particle colors or not.
  27067. * Default value : true. The SPS is faster when it's set to false.
  27068. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27069. */
  27070. get computeParticleColor(): boolean;
  27071. /**
  27072. * Gets if `setParticles()` computes the particle textures or not.
  27073. * Default value : true. The SPS is faster when it's set to false.
  27074. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  27075. */
  27076. get computeParticleTexture(): boolean;
  27077. /**
  27078. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  27079. * Default value : false. The SPS is faster when it's set to false.
  27080. * Note : the particle custom vertex positions aren't stored values.
  27081. */
  27082. get computeParticleVertex(): boolean;
  27083. /**
  27084. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  27085. */
  27086. get computeBoundingBox(): boolean;
  27087. /**
  27088. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  27089. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27090. * Default : `true`
  27091. */
  27092. get depthSortParticles(): boolean;
  27093. /**
  27094. * Gets if the SPS is created as expandable at construction time.
  27095. * Default : `false`
  27096. */
  27097. get expandable(): boolean;
  27098. /**
  27099. * Gets if the SPS supports the Multi Materials
  27100. */
  27101. get multimaterialEnabled(): boolean;
  27102. /**
  27103. * Gets if the SPS uses the model materials for its own multimaterial.
  27104. */
  27105. get useModelMaterial(): boolean;
  27106. /**
  27107. * The SPS used material array.
  27108. */
  27109. get materials(): Material[];
  27110. /**
  27111. * Sets the SPS MultiMaterial from the passed materials.
  27112. * Note : the passed array is internally copied and not used then by reference.
  27113. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  27114. */
  27115. setMultiMaterial(materials: Material[]): void;
  27116. /**
  27117. * The SPS computed multimaterial object
  27118. */
  27119. get multimaterial(): MultiMaterial;
  27120. set multimaterial(mm: MultiMaterial);
  27121. /**
  27122. * If the subMeshes must be updated on the next call to setParticles()
  27123. */
  27124. get autoUpdateSubMeshes(): boolean;
  27125. set autoUpdateSubMeshes(val: boolean);
  27126. /**
  27127. * This function does nothing. It may be overwritten to set all the particle first values.
  27128. * The SPS doesn't call this function, you may have to call it by your own.
  27129. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27130. */
  27131. initParticles(): void;
  27132. /**
  27133. * This function does nothing. It may be overwritten to recycle a particle.
  27134. * The SPS doesn't call this function, you may have to call it by your own.
  27135. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27136. * @param particle The particle to recycle
  27137. * @returns the recycled particle
  27138. */
  27139. recycleParticle(particle: SolidParticle): SolidParticle;
  27140. /**
  27141. * Updates a particle : this function should be overwritten by the user.
  27142. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  27143. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27144. * @example : just set a particle position or velocity and recycle conditions
  27145. * @param particle The particle to update
  27146. * @returns the updated particle
  27147. */
  27148. updateParticle(particle: SolidParticle): SolidParticle;
  27149. /**
  27150. * Updates a vertex of a particle : it can be overwritten by the user.
  27151. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  27152. * @param particle the current particle
  27153. * @param vertex the current index of the current particle
  27154. * @param pt the index of the current vertex in the particle shape
  27155. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  27156. * @example : just set a vertex particle position
  27157. * @returns the updated vertex
  27158. */
  27159. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  27160. /**
  27161. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  27162. * This does nothing and may be overwritten by the user.
  27163. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27164. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27165. * @param update the boolean update value actually passed to setParticles()
  27166. */
  27167. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27168. /**
  27169. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  27170. * This will be passed three parameters.
  27171. * This does nothing and may be overwritten by the user.
  27172. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27173. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27174. * @param update the boolean update value actually passed to setParticles()
  27175. */
  27176. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27177. }
  27178. }
  27179. declare module BABYLON {
  27180. /**
  27181. * Represents one particle of a solid particle system.
  27182. */
  27183. export class SolidParticle {
  27184. /**
  27185. * particle global index
  27186. */
  27187. idx: number;
  27188. /**
  27189. * particle identifier
  27190. */
  27191. id: number;
  27192. /**
  27193. * The color of the particle
  27194. */
  27195. color: Nullable<Color4>;
  27196. /**
  27197. * The world space position of the particle.
  27198. */
  27199. position: Vector3;
  27200. /**
  27201. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  27202. */
  27203. rotation: Vector3;
  27204. /**
  27205. * The world space rotation quaternion of the particle.
  27206. */
  27207. rotationQuaternion: Nullable<Quaternion>;
  27208. /**
  27209. * The scaling of the particle.
  27210. */
  27211. scaling: Vector3;
  27212. /**
  27213. * The uvs of the particle.
  27214. */
  27215. uvs: Vector4;
  27216. /**
  27217. * The current speed of the particle.
  27218. */
  27219. velocity: Vector3;
  27220. /**
  27221. * The pivot point in the particle local space.
  27222. */
  27223. pivot: Vector3;
  27224. /**
  27225. * Must the particle be translated from its pivot point in its local space ?
  27226. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  27227. * Default : false
  27228. */
  27229. translateFromPivot: boolean;
  27230. /**
  27231. * Is the particle active or not ?
  27232. */
  27233. alive: boolean;
  27234. /**
  27235. * Is the particle visible or not ?
  27236. */
  27237. isVisible: boolean;
  27238. /**
  27239. * Index of this particle in the global "positions" array (Internal use)
  27240. * @hidden
  27241. */
  27242. _pos: number;
  27243. /**
  27244. * @hidden Index of this particle in the global "indices" array (Internal use)
  27245. */
  27246. _ind: number;
  27247. /**
  27248. * @hidden ModelShape of this particle (Internal use)
  27249. */
  27250. _model: ModelShape;
  27251. /**
  27252. * ModelShape id of this particle
  27253. */
  27254. shapeId: number;
  27255. /**
  27256. * Index of the particle in its shape id
  27257. */
  27258. idxInShape: number;
  27259. /**
  27260. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  27261. */
  27262. _modelBoundingInfo: BoundingInfo;
  27263. /**
  27264. * @hidden Particle BoundingInfo object (Internal use)
  27265. */
  27266. _boundingInfo: BoundingInfo;
  27267. /**
  27268. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  27269. */
  27270. _sps: SolidParticleSystem;
  27271. /**
  27272. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  27273. */
  27274. _stillInvisible: boolean;
  27275. /**
  27276. * @hidden Last computed particle rotation matrix
  27277. */
  27278. _rotationMatrix: number[];
  27279. /**
  27280. * Parent particle Id, if any.
  27281. * Default null.
  27282. */
  27283. parentId: Nullable<number>;
  27284. /**
  27285. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  27286. */
  27287. materialIndex: Nullable<number>;
  27288. /**
  27289. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  27290. * The possible values are :
  27291. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  27292. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27293. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  27294. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  27295. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27296. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  27297. * */
  27298. cullingStrategy: number;
  27299. /**
  27300. * @hidden Internal global position in the SPS.
  27301. */
  27302. _globalPosition: Vector3;
  27303. /**
  27304. * Creates a Solid Particle object.
  27305. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  27306. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  27307. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  27308. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  27309. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  27310. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  27311. * @param shapeId (integer) is the model shape identifier in the SPS.
  27312. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  27313. * @param sps defines the sps it is associated to
  27314. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  27315. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  27316. */
  27317. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  27318. /**
  27319. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  27320. * @param target the particle target
  27321. * @returns the current particle
  27322. */
  27323. copyToRef(target: SolidParticle): SolidParticle;
  27324. /**
  27325. * Legacy support, changed scale to scaling
  27326. */
  27327. get scale(): Vector3;
  27328. /**
  27329. * Legacy support, changed scale to scaling
  27330. */
  27331. set scale(scale: Vector3);
  27332. /**
  27333. * Legacy support, changed quaternion to rotationQuaternion
  27334. */
  27335. get quaternion(): Nullable<Quaternion>;
  27336. /**
  27337. * Legacy support, changed quaternion to rotationQuaternion
  27338. */
  27339. set quaternion(q: Nullable<Quaternion>);
  27340. /**
  27341. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  27342. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  27343. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  27344. * @returns true if it intersects
  27345. */
  27346. intersectsMesh(target: Mesh | SolidParticle): boolean;
  27347. /**
  27348. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  27349. * A particle is in the frustum if its bounding box intersects the frustum
  27350. * @param frustumPlanes defines the frustum to test
  27351. * @returns true if the particle is in the frustum planes
  27352. */
  27353. isInFrustum(frustumPlanes: Plane[]): boolean;
  27354. /**
  27355. * get the rotation matrix of the particle
  27356. * @hidden
  27357. */
  27358. getRotationMatrix(m: Matrix): void;
  27359. }
  27360. /**
  27361. * Represents the shape of the model used by one particle of a solid particle system.
  27362. * SPS internal tool, don't use it manually.
  27363. */
  27364. export class ModelShape {
  27365. /**
  27366. * The shape id
  27367. * @hidden
  27368. */
  27369. shapeID: number;
  27370. /**
  27371. * flat array of model positions (internal use)
  27372. * @hidden
  27373. */
  27374. _shape: Vector3[];
  27375. /**
  27376. * flat array of model UVs (internal use)
  27377. * @hidden
  27378. */
  27379. _shapeUV: number[];
  27380. /**
  27381. * color array of the model
  27382. * @hidden
  27383. */
  27384. _shapeColors: number[];
  27385. /**
  27386. * indices array of the model
  27387. * @hidden
  27388. */
  27389. _indices: number[];
  27390. /**
  27391. * normals array of the model
  27392. * @hidden
  27393. */
  27394. _normals: number[];
  27395. /**
  27396. * length of the shape in the model indices array (internal use)
  27397. * @hidden
  27398. */
  27399. _indicesLength: number;
  27400. /**
  27401. * Custom position function (internal use)
  27402. * @hidden
  27403. */
  27404. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  27405. /**
  27406. * Custom vertex function (internal use)
  27407. * @hidden
  27408. */
  27409. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  27410. /**
  27411. * Model material (internal use)
  27412. * @hidden
  27413. */
  27414. _material: Nullable<Material>;
  27415. /**
  27416. * 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.
  27417. * SPS internal tool, don't use it manually.
  27418. * @hidden
  27419. */
  27420. 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>);
  27421. }
  27422. /**
  27423. * Represents a Depth Sorted Particle in the solid particle system.
  27424. * @hidden
  27425. */
  27426. export class DepthSortedParticle {
  27427. /**
  27428. * Index of the particle in the "indices" array
  27429. */
  27430. ind: number;
  27431. /**
  27432. * Length of the particle shape in the "indices" array
  27433. */
  27434. indicesLength: number;
  27435. /**
  27436. * Squared distance from the particle to the camera
  27437. */
  27438. sqDistance: number;
  27439. /**
  27440. * Material index when used with MultiMaterials
  27441. */
  27442. materialIndex: number;
  27443. /**
  27444. * Creates a new sorted particle
  27445. * @param materialIndex
  27446. */
  27447. constructor(ind: number, indLength: number, materialIndex: number);
  27448. }
  27449. }
  27450. declare module BABYLON {
  27451. /**
  27452. * @hidden
  27453. */
  27454. export class _MeshCollisionData {
  27455. _checkCollisions: boolean;
  27456. _collisionMask: number;
  27457. _collisionGroup: number;
  27458. _collider: Nullable<Collider>;
  27459. _oldPositionForCollisions: Vector3;
  27460. _diffPositionForCollisions: Vector3;
  27461. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  27462. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  27463. }
  27464. }
  27465. declare module BABYLON {
  27466. /** @hidden */
  27467. class _FacetDataStorage {
  27468. facetPositions: Vector3[];
  27469. facetNormals: Vector3[];
  27470. facetPartitioning: number[][];
  27471. facetNb: number;
  27472. partitioningSubdivisions: number;
  27473. partitioningBBoxRatio: number;
  27474. facetDataEnabled: boolean;
  27475. facetParameters: any;
  27476. bbSize: Vector3;
  27477. subDiv: {
  27478. max: number;
  27479. X: number;
  27480. Y: number;
  27481. Z: number;
  27482. };
  27483. facetDepthSort: boolean;
  27484. facetDepthSortEnabled: boolean;
  27485. depthSortedIndices: IndicesArray;
  27486. depthSortedFacets: {
  27487. ind: number;
  27488. sqDistance: number;
  27489. }[];
  27490. facetDepthSortFunction: (f1: {
  27491. ind: number;
  27492. sqDistance: number;
  27493. }, f2: {
  27494. ind: number;
  27495. sqDistance: number;
  27496. }) => number;
  27497. facetDepthSortFrom: Vector3;
  27498. facetDepthSortOrigin: Vector3;
  27499. invertedMatrix: Matrix;
  27500. }
  27501. /**
  27502. * @hidden
  27503. **/
  27504. class _InternalAbstractMeshDataInfo {
  27505. _hasVertexAlpha: boolean;
  27506. _useVertexColors: boolean;
  27507. _numBoneInfluencers: number;
  27508. _applyFog: boolean;
  27509. _receiveShadows: boolean;
  27510. _facetData: _FacetDataStorage;
  27511. _visibility: number;
  27512. _skeleton: Nullable<Skeleton>;
  27513. _layerMask: number;
  27514. _computeBonesUsingShaders: boolean;
  27515. _isActive: boolean;
  27516. _onlyForInstances: boolean;
  27517. _isActiveIntermediate: boolean;
  27518. _onlyForInstancesIntermediate: boolean;
  27519. _actAsRegularMesh: boolean;
  27520. }
  27521. /**
  27522. * Class used to store all common mesh properties
  27523. */
  27524. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  27525. /** No occlusion */
  27526. static OCCLUSION_TYPE_NONE: number;
  27527. /** Occlusion set to optimisitic */
  27528. static OCCLUSION_TYPE_OPTIMISTIC: number;
  27529. /** Occlusion set to strict */
  27530. static OCCLUSION_TYPE_STRICT: number;
  27531. /** Use an accurante occlusion algorithm */
  27532. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  27533. /** Use a conservative occlusion algorithm */
  27534. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  27535. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  27536. * Test order :
  27537. * Is the bounding sphere outside the frustum ?
  27538. * If not, are the bounding box vertices outside the frustum ?
  27539. * It not, then the cullable object is in the frustum.
  27540. */
  27541. static readonly CULLINGSTRATEGY_STANDARD: number;
  27542. /** Culling strategy : Bounding Sphere Only.
  27543. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  27544. * It's also less accurate than the standard because some not visible objects can still be selected.
  27545. * Test : is the bounding sphere outside the frustum ?
  27546. * If not, then the cullable object is in the frustum.
  27547. */
  27548. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  27549. /** Culling strategy : Optimistic Inclusion.
  27550. * This in an inclusion test first, then the standard exclusion test.
  27551. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  27552. * 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.
  27553. * Anyway, it's as accurate as the standard strategy.
  27554. * Test :
  27555. * Is the cullable object bounding sphere center in the frustum ?
  27556. * If not, apply the default culling strategy.
  27557. */
  27558. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  27559. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  27560. * This in an inclusion test first, then the bounding sphere only exclusion test.
  27561. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  27562. * 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.
  27563. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  27564. * Test :
  27565. * Is the cullable object bounding sphere center in the frustum ?
  27566. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  27567. */
  27568. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  27569. /**
  27570. * No billboard
  27571. */
  27572. static get BILLBOARDMODE_NONE(): number;
  27573. /** Billboard on X axis */
  27574. static get BILLBOARDMODE_X(): number;
  27575. /** Billboard on Y axis */
  27576. static get BILLBOARDMODE_Y(): number;
  27577. /** Billboard on Z axis */
  27578. static get BILLBOARDMODE_Z(): number;
  27579. /** Billboard on all axes */
  27580. static get BILLBOARDMODE_ALL(): number;
  27581. /** Billboard on using position instead of orientation */
  27582. static get BILLBOARDMODE_USE_POSITION(): number;
  27583. /** @hidden */
  27584. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  27585. /**
  27586. * The culling strategy to use to check whether the mesh must be rendered or not.
  27587. * This value can be changed at any time and will be used on the next render mesh selection.
  27588. * The possible values are :
  27589. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  27590. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27591. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  27592. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  27593. * Please read each static variable documentation to get details about the culling process.
  27594. * */
  27595. cullingStrategy: number;
  27596. /**
  27597. * Gets the number of facets in the mesh
  27598. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  27599. */
  27600. get facetNb(): number;
  27601. /**
  27602. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  27603. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  27604. */
  27605. get partitioningSubdivisions(): number;
  27606. set partitioningSubdivisions(nb: number);
  27607. /**
  27608. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  27609. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  27610. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  27611. */
  27612. get partitioningBBoxRatio(): number;
  27613. set partitioningBBoxRatio(ratio: number);
  27614. /**
  27615. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  27616. * Works only for updatable meshes.
  27617. * Doesn't work with multi-materials
  27618. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  27619. */
  27620. get mustDepthSortFacets(): boolean;
  27621. set mustDepthSortFacets(sort: boolean);
  27622. /**
  27623. * The location (Vector3) where the facet depth sort must be computed from.
  27624. * By default, the active camera position.
  27625. * Used only when facet depth sort is enabled
  27626. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  27627. */
  27628. get facetDepthSortFrom(): Vector3;
  27629. set facetDepthSortFrom(location: Vector3);
  27630. /**
  27631. * gets a boolean indicating if facetData is enabled
  27632. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  27633. */
  27634. get isFacetDataEnabled(): boolean;
  27635. /** @hidden */
  27636. _updateNonUniformScalingState(value: boolean): boolean;
  27637. /**
  27638. * An event triggered when this mesh collides with another one
  27639. */
  27640. onCollideObservable: Observable<AbstractMesh>;
  27641. /** Set a function to call when this mesh collides with another one */
  27642. set onCollide(callback: () => void);
  27643. /**
  27644. * An event triggered when the collision's position changes
  27645. */
  27646. onCollisionPositionChangeObservable: Observable<Vector3>;
  27647. /** Set a function to call when the collision's position changes */
  27648. set onCollisionPositionChange(callback: () => void);
  27649. /**
  27650. * An event triggered when material is changed
  27651. */
  27652. onMaterialChangedObservable: Observable<AbstractMesh>;
  27653. /**
  27654. * Gets or sets the orientation for POV movement & rotation
  27655. */
  27656. definedFacingForward: boolean;
  27657. /** @hidden */
  27658. _occlusionQuery: Nullable<WebGLQuery>;
  27659. /** @hidden */
  27660. _renderingGroup: Nullable<RenderingGroup>;
  27661. /**
  27662. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  27663. */
  27664. get visibility(): number;
  27665. /**
  27666. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  27667. */
  27668. set visibility(value: number);
  27669. /** Gets or sets the alpha index used to sort transparent meshes
  27670. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  27671. */
  27672. alphaIndex: number;
  27673. /**
  27674. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  27675. */
  27676. isVisible: boolean;
  27677. /**
  27678. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  27679. */
  27680. isPickable: boolean;
  27681. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  27682. showSubMeshesBoundingBox: boolean;
  27683. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  27684. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  27685. */
  27686. isBlocker: boolean;
  27687. /**
  27688. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  27689. */
  27690. enablePointerMoveEvents: boolean;
  27691. /**
  27692. * Specifies the rendering group id for this mesh (0 by default)
  27693. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  27694. */
  27695. renderingGroupId: number;
  27696. private _material;
  27697. /** Gets or sets current material */
  27698. get material(): Nullable<Material>;
  27699. set material(value: Nullable<Material>);
  27700. /**
  27701. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  27702. * @see http://doc.babylonjs.com/babylon101/shadows
  27703. */
  27704. get receiveShadows(): boolean;
  27705. set receiveShadows(value: boolean);
  27706. /** Defines color to use when rendering outline */
  27707. outlineColor: Color3;
  27708. /** Define width to use when rendering outline */
  27709. outlineWidth: number;
  27710. /** Defines color to use when rendering overlay */
  27711. overlayColor: Color3;
  27712. /** Defines alpha to use when rendering overlay */
  27713. overlayAlpha: number;
  27714. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  27715. get hasVertexAlpha(): boolean;
  27716. set hasVertexAlpha(value: boolean);
  27717. /** 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) */
  27718. get useVertexColors(): boolean;
  27719. set useVertexColors(value: boolean);
  27720. /**
  27721. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  27722. */
  27723. get computeBonesUsingShaders(): boolean;
  27724. set computeBonesUsingShaders(value: boolean);
  27725. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  27726. get numBoneInfluencers(): number;
  27727. set numBoneInfluencers(value: number);
  27728. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  27729. get applyFog(): boolean;
  27730. set applyFog(value: boolean);
  27731. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  27732. useOctreeForRenderingSelection: boolean;
  27733. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  27734. useOctreeForPicking: boolean;
  27735. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  27736. useOctreeForCollisions: boolean;
  27737. /**
  27738. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  27739. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  27740. */
  27741. get layerMask(): number;
  27742. set layerMask(value: number);
  27743. /**
  27744. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  27745. */
  27746. alwaysSelectAsActiveMesh: boolean;
  27747. /**
  27748. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  27749. */
  27750. doNotSyncBoundingInfo: boolean;
  27751. /**
  27752. * Gets or sets the current action manager
  27753. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  27754. */
  27755. actionManager: Nullable<AbstractActionManager>;
  27756. private _meshCollisionData;
  27757. /**
  27758. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  27759. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27760. */
  27761. ellipsoid: Vector3;
  27762. /**
  27763. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  27764. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27765. */
  27766. ellipsoidOffset: Vector3;
  27767. /**
  27768. * Gets or sets a collision mask used to mask collisions (default is -1).
  27769. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  27770. */
  27771. get collisionMask(): number;
  27772. set collisionMask(mask: number);
  27773. /**
  27774. * Gets or sets the current collision group mask (-1 by default).
  27775. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  27776. */
  27777. get collisionGroup(): number;
  27778. set collisionGroup(mask: number);
  27779. /**
  27780. * Defines edge width used when edgesRenderer is enabled
  27781. * @see https://www.babylonjs-playground.com/#10OJSG#13
  27782. */
  27783. edgesWidth: number;
  27784. /**
  27785. * Defines edge color used when edgesRenderer is enabled
  27786. * @see https://www.babylonjs-playground.com/#10OJSG#13
  27787. */
  27788. edgesColor: Color4;
  27789. /** @hidden */
  27790. _edgesRenderer: Nullable<IEdgesRenderer>;
  27791. /** @hidden */
  27792. _masterMesh: Nullable<AbstractMesh>;
  27793. /** @hidden */
  27794. _boundingInfo: Nullable<BoundingInfo>;
  27795. /** @hidden */
  27796. _renderId: number;
  27797. /**
  27798. * Gets or sets the list of subMeshes
  27799. * @see http://doc.babylonjs.com/how_to/multi_materials
  27800. */
  27801. subMeshes: SubMesh[];
  27802. /** @hidden */
  27803. _intersectionsInProgress: AbstractMesh[];
  27804. /** @hidden */
  27805. _unIndexed: boolean;
  27806. /** @hidden */
  27807. _lightSources: Light[];
  27808. /** Gets the list of lights affecting that mesh */
  27809. get lightSources(): Light[];
  27810. /** @hidden */
  27811. get _positions(): Nullable<Vector3[]>;
  27812. /** @hidden */
  27813. _waitingData: {
  27814. lods: Nullable<any>;
  27815. actions: Nullable<any>;
  27816. freezeWorldMatrix: Nullable<boolean>;
  27817. };
  27818. /** @hidden */
  27819. _bonesTransformMatrices: Nullable<Float32Array>;
  27820. /** @hidden */
  27821. _transformMatrixTexture: Nullable<RawTexture>;
  27822. /**
  27823. * Gets or sets a skeleton to apply skining transformations
  27824. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  27825. */
  27826. set skeleton(value: Nullable<Skeleton>);
  27827. get skeleton(): Nullable<Skeleton>;
  27828. /**
  27829. * An event triggered when the mesh is rebuilt.
  27830. */
  27831. onRebuildObservable: Observable<AbstractMesh>;
  27832. /**
  27833. * Creates a new AbstractMesh
  27834. * @param name defines the name of the mesh
  27835. * @param scene defines the hosting scene
  27836. */
  27837. constructor(name: string, scene?: Nullable<Scene>);
  27838. /**
  27839. * Returns the string "AbstractMesh"
  27840. * @returns "AbstractMesh"
  27841. */
  27842. getClassName(): string;
  27843. /**
  27844. * Gets a string representation of the current mesh
  27845. * @param fullDetails defines a boolean indicating if full details must be included
  27846. * @returns a string representation of the current mesh
  27847. */
  27848. toString(fullDetails?: boolean): string;
  27849. /**
  27850. * @hidden
  27851. */
  27852. protected _getEffectiveParent(): Nullable<Node>;
  27853. /** @hidden */
  27854. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  27855. /** @hidden */
  27856. _rebuild(): void;
  27857. /** @hidden */
  27858. _resyncLightSources(): void;
  27859. /** @hidden */
  27860. _resyncLightSource(light: Light): void;
  27861. /** @hidden */
  27862. _unBindEffect(): void;
  27863. /** @hidden */
  27864. _removeLightSource(light: Light, dispose: boolean): void;
  27865. private _markSubMeshesAsDirty;
  27866. /** @hidden */
  27867. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  27868. /** @hidden */
  27869. _markSubMeshesAsAttributesDirty(): void;
  27870. /** @hidden */
  27871. _markSubMeshesAsMiscDirty(): void;
  27872. /**
  27873. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  27874. */
  27875. get scaling(): Vector3;
  27876. set scaling(newScaling: Vector3);
  27877. /**
  27878. * Returns true if the mesh is blocked. Implemented by child classes
  27879. */
  27880. get isBlocked(): boolean;
  27881. /**
  27882. * Returns the mesh itself by default. Implemented by child classes
  27883. * @param camera defines the camera to use to pick the right LOD level
  27884. * @returns the currentAbstractMesh
  27885. */
  27886. getLOD(camera: Camera): Nullable<AbstractMesh>;
  27887. /**
  27888. * Returns 0 by default. Implemented by child classes
  27889. * @returns an integer
  27890. */
  27891. getTotalVertices(): number;
  27892. /**
  27893. * Returns a positive integer : the total number of indices in this mesh geometry.
  27894. * @returns the numner of indices or zero if the mesh has no geometry.
  27895. */
  27896. getTotalIndices(): number;
  27897. /**
  27898. * Returns null by default. Implemented by child classes
  27899. * @returns null
  27900. */
  27901. getIndices(): Nullable<IndicesArray>;
  27902. /**
  27903. * Returns the array of the requested vertex data kind. Implemented by child classes
  27904. * @param kind defines the vertex data kind to use
  27905. * @returns null
  27906. */
  27907. getVerticesData(kind: string): Nullable<FloatArray>;
  27908. /**
  27909. * Sets the vertex data of the mesh geometry for the requested `kind`.
  27910. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  27911. * Note that a new underlying VertexBuffer object is created each call.
  27912. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  27913. * @param kind defines vertex data kind:
  27914. * * VertexBuffer.PositionKind
  27915. * * VertexBuffer.UVKind
  27916. * * VertexBuffer.UV2Kind
  27917. * * VertexBuffer.UV3Kind
  27918. * * VertexBuffer.UV4Kind
  27919. * * VertexBuffer.UV5Kind
  27920. * * VertexBuffer.UV6Kind
  27921. * * VertexBuffer.ColorKind
  27922. * * VertexBuffer.MatricesIndicesKind
  27923. * * VertexBuffer.MatricesIndicesExtraKind
  27924. * * VertexBuffer.MatricesWeightsKind
  27925. * * VertexBuffer.MatricesWeightsExtraKind
  27926. * @param data defines the data source
  27927. * @param updatable defines if the data must be flagged as updatable (or static)
  27928. * @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
  27929. * @returns the current mesh
  27930. */
  27931. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  27932. /**
  27933. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  27934. * If the mesh has no geometry, it is simply returned as it is.
  27935. * @param kind defines vertex data kind:
  27936. * * VertexBuffer.PositionKind
  27937. * * VertexBuffer.UVKind
  27938. * * VertexBuffer.UV2Kind
  27939. * * VertexBuffer.UV3Kind
  27940. * * VertexBuffer.UV4Kind
  27941. * * VertexBuffer.UV5Kind
  27942. * * VertexBuffer.UV6Kind
  27943. * * VertexBuffer.ColorKind
  27944. * * VertexBuffer.MatricesIndicesKind
  27945. * * VertexBuffer.MatricesIndicesExtraKind
  27946. * * VertexBuffer.MatricesWeightsKind
  27947. * * VertexBuffer.MatricesWeightsExtraKind
  27948. * @param data defines the data source
  27949. * @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
  27950. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  27951. * @returns the current mesh
  27952. */
  27953. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  27954. /**
  27955. * Sets the mesh indices,
  27956. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  27957. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  27958. * @param totalVertices Defines the total number of vertices
  27959. * @returns the current mesh
  27960. */
  27961. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  27962. /**
  27963. * Gets a boolean indicating if specific vertex data is present
  27964. * @param kind defines the vertex data kind to use
  27965. * @returns true is data kind is present
  27966. */
  27967. isVerticesDataPresent(kind: string): boolean;
  27968. /**
  27969. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  27970. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  27971. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  27972. * @returns a BoundingInfo
  27973. */
  27974. getBoundingInfo(): BoundingInfo;
  27975. /**
  27976. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  27977. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  27978. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  27979. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  27980. * @returns the current mesh
  27981. */
  27982. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  27983. /**
  27984. * Overwrite the current bounding info
  27985. * @param boundingInfo defines the new bounding info
  27986. * @returns the current mesh
  27987. */
  27988. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  27989. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  27990. get useBones(): boolean;
  27991. /** @hidden */
  27992. _preActivate(): void;
  27993. /** @hidden */
  27994. _preActivateForIntermediateRendering(renderId: number): void;
  27995. /** @hidden */
  27996. _activate(renderId: number, intermediateRendering: boolean): boolean;
  27997. /** @hidden */
  27998. _postActivate(): void;
  27999. /** @hidden */
  28000. _freeze(): void;
  28001. /** @hidden */
  28002. _unFreeze(): void;
  28003. /**
  28004. * Gets the current world matrix
  28005. * @returns a Matrix
  28006. */
  28007. getWorldMatrix(): Matrix;
  28008. /** @hidden */
  28009. _getWorldMatrixDeterminant(): number;
  28010. /**
  28011. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  28012. */
  28013. get isAnInstance(): boolean;
  28014. /**
  28015. * Gets a boolean indicating if this mesh has instances
  28016. */
  28017. get hasInstances(): boolean;
  28018. /**
  28019. * Perform relative position change from the point of view of behind the front of the mesh.
  28020. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28021. * Supports definition of mesh facing forward or backward
  28022. * @param amountRight defines the distance on the right axis
  28023. * @param amountUp defines the distance on the up axis
  28024. * @param amountForward defines the distance on the forward axis
  28025. * @returns the current mesh
  28026. */
  28027. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  28028. /**
  28029. * Calculate relative position change from the point of view of behind the front of the mesh.
  28030. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28031. * Supports definition of mesh facing forward or backward
  28032. * @param amountRight defines the distance on the right axis
  28033. * @param amountUp defines the distance on the up axis
  28034. * @param amountForward defines the distance on the forward axis
  28035. * @returns the new displacement vector
  28036. */
  28037. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  28038. /**
  28039. * Perform relative rotation change from the point of view of behind the front of the mesh.
  28040. * Supports definition of mesh facing forward or backward
  28041. * @param flipBack defines the flip
  28042. * @param twirlClockwise defines the twirl
  28043. * @param tiltRight defines the tilt
  28044. * @returns the current mesh
  28045. */
  28046. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  28047. /**
  28048. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  28049. * Supports definition of mesh facing forward or backward.
  28050. * @param flipBack defines the flip
  28051. * @param twirlClockwise defines the twirl
  28052. * @param tiltRight defines the tilt
  28053. * @returns the new rotation vector
  28054. */
  28055. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  28056. /**
  28057. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28058. * This means the mesh underlying bounding box and sphere are recomputed.
  28059. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28060. * @returns the current mesh
  28061. */
  28062. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  28063. /** @hidden */
  28064. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  28065. /** @hidden */
  28066. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  28067. /** @hidden */
  28068. _updateBoundingInfo(): AbstractMesh;
  28069. /** @hidden */
  28070. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  28071. /** @hidden */
  28072. protected _afterComputeWorldMatrix(): void;
  28073. /** @hidden */
  28074. get _effectiveMesh(): AbstractMesh;
  28075. /**
  28076. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  28077. * A mesh is in the frustum if its bounding box intersects the frustum
  28078. * @param frustumPlanes defines the frustum to test
  28079. * @returns true if the mesh is in the frustum planes
  28080. */
  28081. isInFrustum(frustumPlanes: Plane[]): boolean;
  28082. /**
  28083. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  28084. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  28085. * @param frustumPlanes defines the frustum to test
  28086. * @returns true if the mesh is completely in the frustum planes
  28087. */
  28088. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  28089. /**
  28090. * True if the mesh intersects another mesh or a SolidParticle object
  28091. * @param mesh defines a target mesh or SolidParticle to test
  28092. * @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)
  28093. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  28094. * @returns true if there is an intersection
  28095. */
  28096. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  28097. /**
  28098. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  28099. * @param point defines the point to test
  28100. * @returns true if there is an intersection
  28101. */
  28102. intersectsPoint(point: Vector3): boolean;
  28103. /**
  28104. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  28105. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28106. */
  28107. get checkCollisions(): boolean;
  28108. set checkCollisions(collisionEnabled: boolean);
  28109. /**
  28110. * Gets Collider object used to compute collisions (not physics)
  28111. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28112. */
  28113. get collider(): Nullable<Collider>;
  28114. /**
  28115. * Move the mesh using collision engine
  28116. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28117. * @param displacement defines the requested displacement vector
  28118. * @returns the current mesh
  28119. */
  28120. moveWithCollisions(displacement: Vector3): AbstractMesh;
  28121. private _onCollisionPositionChange;
  28122. /** @hidden */
  28123. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  28124. /** @hidden */
  28125. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  28126. /** @hidden */
  28127. _checkCollision(collider: Collider): AbstractMesh;
  28128. /** @hidden */
  28129. _generatePointsArray(): boolean;
  28130. /**
  28131. * Checks if the passed Ray intersects with the mesh
  28132. * @param ray defines the ray to use
  28133. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  28134. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  28135. * @returns the picking info
  28136. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  28137. */
  28138. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  28139. /**
  28140. * Clones the current mesh
  28141. * @param name defines the mesh name
  28142. * @param newParent defines the new mesh parent
  28143. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  28144. * @returns the new mesh
  28145. */
  28146. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  28147. /**
  28148. * Disposes all the submeshes of the current meshnp
  28149. * @returns the current mesh
  28150. */
  28151. releaseSubMeshes(): AbstractMesh;
  28152. /**
  28153. * Releases resources associated with this abstract mesh.
  28154. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28155. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28156. */
  28157. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28158. /**
  28159. * Adds the passed mesh as a child to the current mesh
  28160. * @param mesh defines the child mesh
  28161. * @returns the current mesh
  28162. */
  28163. addChild(mesh: AbstractMesh): AbstractMesh;
  28164. /**
  28165. * Removes the passed mesh from the current mesh children list
  28166. * @param mesh defines the child mesh
  28167. * @returns the current mesh
  28168. */
  28169. removeChild(mesh: AbstractMesh): AbstractMesh;
  28170. /** @hidden */
  28171. private _initFacetData;
  28172. /**
  28173. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  28174. * This method can be called within the render loop.
  28175. * 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
  28176. * @returns the current mesh
  28177. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28178. */
  28179. updateFacetData(): AbstractMesh;
  28180. /**
  28181. * Returns the facetLocalNormals array.
  28182. * The normals are expressed in the mesh local spac
  28183. * @returns an array of Vector3
  28184. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28185. */
  28186. getFacetLocalNormals(): Vector3[];
  28187. /**
  28188. * Returns the facetLocalPositions array.
  28189. * The facet positions are expressed in the mesh local space
  28190. * @returns an array of Vector3
  28191. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28192. */
  28193. getFacetLocalPositions(): Vector3[];
  28194. /**
  28195. * Returns the facetLocalPartioning array
  28196. * @returns an array of array of numbers
  28197. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28198. */
  28199. getFacetLocalPartitioning(): number[][];
  28200. /**
  28201. * Returns the i-th facet position in the world system.
  28202. * This method allocates a new Vector3 per call
  28203. * @param i defines the facet index
  28204. * @returns a new Vector3
  28205. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28206. */
  28207. getFacetPosition(i: number): Vector3;
  28208. /**
  28209. * Sets the reference Vector3 with the i-th facet position in the world system
  28210. * @param i defines the facet index
  28211. * @param ref defines the target vector
  28212. * @returns the current mesh
  28213. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28214. */
  28215. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  28216. /**
  28217. * Returns the i-th facet normal in the world system.
  28218. * This method allocates a new Vector3 per call
  28219. * @param i defines the facet index
  28220. * @returns a new Vector3
  28221. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28222. */
  28223. getFacetNormal(i: number): Vector3;
  28224. /**
  28225. * Sets the reference Vector3 with the i-th facet normal in the world system
  28226. * @param i defines the facet index
  28227. * @param ref defines the target vector
  28228. * @returns the current mesh
  28229. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28230. */
  28231. getFacetNormalToRef(i: number, ref: Vector3): this;
  28232. /**
  28233. * 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)
  28234. * @param x defines x coordinate
  28235. * @param y defines y coordinate
  28236. * @param z defines z coordinate
  28237. * @returns the array of facet indexes
  28238. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28239. */
  28240. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  28241. /**
  28242. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  28243. * @param projected sets as the (x,y,z) world projection on the facet
  28244. * @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
  28245. * @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
  28246. * @param x defines x coordinate
  28247. * @param y defines y coordinate
  28248. * @param z defines z coordinate
  28249. * @returns the face index if found (or null instead)
  28250. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28251. */
  28252. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  28253. /**
  28254. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  28255. * @param projected sets as the (x,y,z) local projection on the facet
  28256. * @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
  28257. * @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
  28258. * @param x defines x coordinate
  28259. * @param y defines y coordinate
  28260. * @param z defines z coordinate
  28261. * @returns the face index if found (or null instead)
  28262. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28263. */
  28264. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  28265. /**
  28266. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  28267. * @returns the parameters
  28268. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28269. */
  28270. getFacetDataParameters(): any;
  28271. /**
  28272. * Disables the feature FacetData and frees the related memory
  28273. * @returns the current mesh
  28274. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28275. */
  28276. disableFacetData(): AbstractMesh;
  28277. /**
  28278. * Updates the AbstractMesh indices array
  28279. * @param indices defines the data source
  28280. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  28281. * @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)
  28282. * @returns the current mesh
  28283. */
  28284. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  28285. /**
  28286. * Creates new normals data for the mesh
  28287. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  28288. * @returns the current mesh
  28289. */
  28290. createNormals(updatable: boolean): AbstractMesh;
  28291. /**
  28292. * Align the mesh with a normal
  28293. * @param normal defines the normal to use
  28294. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  28295. * @returns the current mesh
  28296. */
  28297. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  28298. /** @hidden */
  28299. _checkOcclusionQuery(): boolean;
  28300. /**
  28301. * Disables the mesh edge rendering mode
  28302. * @returns the currentAbstractMesh
  28303. */
  28304. disableEdgesRendering(): AbstractMesh;
  28305. /**
  28306. * Enables the edge rendering mode on the mesh.
  28307. * This mode makes the mesh edges visible
  28308. * @param epsilon defines the maximal distance between two angles to detect a face
  28309. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  28310. * @returns the currentAbstractMesh
  28311. * @see https://www.babylonjs-playground.com/#19O9TU#0
  28312. */
  28313. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  28314. }
  28315. }
  28316. declare module BABYLON {
  28317. /**
  28318. * Interface used to define ActionEvent
  28319. */
  28320. export interface IActionEvent {
  28321. /** The mesh or sprite that triggered the action */
  28322. source: any;
  28323. /** The X mouse cursor position at the time of the event */
  28324. pointerX: number;
  28325. /** The Y mouse cursor position at the time of the event */
  28326. pointerY: number;
  28327. /** The mesh that is currently pointed at (can be null) */
  28328. meshUnderPointer: Nullable<AbstractMesh>;
  28329. /** the original (browser) event that triggered the ActionEvent */
  28330. sourceEvent?: any;
  28331. /** additional data for the event */
  28332. additionalData?: any;
  28333. }
  28334. /**
  28335. * ActionEvent is the event being sent when an action is triggered.
  28336. */
  28337. export class ActionEvent implements IActionEvent {
  28338. /** The mesh or sprite that triggered the action */
  28339. source: any;
  28340. /** The X mouse cursor position at the time of the event */
  28341. pointerX: number;
  28342. /** The Y mouse cursor position at the time of the event */
  28343. pointerY: number;
  28344. /** The mesh that is currently pointed at (can be null) */
  28345. meshUnderPointer: Nullable<AbstractMesh>;
  28346. /** the original (browser) event that triggered the ActionEvent */
  28347. sourceEvent?: any;
  28348. /** additional data for the event */
  28349. additionalData?: any;
  28350. /**
  28351. * Creates a new ActionEvent
  28352. * @param source The mesh or sprite that triggered the action
  28353. * @param pointerX The X mouse cursor position at the time of the event
  28354. * @param pointerY The Y mouse cursor position at the time of the event
  28355. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  28356. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  28357. * @param additionalData additional data for the event
  28358. */
  28359. constructor(
  28360. /** The mesh or sprite that triggered the action */
  28361. source: any,
  28362. /** The X mouse cursor position at the time of the event */
  28363. pointerX: number,
  28364. /** The Y mouse cursor position at the time of the event */
  28365. pointerY: number,
  28366. /** The mesh that is currently pointed at (can be null) */
  28367. meshUnderPointer: Nullable<AbstractMesh>,
  28368. /** the original (browser) event that triggered the ActionEvent */
  28369. sourceEvent?: any,
  28370. /** additional data for the event */
  28371. additionalData?: any);
  28372. /**
  28373. * Helper function to auto-create an ActionEvent from a source mesh.
  28374. * @param source The source mesh that triggered the event
  28375. * @param evt The original (browser) event
  28376. * @param additionalData additional data for the event
  28377. * @returns the new ActionEvent
  28378. */
  28379. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  28380. /**
  28381. * Helper function to auto-create an ActionEvent from a source sprite
  28382. * @param source The source sprite that triggered the event
  28383. * @param scene Scene associated with the sprite
  28384. * @param evt The original (browser) event
  28385. * @param additionalData additional data for the event
  28386. * @returns the new ActionEvent
  28387. */
  28388. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  28389. /**
  28390. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  28391. * @param scene the scene where the event occurred
  28392. * @param evt The original (browser) event
  28393. * @returns the new ActionEvent
  28394. */
  28395. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  28396. /**
  28397. * Helper function to auto-create an ActionEvent from a primitive
  28398. * @param prim defines the target primitive
  28399. * @param pointerPos defines the pointer position
  28400. * @param evt The original (browser) event
  28401. * @param additionalData additional data for the event
  28402. * @returns the new ActionEvent
  28403. */
  28404. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  28405. }
  28406. }
  28407. declare module BABYLON {
  28408. /**
  28409. * Abstract class used to decouple action Manager from scene and meshes.
  28410. * Do not instantiate.
  28411. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  28412. */
  28413. export abstract class AbstractActionManager implements IDisposable {
  28414. /** Gets the list of active triggers */
  28415. static Triggers: {
  28416. [key: string]: number;
  28417. };
  28418. /** Gets the cursor to use when hovering items */
  28419. hoverCursor: string;
  28420. /** Gets the list of actions */
  28421. actions: IAction[];
  28422. /**
  28423. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  28424. */
  28425. isRecursive: boolean;
  28426. /**
  28427. * Releases all associated resources
  28428. */
  28429. abstract dispose(): void;
  28430. /**
  28431. * Does this action manager has pointer triggers
  28432. */
  28433. abstract get hasPointerTriggers(): boolean;
  28434. /**
  28435. * Does this action manager has pick triggers
  28436. */
  28437. abstract get hasPickTriggers(): boolean;
  28438. /**
  28439. * Process a specific trigger
  28440. * @param trigger defines the trigger to process
  28441. * @param evt defines the event details to be processed
  28442. */
  28443. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  28444. /**
  28445. * Does this action manager handles actions of any of the given triggers
  28446. * @param triggers defines the triggers to be tested
  28447. * @return a boolean indicating whether one (or more) of the triggers is handled
  28448. */
  28449. abstract hasSpecificTriggers(triggers: number[]): boolean;
  28450. /**
  28451. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  28452. * speed.
  28453. * @param triggerA defines the trigger to be tested
  28454. * @param triggerB defines the trigger to be tested
  28455. * @return a boolean indicating whether one (or more) of the triggers is handled
  28456. */
  28457. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  28458. /**
  28459. * Does this action manager handles actions of a given trigger
  28460. * @param trigger defines the trigger to be tested
  28461. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  28462. * @return whether the trigger is handled
  28463. */
  28464. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  28465. /**
  28466. * Serialize this manager to a JSON object
  28467. * @param name defines the property name to store this manager
  28468. * @returns a JSON representation of this manager
  28469. */
  28470. abstract serialize(name: string): any;
  28471. /**
  28472. * Registers an action to this action manager
  28473. * @param action defines the action to be registered
  28474. * @return the action amended (prepared) after registration
  28475. */
  28476. abstract registerAction(action: IAction): Nullable<IAction>;
  28477. /**
  28478. * Unregisters an action to this action manager
  28479. * @param action defines the action to be unregistered
  28480. * @return a boolean indicating whether the action has been unregistered
  28481. */
  28482. abstract unregisterAction(action: IAction): Boolean;
  28483. /**
  28484. * Does exist one action manager with at least one trigger
  28485. **/
  28486. static get HasTriggers(): boolean;
  28487. /**
  28488. * Does exist one action manager with at least one pick trigger
  28489. **/
  28490. static get HasPickTriggers(): boolean;
  28491. /**
  28492. * Does exist one action manager that handles actions of a given trigger
  28493. * @param trigger defines the trigger to be tested
  28494. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  28495. **/
  28496. static HasSpecificTrigger(trigger: number): boolean;
  28497. }
  28498. }
  28499. declare module BABYLON {
  28500. /**
  28501. * Defines how a node can be built from a string name.
  28502. */
  28503. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  28504. /**
  28505. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  28506. */
  28507. export class Node implements IBehaviorAware<Node> {
  28508. /** @hidden */
  28509. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  28510. private static _NodeConstructors;
  28511. /**
  28512. * Add a new node constructor
  28513. * @param type defines the type name of the node to construct
  28514. * @param constructorFunc defines the constructor function
  28515. */
  28516. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  28517. /**
  28518. * Returns a node constructor based on type name
  28519. * @param type defines the type name
  28520. * @param name defines the new node name
  28521. * @param scene defines the hosting scene
  28522. * @param options defines optional options to transmit to constructors
  28523. * @returns the new constructor or null
  28524. */
  28525. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  28526. /**
  28527. * Gets or sets the name of the node
  28528. */
  28529. name: string;
  28530. /**
  28531. * Gets or sets the id of the node
  28532. */
  28533. id: string;
  28534. /**
  28535. * Gets or sets the unique id of the node
  28536. */
  28537. uniqueId: number;
  28538. /**
  28539. * Gets or sets a string used to store user defined state for the node
  28540. */
  28541. state: string;
  28542. /**
  28543. * Gets or sets an object used to store user defined information for the node
  28544. */
  28545. metadata: any;
  28546. /**
  28547. * For internal use only. Please do not use.
  28548. */
  28549. reservedDataStore: any;
  28550. /**
  28551. * List of inspectable custom properties (used by the Inspector)
  28552. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  28553. */
  28554. inspectableCustomProperties: IInspectable[];
  28555. private _doNotSerialize;
  28556. /**
  28557. * Gets or sets a boolean used to define if the node must be serialized
  28558. */
  28559. get doNotSerialize(): boolean;
  28560. set doNotSerialize(value: boolean);
  28561. /** @hidden */
  28562. _isDisposed: boolean;
  28563. /**
  28564. * Gets a list of Animations associated with the node
  28565. */
  28566. animations: Animation[];
  28567. protected _ranges: {
  28568. [name: string]: Nullable<AnimationRange>;
  28569. };
  28570. /**
  28571. * Callback raised when the node is ready to be used
  28572. */
  28573. onReady: Nullable<(node: Node) => void>;
  28574. private _isEnabled;
  28575. private _isParentEnabled;
  28576. private _isReady;
  28577. /** @hidden */
  28578. _currentRenderId: number;
  28579. private _parentUpdateId;
  28580. /** @hidden */
  28581. _childUpdateId: number;
  28582. /** @hidden */
  28583. _waitingParentId: Nullable<string>;
  28584. /** @hidden */
  28585. _scene: Scene;
  28586. /** @hidden */
  28587. _cache: any;
  28588. private _parentNode;
  28589. private _children;
  28590. /** @hidden */
  28591. _worldMatrix: Matrix;
  28592. /** @hidden */
  28593. _worldMatrixDeterminant: number;
  28594. /** @hidden */
  28595. _worldMatrixDeterminantIsDirty: boolean;
  28596. /** @hidden */
  28597. private _sceneRootNodesIndex;
  28598. /**
  28599. * Gets a boolean indicating if the node has been disposed
  28600. * @returns true if the node was disposed
  28601. */
  28602. isDisposed(): boolean;
  28603. /**
  28604. * Gets or sets the parent of the node (without keeping the current position in the scene)
  28605. * @see https://doc.babylonjs.com/how_to/parenting
  28606. */
  28607. set parent(parent: Nullable<Node>);
  28608. get parent(): Nullable<Node>;
  28609. /** @hidden */
  28610. _addToSceneRootNodes(): void;
  28611. /** @hidden */
  28612. _removeFromSceneRootNodes(): void;
  28613. private _animationPropertiesOverride;
  28614. /**
  28615. * Gets or sets the animation properties override
  28616. */
  28617. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  28618. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  28619. /**
  28620. * Gets a string idenfifying the name of the class
  28621. * @returns "Node" string
  28622. */
  28623. getClassName(): string;
  28624. /** @hidden */
  28625. readonly _isNode: boolean;
  28626. /**
  28627. * An event triggered when the mesh is disposed
  28628. */
  28629. onDisposeObservable: Observable<Node>;
  28630. private _onDisposeObserver;
  28631. /**
  28632. * Sets a callback that will be raised when the node will be disposed
  28633. */
  28634. set onDispose(callback: () => void);
  28635. /**
  28636. * Creates a new Node
  28637. * @param name the name and id to be given to this node
  28638. * @param scene the scene this node will be added to
  28639. */
  28640. constructor(name: string, scene?: Nullable<Scene>);
  28641. /**
  28642. * Gets the scene of the node
  28643. * @returns a scene
  28644. */
  28645. getScene(): Scene;
  28646. /**
  28647. * Gets the engine of the node
  28648. * @returns a Engine
  28649. */
  28650. getEngine(): Engine;
  28651. private _behaviors;
  28652. /**
  28653. * Attach a behavior to the node
  28654. * @see http://doc.babylonjs.com/features/behaviour
  28655. * @param behavior defines the behavior to attach
  28656. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  28657. * @returns the current Node
  28658. */
  28659. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  28660. /**
  28661. * Remove an attached behavior
  28662. * @see http://doc.babylonjs.com/features/behaviour
  28663. * @param behavior defines the behavior to attach
  28664. * @returns the current Node
  28665. */
  28666. removeBehavior(behavior: Behavior<Node>): Node;
  28667. /**
  28668. * Gets the list of attached behaviors
  28669. * @see http://doc.babylonjs.com/features/behaviour
  28670. */
  28671. get behaviors(): Behavior<Node>[];
  28672. /**
  28673. * Gets an attached behavior by name
  28674. * @param name defines the name of the behavior to look for
  28675. * @see http://doc.babylonjs.com/features/behaviour
  28676. * @returns null if behavior was not found else the requested behavior
  28677. */
  28678. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  28679. /**
  28680. * Returns the latest update of the World matrix
  28681. * @returns a Matrix
  28682. */
  28683. getWorldMatrix(): Matrix;
  28684. /** @hidden */
  28685. _getWorldMatrixDeterminant(): number;
  28686. /**
  28687. * Returns directly the latest state of the mesh World matrix.
  28688. * A Matrix is returned.
  28689. */
  28690. get worldMatrixFromCache(): Matrix;
  28691. /** @hidden */
  28692. _initCache(): void;
  28693. /** @hidden */
  28694. updateCache(force?: boolean): void;
  28695. /** @hidden */
  28696. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  28697. /** @hidden */
  28698. _updateCache(ignoreParentClass?: boolean): void;
  28699. /** @hidden */
  28700. _isSynchronized(): boolean;
  28701. /** @hidden */
  28702. _markSyncedWithParent(): void;
  28703. /** @hidden */
  28704. isSynchronizedWithParent(): boolean;
  28705. /** @hidden */
  28706. isSynchronized(): boolean;
  28707. /**
  28708. * Is this node ready to be used/rendered
  28709. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  28710. * @return true if the node is ready
  28711. */
  28712. isReady(completeCheck?: boolean): boolean;
  28713. /**
  28714. * Is this node enabled?
  28715. * 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
  28716. * @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
  28717. * @return whether this node (and its parent) is enabled
  28718. */
  28719. isEnabled(checkAncestors?: boolean): boolean;
  28720. /** @hidden */
  28721. protected _syncParentEnabledState(): void;
  28722. /**
  28723. * Set the enabled state of this node
  28724. * @param value defines the new enabled state
  28725. */
  28726. setEnabled(value: boolean): void;
  28727. /**
  28728. * Is this node a descendant of the given node?
  28729. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  28730. * @param ancestor defines the parent node to inspect
  28731. * @returns a boolean indicating if this node is a descendant of the given node
  28732. */
  28733. isDescendantOf(ancestor: Node): boolean;
  28734. /** @hidden */
  28735. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  28736. /**
  28737. * Will return all nodes that have this node as ascendant
  28738. * @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
  28739. * @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
  28740. * @return all children nodes of all types
  28741. */
  28742. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  28743. /**
  28744. * Get all child-meshes of this node
  28745. * @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)
  28746. * @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
  28747. * @returns an array of AbstractMesh
  28748. */
  28749. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  28750. /**
  28751. * Get all direct children of this node
  28752. * @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
  28753. * @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)
  28754. * @returns an array of Node
  28755. */
  28756. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  28757. /** @hidden */
  28758. _setReady(state: boolean): void;
  28759. /**
  28760. * Get an animation by name
  28761. * @param name defines the name of the animation to look for
  28762. * @returns null if not found else the requested animation
  28763. */
  28764. getAnimationByName(name: string): Nullable<Animation>;
  28765. /**
  28766. * Creates an animation range for this node
  28767. * @param name defines the name of the range
  28768. * @param from defines the starting key
  28769. * @param to defines the end key
  28770. */
  28771. createAnimationRange(name: string, from: number, to: number): void;
  28772. /**
  28773. * Delete a specific animation range
  28774. * @param name defines the name of the range to delete
  28775. * @param deleteFrames defines if animation frames from the range must be deleted as well
  28776. */
  28777. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  28778. /**
  28779. * Get an animation range by name
  28780. * @param name defines the name of the animation range to look for
  28781. * @returns null if not found else the requested animation range
  28782. */
  28783. getAnimationRange(name: string): Nullable<AnimationRange>;
  28784. /**
  28785. * Gets the list of all animation ranges defined on this node
  28786. * @returns an array
  28787. */
  28788. getAnimationRanges(): Nullable<AnimationRange>[];
  28789. /**
  28790. * Will start the animation sequence
  28791. * @param name defines the range frames for animation sequence
  28792. * @param loop defines if the animation should loop (false by default)
  28793. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  28794. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  28795. * @returns the object created for this animation. If range does not exist, it will return null
  28796. */
  28797. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  28798. /**
  28799. * Serialize animation ranges into a JSON compatible object
  28800. * @returns serialization object
  28801. */
  28802. serializeAnimationRanges(): any;
  28803. /**
  28804. * Computes the world matrix of the node
  28805. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  28806. * @returns the world matrix
  28807. */
  28808. computeWorldMatrix(force?: boolean): Matrix;
  28809. /**
  28810. * Releases resources associated with this node.
  28811. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28812. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28813. */
  28814. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28815. /**
  28816. * Parse animation range data from a serialization object and store them into a given node
  28817. * @param node defines where to store the animation ranges
  28818. * @param parsedNode defines the serialization object to read data from
  28819. * @param scene defines the hosting scene
  28820. */
  28821. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  28822. /**
  28823. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  28824. * @param includeDescendants Include bounding info from descendants as well (true by default)
  28825. * @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
  28826. * @returns the new bounding vectors
  28827. */
  28828. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  28829. min: Vector3;
  28830. max: Vector3;
  28831. };
  28832. }
  28833. }
  28834. declare module BABYLON {
  28835. /**
  28836. * @hidden
  28837. */
  28838. export class _IAnimationState {
  28839. key: number;
  28840. repeatCount: number;
  28841. workValue?: any;
  28842. loopMode?: number;
  28843. offsetValue?: any;
  28844. highLimitValue?: any;
  28845. }
  28846. /**
  28847. * Class used to store any kind of animation
  28848. */
  28849. export class Animation {
  28850. /**Name of the animation */
  28851. name: string;
  28852. /**Property to animate */
  28853. targetProperty: string;
  28854. /**The frames per second of the animation */
  28855. framePerSecond: number;
  28856. /**The data type of the animation */
  28857. dataType: number;
  28858. /**The loop mode of the animation */
  28859. loopMode?: number | undefined;
  28860. /**Specifies if blending should be enabled */
  28861. enableBlending?: boolean | undefined;
  28862. /**
  28863. * Use matrix interpolation instead of using direct key value when animating matrices
  28864. */
  28865. static AllowMatricesInterpolation: boolean;
  28866. /**
  28867. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  28868. */
  28869. static AllowMatrixDecomposeForInterpolation: boolean;
  28870. /**
  28871. * Stores the key frames of the animation
  28872. */
  28873. private _keys;
  28874. /**
  28875. * Stores the easing function of the animation
  28876. */
  28877. private _easingFunction;
  28878. /**
  28879. * @hidden Internal use only
  28880. */
  28881. _runtimeAnimations: RuntimeAnimation[];
  28882. /**
  28883. * The set of event that will be linked to this animation
  28884. */
  28885. private _events;
  28886. /**
  28887. * Stores an array of target property paths
  28888. */
  28889. targetPropertyPath: string[];
  28890. /**
  28891. * Stores the blending speed of the animation
  28892. */
  28893. blendingSpeed: number;
  28894. /**
  28895. * Stores the animation ranges for the animation
  28896. */
  28897. private _ranges;
  28898. /**
  28899. * @hidden Internal use
  28900. */
  28901. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  28902. /**
  28903. * Sets up an animation
  28904. * @param property The property to animate
  28905. * @param animationType The animation type to apply
  28906. * @param framePerSecond The frames per second of the animation
  28907. * @param easingFunction The easing function used in the animation
  28908. * @returns The created animation
  28909. */
  28910. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  28911. /**
  28912. * Create and start an animation on a node
  28913. * @param name defines the name of the global animation that will be run on all nodes
  28914. * @param node defines the root node where the animation will take place
  28915. * @param targetProperty defines property to animate
  28916. * @param framePerSecond defines the number of frame per second yo use
  28917. * @param totalFrame defines the number of frames in total
  28918. * @param from defines the initial value
  28919. * @param to defines the final value
  28920. * @param loopMode defines which loop mode you want to use (off by default)
  28921. * @param easingFunction defines the easing function to use (linear by default)
  28922. * @param onAnimationEnd defines the callback to call when animation end
  28923. * @returns the animatable created for this animation
  28924. */
  28925. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  28926. /**
  28927. * Create and start an animation on a node and its descendants
  28928. * @param name defines the name of the global animation that will be run on all nodes
  28929. * @param node defines the root node where the animation will take place
  28930. * @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
  28931. * @param targetProperty defines property to animate
  28932. * @param framePerSecond defines the number of frame per second to use
  28933. * @param totalFrame defines the number of frames in total
  28934. * @param from defines the initial value
  28935. * @param to defines the final value
  28936. * @param loopMode defines which loop mode you want to use (off by default)
  28937. * @param easingFunction defines the easing function to use (linear by default)
  28938. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  28939. * @returns the list of animatables created for all nodes
  28940. * @example https://www.babylonjs-playground.com/#MH0VLI
  28941. */
  28942. 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[]>;
  28943. /**
  28944. * Creates a new animation, merges it with the existing animations and starts it
  28945. * @param name Name of the animation
  28946. * @param node Node which contains the scene that begins the animations
  28947. * @param targetProperty Specifies which property to animate
  28948. * @param framePerSecond The frames per second of the animation
  28949. * @param totalFrame The total number of frames
  28950. * @param from The frame at the beginning of the animation
  28951. * @param to The frame at the end of the animation
  28952. * @param loopMode Specifies the loop mode of the animation
  28953. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  28954. * @param onAnimationEnd Callback to run once the animation is complete
  28955. * @returns Nullable animation
  28956. */
  28957. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  28958. /**
  28959. * Transition property of an host to the target Value
  28960. * @param property The property to transition
  28961. * @param targetValue The target Value of the property
  28962. * @param host The object where the property to animate belongs
  28963. * @param scene Scene used to run the animation
  28964. * @param frameRate Framerate (in frame/s) to use
  28965. * @param transition The transition type we want to use
  28966. * @param duration The duration of the animation, in milliseconds
  28967. * @param onAnimationEnd Callback trigger at the end of the animation
  28968. * @returns Nullable animation
  28969. */
  28970. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  28971. /**
  28972. * Return the array of runtime animations currently using this animation
  28973. */
  28974. get runtimeAnimations(): RuntimeAnimation[];
  28975. /**
  28976. * Specifies if any of the runtime animations are currently running
  28977. */
  28978. get hasRunningRuntimeAnimations(): boolean;
  28979. /**
  28980. * Initializes the animation
  28981. * @param name Name of the animation
  28982. * @param targetProperty Property to animate
  28983. * @param framePerSecond The frames per second of the animation
  28984. * @param dataType The data type of the animation
  28985. * @param loopMode The loop mode of the animation
  28986. * @param enableBlending Specifies if blending should be enabled
  28987. */
  28988. constructor(
  28989. /**Name of the animation */
  28990. name: string,
  28991. /**Property to animate */
  28992. targetProperty: string,
  28993. /**The frames per second of the animation */
  28994. framePerSecond: number,
  28995. /**The data type of the animation */
  28996. dataType: number,
  28997. /**The loop mode of the animation */
  28998. loopMode?: number | undefined,
  28999. /**Specifies if blending should be enabled */
  29000. enableBlending?: boolean | undefined);
  29001. /**
  29002. * Converts the animation to a string
  29003. * @param fullDetails support for multiple levels of logging within scene loading
  29004. * @returns String form of the animation
  29005. */
  29006. toString(fullDetails?: boolean): string;
  29007. /**
  29008. * Add an event to this animation
  29009. * @param event Event to add
  29010. */
  29011. addEvent(event: AnimationEvent): void;
  29012. /**
  29013. * Remove all events found at the given frame
  29014. * @param frame The frame to remove events from
  29015. */
  29016. removeEvents(frame: number): void;
  29017. /**
  29018. * Retrieves all the events from the animation
  29019. * @returns Events from the animation
  29020. */
  29021. getEvents(): AnimationEvent[];
  29022. /**
  29023. * Creates an animation range
  29024. * @param name Name of the animation range
  29025. * @param from Starting frame of the animation range
  29026. * @param to Ending frame of the animation
  29027. */
  29028. createRange(name: string, from: number, to: number): void;
  29029. /**
  29030. * Deletes an animation range by name
  29031. * @param name Name of the animation range to delete
  29032. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  29033. */
  29034. deleteRange(name: string, deleteFrames?: boolean): void;
  29035. /**
  29036. * Gets the animation range by name, or null if not defined
  29037. * @param name Name of the animation range
  29038. * @returns Nullable animation range
  29039. */
  29040. getRange(name: string): Nullable<AnimationRange>;
  29041. /**
  29042. * Gets the key frames from the animation
  29043. * @returns The key frames of the animation
  29044. */
  29045. getKeys(): Array<IAnimationKey>;
  29046. /**
  29047. * Gets the highest frame rate of the animation
  29048. * @returns Highest frame rate of the animation
  29049. */
  29050. getHighestFrame(): number;
  29051. /**
  29052. * Gets the easing function of the animation
  29053. * @returns Easing function of the animation
  29054. */
  29055. getEasingFunction(): IEasingFunction;
  29056. /**
  29057. * Sets the easing function of the animation
  29058. * @param easingFunction A custom mathematical formula for animation
  29059. */
  29060. setEasingFunction(easingFunction: EasingFunction): void;
  29061. /**
  29062. * Interpolates a scalar linearly
  29063. * @param startValue Start value of the animation curve
  29064. * @param endValue End value of the animation curve
  29065. * @param gradient Scalar amount to interpolate
  29066. * @returns Interpolated scalar value
  29067. */
  29068. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  29069. /**
  29070. * Interpolates a scalar cubically
  29071. * @param startValue Start value of the animation curve
  29072. * @param outTangent End tangent of the animation
  29073. * @param endValue End value of the animation curve
  29074. * @param inTangent Start tangent of the animation curve
  29075. * @param gradient Scalar amount to interpolate
  29076. * @returns Interpolated scalar value
  29077. */
  29078. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  29079. /**
  29080. * Interpolates a quaternion using a spherical linear interpolation
  29081. * @param startValue Start value of the animation curve
  29082. * @param endValue End value of the animation curve
  29083. * @param gradient Scalar amount to interpolate
  29084. * @returns Interpolated quaternion value
  29085. */
  29086. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  29087. /**
  29088. * Interpolates a quaternion cubically
  29089. * @param startValue Start value of the animation curve
  29090. * @param outTangent End tangent of the animation curve
  29091. * @param endValue End value of the animation curve
  29092. * @param inTangent Start tangent of the animation curve
  29093. * @param gradient Scalar amount to interpolate
  29094. * @returns Interpolated quaternion value
  29095. */
  29096. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  29097. /**
  29098. * Interpolates a Vector3 linearl
  29099. * @param startValue Start value of the animation curve
  29100. * @param endValue End value of the animation curve
  29101. * @param gradient Scalar amount to interpolate
  29102. * @returns Interpolated scalar value
  29103. */
  29104. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  29105. /**
  29106. * Interpolates a Vector3 cubically
  29107. * @param startValue Start value of the animation curve
  29108. * @param outTangent End tangent of the animation
  29109. * @param endValue End value of the animation curve
  29110. * @param inTangent Start tangent of the animation curve
  29111. * @param gradient Scalar amount to interpolate
  29112. * @returns InterpolatedVector3 value
  29113. */
  29114. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  29115. /**
  29116. * Interpolates a Vector2 linearly
  29117. * @param startValue Start value of the animation curve
  29118. * @param endValue End value of the animation curve
  29119. * @param gradient Scalar amount to interpolate
  29120. * @returns Interpolated Vector2 value
  29121. */
  29122. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  29123. /**
  29124. * Interpolates a Vector2 cubically
  29125. * @param startValue Start value of the animation curve
  29126. * @param outTangent End tangent of the animation
  29127. * @param endValue End value of the animation curve
  29128. * @param inTangent Start tangent of the animation curve
  29129. * @param gradient Scalar amount to interpolate
  29130. * @returns Interpolated Vector2 value
  29131. */
  29132. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  29133. /**
  29134. * Interpolates a size linearly
  29135. * @param startValue Start value of the animation curve
  29136. * @param endValue End value of the animation curve
  29137. * @param gradient Scalar amount to interpolate
  29138. * @returns Interpolated Size value
  29139. */
  29140. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  29141. /**
  29142. * Interpolates a Color3 linearly
  29143. * @param startValue Start value of the animation curve
  29144. * @param endValue End value of the animation curve
  29145. * @param gradient Scalar amount to interpolate
  29146. * @returns Interpolated Color3 value
  29147. */
  29148. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  29149. /**
  29150. * Interpolates a Color4 linearly
  29151. * @param startValue Start value of the animation curve
  29152. * @param endValue End value of the animation curve
  29153. * @param gradient Scalar amount to interpolate
  29154. * @returns Interpolated Color3 value
  29155. */
  29156. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  29157. /**
  29158. * @hidden Internal use only
  29159. */
  29160. _getKeyValue(value: any): any;
  29161. /**
  29162. * @hidden Internal use only
  29163. */
  29164. _interpolate(currentFrame: number, state: _IAnimationState): any;
  29165. /**
  29166. * Defines the function to use to interpolate matrices
  29167. * @param startValue defines the start matrix
  29168. * @param endValue defines the end matrix
  29169. * @param gradient defines the gradient between both matrices
  29170. * @param result defines an optional target matrix where to store the interpolation
  29171. * @returns the interpolated matrix
  29172. */
  29173. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  29174. /**
  29175. * Makes a copy of the animation
  29176. * @returns Cloned animation
  29177. */
  29178. clone(): Animation;
  29179. /**
  29180. * Sets the key frames of the animation
  29181. * @param values The animation key frames to set
  29182. */
  29183. setKeys(values: Array<IAnimationKey>): void;
  29184. /**
  29185. * Serializes the animation to an object
  29186. * @returns Serialized object
  29187. */
  29188. serialize(): any;
  29189. /**
  29190. * Float animation type
  29191. */
  29192. static readonly ANIMATIONTYPE_FLOAT: number;
  29193. /**
  29194. * Vector3 animation type
  29195. */
  29196. static readonly ANIMATIONTYPE_VECTOR3: number;
  29197. /**
  29198. * Quaternion animation type
  29199. */
  29200. static readonly ANIMATIONTYPE_QUATERNION: number;
  29201. /**
  29202. * Matrix animation type
  29203. */
  29204. static readonly ANIMATIONTYPE_MATRIX: number;
  29205. /**
  29206. * Color3 animation type
  29207. */
  29208. static readonly ANIMATIONTYPE_COLOR3: number;
  29209. /**
  29210. * Color3 animation type
  29211. */
  29212. static readonly ANIMATIONTYPE_COLOR4: number;
  29213. /**
  29214. * Vector2 animation type
  29215. */
  29216. static readonly ANIMATIONTYPE_VECTOR2: number;
  29217. /**
  29218. * Size animation type
  29219. */
  29220. static readonly ANIMATIONTYPE_SIZE: number;
  29221. /**
  29222. * Relative Loop Mode
  29223. */
  29224. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  29225. /**
  29226. * Cycle Loop Mode
  29227. */
  29228. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  29229. /**
  29230. * Constant Loop Mode
  29231. */
  29232. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  29233. /** @hidden */
  29234. static _UniversalLerp(left: any, right: any, amount: number): any;
  29235. /**
  29236. * Parses an animation object and creates an animation
  29237. * @param parsedAnimation Parsed animation object
  29238. * @returns Animation object
  29239. */
  29240. static Parse(parsedAnimation: any): Animation;
  29241. /**
  29242. * Appends the serialized animations from the source animations
  29243. * @param source Source containing the animations
  29244. * @param destination Target to store the animations
  29245. */
  29246. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29247. }
  29248. }
  29249. declare module BABYLON {
  29250. /**
  29251. * Interface containing an array of animations
  29252. */
  29253. export interface IAnimatable {
  29254. /**
  29255. * Array of animations
  29256. */
  29257. animations: Nullable<Array<Animation>>;
  29258. }
  29259. }
  29260. declare module BABYLON {
  29261. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  29262. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29263. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29264. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29265. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29266. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29267. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29268. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29269. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29270. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29271. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29272. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29273. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29274. /**
  29275. * Decorator used to define property that can be serialized as reference to a camera
  29276. * @param sourceName defines the name of the property to decorate
  29277. */
  29278. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29279. /**
  29280. * Class used to help serialization objects
  29281. */
  29282. export class SerializationHelper {
  29283. /** @hidden */
  29284. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  29285. /** @hidden */
  29286. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  29287. /** @hidden */
  29288. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  29289. /** @hidden */
  29290. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  29291. /**
  29292. * Appends the serialized animations from the source animations
  29293. * @param source Source containing the animations
  29294. * @param destination Target to store the animations
  29295. */
  29296. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29297. /**
  29298. * Static function used to serialized a specific entity
  29299. * @param entity defines the entity to serialize
  29300. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  29301. * @returns a JSON compatible object representing the serialization of the entity
  29302. */
  29303. static Serialize<T>(entity: T, serializationObject?: any): any;
  29304. /**
  29305. * Creates a new entity from a serialization data object
  29306. * @param creationFunction defines a function used to instanciated the new entity
  29307. * @param source defines the source serialization data
  29308. * @param scene defines the hosting scene
  29309. * @param rootUrl defines the root url for resources
  29310. * @returns a new entity
  29311. */
  29312. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  29313. /**
  29314. * Clones an object
  29315. * @param creationFunction defines the function used to instanciate the new object
  29316. * @param source defines the source object
  29317. * @returns the cloned object
  29318. */
  29319. static Clone<T>(creationFunction: () => T, source: T): T;
  29320. /**
  29321. * Instanciates a new object based on a source one (some data will be shared between both object)
  29322. * @param creationFunction defines the function used to instanciate the new object
  29323. * @param source defines the source object
  29324. * @returns the new object
  29325. */
  29326. static Instanciate<T>(creationFunction: () => T, source: T): T;
  29327. }
  29328. }
  29329. declare module BABYLON {
  29330. /**
  29331. * Class used to manipulate GUIDs
  29332. */
  29333. export class GUID {
  29334. /**
  29335. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  29336. * Be aware Math.random() could cause collisions, but:
  29337. * "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"
  29338. * @returns a pseudo random id
  29339. */
  29340. static RandomId(): string;
  29341. }
  29342. }
  29343. declare module BABYLON {
  29344. /**
  29345. * Base class of all the textures in babylon.
  29346. * It groups all the common properties the materials, post process, lights... might need
  29347. * in order to make a correct use of the texture.
  29348. */
  29349. export class BaseTexture implements IAnimatable {
  29350. /**
  29351. * Default anisotropic filtering level for the application.
  29352. * It is set to 4 as a good tradeoff between perf and quality.
  29353. */
  29354. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  29355. /**
  29356. * Gets or sets the unique id of the texture
  29357. */
  29358. uniqueId: number;
  29359. /**
  29360. * Define the name of the texture.
  29361. */
  29362. name: string;
  29363. /**
  29364. * Gets or sets an object used to store user defined information.
  29365. */
  29366. metadata: any;
  29367. /**
  29368. * For internal use only. Please do not use.
  29369. */
  29370. reservedDataStore: any;
  29371. private _hasAlpha;
  29372. /**
  29373. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  29374. */
  29375. set hasAlpha(value: boolean);
  29376. get hasAlpha(): boolean;
  29377. /**
  29378. * Defines if the alpha value should be determined via the rgb values.
  29379. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  29380. */
  29381. getAlphaFromRGB: boolean;
  29382. /**
  29383. * Intensity or strength of the texture.
  29384. * It is commonly used by materials to fine tune the intensity of the texture
  29385. */
  29386. level: number;
  29387. /**
  29388. * Define the UV chanel to use starting from 0 and defaulting to 0.
  29389. * This is part of the texture as textures usually maps to one uv set.
  29390. */
  29391. coordinatesIndex: number;
  29392. private _coordinatesMode;
  29393. /**
  29394. * How a texture is mapped.
  29395. *
  29396. * | Value | Type | Description |
  29397. * | ----- | ----------------------------------- | ----------- |
  29398. * | 0 | EXPLICIT_MODE | |
  29399. * | 1 | SPHERICAL_MODE | |
  29400. * | 2 | PLANAR_MODE | |
  29401. * | 3 | CUBIC_MODE | |
  29402. * | 4 | PROJECTION_MODE | |
  29403. * | 5 | SKYBOX_MODE | |
  29404. * | 6 | INVCUBIC_MODE | |
  29405. * | 7 | EQUIRECTANGULAR_MODE | |
  29406. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  29407. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  29408. */
  29409. set coordinatesMode(value: number);
  29410. get coordinatesMode(): number;
  29411. /**
  29412. * | Value | Type | Description |
  29413. * | ----- | ------------------ | ----------- |
  29414. * | 0 | CLAMP_ADDRESSMODE | |
  29415. * | 1 | WRAP_ADDRESSMODE | |
  29416. * | 2 | MIRROR_ADDRESSMODE | |
  29417. */
  29418. wrapU: number;
  29419. /**
  29420. * | Value | Type | Description |
  29421. * | ----- | ------------------ | ----------- |
  29422. * | 0 | CLAMP_ADDRESSMODE | |
  29423. * | 1 | WRAP_ADDRESSMODE | |
  29424. * | 2 | MIRROR_ADDRESSMODE | |
  29425. */
  29426. wrapV: number;
  29427. /**
  29428. * | Value | Type | Description |
  29429. * | ----- | ------------------ | ----------- |
  29430. * | 0 | CLAMP_ADDRESSMODE | |
  29431. * | 1 | WRAP_ADDRESSMODE | |
  29432. * | 2 | MIRROR_ADDRESSMODE | |
  29433. */
  29434. wrapR: number;
  29435. /**
  29436. * With compliant hardware and browser (supporting anisotropic filtering)
  29437. * this defines the level of anisotropic filtering in the texture.
  29438. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  29439. */
  29440. anisotropicFilteringLevel: number;
  29441. /**
  29442. * Define if the texture is a cube texture or if false a 2d texture.
  29443. */
  29444. get isCube(): boolean;
  29445. set isCube(value: boolean);
  29446. /**
  29447. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  29448. */
  29449. get is3D(): boolean;
  29450. set is3D(value: boolean);
  29451. /**
  29452. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  29453. */
  29454. get is2DArray(): boolean;
  29455. set is2DArray(value: boolean);
  29456. /**
  29457. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  29458. * HDR texture are usually stored in linear space.
  29459. * This only impacts the PBR and Background materials
  29460. */
  29461. gammaSpace: boolean;
  29462. /**
  29463. * Gets or sets whether or not the texture contains RGBD data.
  29464. */
  29465. get isRGBD(): boolean;
  29466. set isRGBD(value: boolean);
  29467. /**
  29468. * Is Z inverted in the texture (useful in a cube texture).
  29469. */
  29470. invertZ: boolean;
  29471. /**
  29472. * Are mip maps generated for this texture or not.
  29473. */
  29474. get noMipmap(): boolean;
  29475. /**
  29476. * @hidden
  29477. */
  29478. lodLevelInAlpha: boolean;
  29479. /**
  29480. * With prefiltered texture, defined the offset used during the prefiltering steps.
  29481. */
  29482. get lodGenerationOffset(): number;
  29483. set lodGenerationOffset(value: number);
  29484. /**
  29485. * With prefiltered texture, defined the scale used during the prefiltering steps.
  29486. */
  29487. get lodGenerationScale(): number;
  29488. set lodGenerationScale(value: number);
  29489. /**
  29490. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  29491. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  29492. * average roughness values.
  29493. */
  29494. get linearSpecularLOD(): boolean;
  29495. set linearSpecularLOD(value: boolean);
  29496. /**
  29497. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  29498. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  29499. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  29500. */
  29501. get irradianceTexture(): Nullable<BaseTexture>;
  29502. set irradianceTexture(value: Nullable<BaseTexture>);
  29503. /**
  29504. * Define if the texture is a render target.
  29505. */
  29506. isRenderTarget: boolean;
  29507. /**
  29508. * Define the unique id of the texture in the scene.
  29509. */
  29510. get uid(): string;
  29511. /**
  29512. * Return a string representation of the texture.
  29513. * @returns the texture as a string
  29514. */
  29515. toString(): string;
  29516. /**
  29517. * Get the class name of the texture.
  29518. * @returns "BaseTexture"
  29519. */
  29520. getClassName(): string;
  29521. /**
  29522. * Define the list of animation attached to the texture.
  29523. */
  29524. animations: Animation[];
  29525. /**
  29526. * An event triggered when the texture is disposed.
  29527. */
  29528. onDisposeObservable: Observable<BaseTexture>;
  29529. private _onDisposeObserver;
  29530. /**
  29531. * Callback triggered when the texture has been disposed.
  29532. * Kept for back compatibility, you can use the onDisposeObservable instead.
  29533. */
  29534. set onDispose(callback: () => void);
  29535. /**
  29536. * Define the current state of the loading sequence when in delayed load mode.
  29537. */
  29538. delayLoadState: number;
  29539. private _scene;
  29540. /** @hidden */
  29541. _texture: Nullable<InternalTexture>;
  29542. private _uid;
  29543. /**
  29544. * Define if the texture is preventinga material to render or not.
  29545. * If not and the texture is not ready, the engine will use a default black texture instead.
  29546. */
  29547. get isBlocking(): boolean;
  29548. /**
  29549. * Instantiates a new BaseTexture.
  29550. * Base class of all the textures in babylon.
  29551. * It groups all the common properties the materials, post process, lights... might need
  29552. * in order to make a correct use of the texture.
  29553. * @param scene Define the scene the texture blongs to
  29554. */
  29555. constructor(scene: Nullable<Scene>);
  29556. /**
  29557. * Get the scene the texture belongs to.
  29558. * @returns the scene or null if undefined
  29559. */
  29560. getScene(): Nullable<Scene>;
  29561. /**
  29562. * Get the texture transform matrix used to offset tile the texture for istance.
  29563. * @returns the transformation matrix
  29564. */
  29565. getTextureMatrix(): Matrix;
  29566. /**
  29567. * Get the texture reflection matrix used to rotate/transform the reflection.
  29568. * @returns the reflection matrix
  29569. */
  29570. getReflectionTextureMatrix(): Matrix;
  29571. /**
  29572. * Get the underlying lower level texture from Babylon.
  29573. * @returns the insternal texture
  29574. */
  29575. getInternalTexture(): Nullable<InternalTexture>;
  29576. /**
  29577. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  29578. * @returns true if ready or not blocking
  29579. */
  29580. isReadyOrNotBlocking(): boolean;
  29581. /**
  29582. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  29583. * @returns true if fully ready
  29584. */
  29585. isReady(): boolean;
  29586. private _cachedSize;
  29587. /**
  29588. * Get the size of the texture.
  29589. * @returns the texture size.
  29590. */
  29591. getSize(): ISize;
  29592. /**
  29593. * Get the base size of the texture.
  29594. * It can be different from the size if the texture has been resized for POT for instance
  29595. * @returns the base size
  29596. */
  29597. getBaseSize(): ISize;
  29598. /**
  29599. * Update the sampling mode of the texture.
  29600. * Default is Trilinear mode.
  29601. *
  29602. * | Value | Type | Description |
  29603. * | ----- | ------------------ | ----------- |
  29604. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  29605. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  29606. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  29607. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  29608. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  29609. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  29610. * | 7 | NEAREST_LINEAR | |
  29611. * | 8 | NEAREST_NEAREST | |
  29612. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  29613. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  29614. * | 11 | LINEAR_LINEAR | |
  29615. * | 12 | LINEAR_NEAREST | |
  29616. *
  29617. * > _mag_: magnification filter (close to the viewer)
  29618. * > _min_: minification filter (far from the viewer)
  29619. * > _mip_: filter used between mip map levels
  29620. *@param samplingMode Define the new sampling mode of the texture
  29621. */
  29622. updateSamplingMode(samplingMode: number): void;
  29623. /**
  29624. * Scales the texture if is `canRescale()`
  29625. * @param ratio the resize factor we want to use to rescale
  29626. */
  29627. scale(ratio: number): void;
  29628. /**
  29629. * Get if the texture can rescale.
  29630. */
  29631. get canRescale(): boolean;
  29632. /** @hidden */
  29633. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  29634. /** @hidden */
  29635. _rebuild(): void;
  29636. /**
  29637. * Triggers the load sequence in delayed load mode.
  29638. */
  29639. delayLoad(): void;
  29640. /**
  29641. * Clones the texture.
  29642. * @returns the cloned texture
  29643. */
  29644. clone(): Nullable<BaseTexture>;
  29645. /**
  29646. * Get the texture underlying type (INT, FLOAT...)
  29647. */
  29648. get textureType(): number;
  29649. /**
  29650. * Get the texture underlying format (RGB, RGBA...)
  29651. */
  29652. get textureFormat(): number;
  29653. /**
  29654. * Indicates that textures need to be re-calculated for all materials
  29655. */
  29656. protected _markAllSubMeshesAsTexturesDirty(): void;
  29657. /**
  29658. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  29659. * This will returns an RGBA array buffer containing either in values (0-255) or
  29660. * float values (0-1) depending of the underlying buffer type.
  29661. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  29662. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  29663. * @param buffer defines a user defined buffer to fill with data (can be null)
  29664. * @returns The Array buffer containing the pixels data.
  29665. */
  29666. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  29667. /**
  29668. * Release and destroy the underlying lower level texture aka internalTexture.
  29669. */
  29670. releaseInternalTexture(): void;
  29671. /** @hidden */
  29672. get _lodTextureHigh(): Nullable<BaseTexture>;
  29673. /** @hidden */
  29674. get _lodTextureMid(): Nullable<BaseTexture>;
  29675. /** @hidden */
  29676. get _lodTextureLow(): Nullable<BaseTexture>;
  29677. /**
  29678. * Dispose the texture and release its associated resources.
  29679. */
  29680. dispose(): void;
  29681. /**
  29682. * Serialize the texture into a JSON representation that can be parsed later on.
  29683. * @returns the JSON representation of the texture
  29684. */
  29685. serialize(): any;
  29686. /**
  29687. * Helper function to be called back once a list of texture contains only ready textures.
  29688. * @param textures Define the list of textures to wait for
  29689. * @param callback Define the callback triggered once the entire list will be ready
  29690. */
  29691. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  29692. }
  29693. }
  29694. declare module BABYLON {
  29695. /**
  29696. * Options to be used when creating an effect.
  29697. */
  29698. export interface IEffectCreationOptions {
  29699. /**
  29700. * Atrributes that will be used in the shader.
  29701. */
  29702. attributes: string[];
  29703. /**
  29704. * Uniform varible names that will be set in the shader.
  29705. */
  29706. uniformsNames: string[];
  29707. /**
  29708. * Uniform buffer variable names that will be set in the shader.
  29709. */
  29710. uniformBuffersNames: string[];
  29711. /**
  29712. * Sampler texture variable names that will be set in the shader.
  29713. */
  29714. samplers: string[];
  29715. /**
  29716. * Define statements that will be set in the shader.
  29717. */
  29718. defines: any;
  29719. /**
  29720. * Possible fallbacks for this effect to improve performance when needed.
  29721. */
  29722. fallbacks: Nullable<IEffectFallbacks>;
  29723. /**
  29724. * Callback that will be called when the shader is compiled.
  29725. */
  29726. onCompiled: Nullable<(effect: Effect) => void>;
  29727. /**
  29728. * Callback that will be called if an error occurs during shader compilation.
  29729. */
  29730. onError: Nullable<(effect: Effect, errors: string) => void>;
  29731. /**
  29732. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29733. */
  29734. indexParameters?: any;
  29735. /**
  29736. * Max number of lights that can be used in the shader.
  29737. */
  29738. maxSimultaneousLights?: number;
  29739. /**
  29740. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29741. */
  29742. transformFeedbackVaryings?: Nullable<string[]>;
  29743. }
  29744. /**
  29745. * Effect containing vertex and fragment shader that can be executed on an object.
  29746. */
  29747. export class Effect implements IDisposable {
  29748. /**
  29749. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29750. */
  29751. static ShadersRepository: string;
  29752. /**
  29753. * Name of the effect.
  29754. */
  29755. name: any;
  29756. /**
  29757. * String container all the define statements that should be set on the shader.
  29758. */
  29759. defines: string;
  29760. /**
  29761. * Callback that will be called when the shader is compiled.
  29762. */
  29763. onCompiled: Nullable<(effect: Effect) => void>;
  29764. /**
  29765. * Callback that will be called if an error occurs during shader compilation.
  29766. */
  29767. onError: Nullable<(effect: Effect, errors: string) => void>;
  29768. /**
  29769. * Callback that will be called when effect is bound.
  29770. */
  29771. onBind: Nullable<(effect: Effect) => void>;
  29772. /**
  29773. * Unique ID of the effect.
  29774. */
  29775. uniqueId: number;
  29776. /**
  29777. * Observable that will be called when the shader is compiled.
  29778. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29779. */
  29780. onCompileObservable: Observable<Effect>;
  29781. /**
  29782. * Observable that will be called if an error occurs during shader compilation.
  29783. */
  29784. onErrorObservable: Observable<Effect>;
  29785. /** @hidden */
  29786. _onBindObservable: Nullable<Observable<Effect>>;
  29787. /**
  29788. * Observable that will be called when effect is bound.
  29789. */
  29790. get onBindObservable(): Observable<Effect>;
  29791. /** @hidden */
  29792. _bonesComputationForcedToCPU: boolean;
  29793. private static _uniqueIdSeed;
  29794. private _engine;
  29795. private _uniformBuffersNames;
  29796. private _uniformsNames;
  29797. private _samplerList;
  29798. private _samplers;
  29799. private _isReady;
  29800. private _compilationError;
  29801. private _allFallbacksProcessed;
  29802. private _attributesNames;
  29803. private _attributes;
  29804. private _attributeLocationByName;
  29805. private _uniforms;
  29806. /**
  29807. * Key for the effect.
  29808. * @hidden
  29809. */
  29810. _key: string;
  29811. private _indexParameters;
  29812. private _fallbacks;
  29813. private _vertexSourceCode;
  29814. private _fragmentSourceCode;
  29815. private _vertexSourceCodeOverride;
  29816. private _fragmentSourceCodeOverride;
  29817. private _transformFeedbackVaryings;
  29818. /**
  29819. * Compiled shader to webGL program.
  29820. * @hidden
  29821. */
  29822. _pipelineContext: Nullable<IPipelineContext>;
  29823. private _valueCache;
  29824. private static _baseCache;
  29825. /**
  29826. * Instantiates an effect.
  29827. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29828. * @param baseName Name of the effect.
  29829. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29830. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29831. * @param samplers List of sampler variables that will be passed to the shader.
  29832. * @param engine Engine to be used to render the effect
  29833. * @param defines Define statements to be added to the shader.
  29834. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29835. * @param onCompiled Callback that will be called when the shader is compiled.
  29836. * @param onError Callback that will be called if an error occurs during shader compilation.
  29837. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29838. */
  29839. 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);
  29840. private _useFinalCode;
  29841. /**
  29842. * Unique key for this effect
  29843. */
  29844. get key(): string;
  29845. /**
  29846. * If the effect has been compiled and prepared.
  29847. * @returns if the effect is compiled and prepared.
  29848. */
  29849. isReady(): boolean;
  29850. private _isReadyInternal;
  29851. /**
  29852. * The engine the effect was initialized with.
  29853. * @returns the engine.
  29854. */
  29855. getEngine(): Engine;
  29856. /**
  29857. * The pipeline context for this effect
  29858. * @returns the associated pipeline context
  29859. */
  29860. getPipelineContext(): Nullable<IPipelineContext>;
  29861. /**
  29862. * The set of names of attribute variables for the shader.
  29863. * @returns An array of attribute names.
  29864. */
  29865. getAttributesNames(): string[];
  29866. /**
  29867. * Returns the attribute at the given index.
  29868. * @param index The index of the attribute.
  29869. * @returns The location of the attribute.
  29870. */
  29871. getAttributeLocation(index: number): number;
  29872. /**
  29873. * Returns the attribute based on the name of the variable.
  29874. * @param name of the attribute to look up.
  29875. * @returns the attribute location.
  29876. */
  29877. getAttributeLocationByName(name: string): number;
  29878. /**
  29879. * The number of attributes.
  29880. * @returns the numnber of attributes.
  29881. */
  29882. getAttributesCount(): number;
  29883. /**
  29884. * Gets the index of a uniform variable.
  29885. * @param uniformName of the uniform to look up.
  29886. * @returns the index.
  29887. */
  29888. getUniformIndex(uniformName: string): number;
  29889. /**
  29890. * Returns the attribute based on the name of the variable.
  29891. * @param uniformName of the uniform to look up.
  29892. * @returns the location of the uniform.
  29893. */
  29894. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29895. /**
  29896. * Returns an array of sampler variable names
  29897. * @returns The array of sampler variable neames.
  29898. */
  29899. getSamplers(): string[];
  29900. /**
  29901. * The error from the last compilation.
  29902. * @returns the error string.
  29903. */
  29904. getCompilationError(): string;
  29905. /**
  29906. * Gets a boolean indicating that all fallbacks were used during compilation
  29907. * @returns true if all fallbacks were used
  29908. */
  29909. allFallbacksProcessed(): boolean;
  29910. /**
  29911. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29912. * @param func The callback to be used.
  29913. */
  29914. executeWhenCompiled(func: (effect: Effect) => void): void;
  29915. private _checkIsReady;
  29916. private _loadShader;
  29917. /**
  29918. * Recompiles the webGL program
  29919. * @param vertexSourceCode The source code for the vertex shader.
  29920. * @param fragmentSourceCode The source code for the fragment shader.
  29921. * @param onCompiled Callback called when completed.
  29922. * @param onError Callback called on error.
  29923. * @hidden
  29924. */
  29925. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  29926. /**
  29927. * Prepares the effect
  29928. * @hidden
  29929. */
  29930. _prepareEffect(): void;
  29931. private _processCompilationErrors;
  29932. /**
  29933. * Checks if the effect is supported. (Must be called after compilation)
  29934. */
  29935. get isSupported(): boolean;
  29936. /**
  29937. * Binds a texture to the engine to be used as output of the shader.
  29938. * @param channel Name of the output variable.
  29939. * @param texture Texture to bind.
  29940. * @hidden
  29941. */
  29942. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  29943. /**
  29944. * Sets a texture on the engine to be used in the shader.
  29945. * @param channel Name of the sampler variable.
  29946. * @param texture Texture to set.
  29947. */
  29948. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29949. /**
  29950. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29951. * @param channel Name of the sampler variable.
  29952. * @param texture Texture to set.
  29953. */
  29954. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29955. /**
  29956. * Sets an array of textures on the engine to be used in the shader.
  29957. * @param channel Name of the variable.
  29958. * @param textures Textures to set.
  29959. */
  29960. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29961. /**
  29962. * 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)
  29963. * @param channel Name of the sampler variable.
  29964. * @param postProcess Post process to get the input texture from.
  29965. */
  29966. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29967. /**
  29968. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29969. * 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)
  29970. * @param channel Name of the sampler variable.
  29971. * @param postProcess Post process to get the output texture from.
  29972. */
  29973. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29974. /** @hidden */
  29975. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  29976. /** @hidden */
  29977. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29978. /** @hidden */
  29979. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29980. /** @hidden */
  29981. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29982. /**
  29983. * Binds a buffer to a uniform.
  29984. * @param buffer Buffer to bind.
  29985. * @param name Name of the uniform variable to bind to.
  29986. */
  29987. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  29988. /**
  29989. * Binds block to a uniform.
  29990. * @param blockName Name of the block to bind.
  29991. * @param index Index to bind.
  29992. */
  29993. bindUniformBlock(blockName: string, index: number): void;
  29994. /**
  29995. * Sets an interger value on a uniform variable.
  29996. * @param uniformName Name of the variable.
  29997. * @param value Value to be set.
  29998. * @returns this effect.
  29999. */
  30000. setInt(uniformName: string, value: number): Effect;
  30001. /**
  30002. * Sets an int array on a uniform variable.
  30003. * @param uniformName Name of the variable.
  30004. * @param array array to be set.
  30005. * @returns this effect.
  30006. */
  30007. setIntArray(uniformName: string, array: Int32Array): Effect;
  30008. /**
  30009. * 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)
  30010. * @param uniformName Name of the variable.
  30011. * @param array array to be set.
  30012. * @returns this effect.
  30013. */
  30014. setIntArray2(uniformName: string, array: Int32Array): Effect;
  30015. /**
  30016. * 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)
  30017. * @param uniformName Name of the variable.
  30018. * @param array array to be set.
  30019. * @returns this effect.
  30020. */
  30021. setIntArray3(uniformName: string, array: Int32Array): Effect;
  30022. /**
  30023. * 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)
  30024. * @param uniformName Name of the variable.
  30025. * @param array array to be set.
  30026. * @returns this effect.
  30027. */
  30028. setIntArray4(uniformName: string, array: Int32Array): Effect;
  30029. /**
  30030. * Sets an float array on a uniform variable.
  30031. * @param uniformName Name of the variable.
  30032. * @param array array to be set.
  30033. * @returns this effect.
  30034. */
  30035. setFloatArray(uniformName: string, array: Float32Array): Effect;
  30036. /**
  30037. * 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)
  30038. * @param uniformName Name of the variable.
  30039. * @param array array to be set.
  30040. * @returns this effect.
  30041. */
  30042. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  30043. /**
  30044. * 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)
  30045. * @param uniformName Name of the variable.
  30046. * @param array array to be set.
  30047. * @returns this effect.
  30048. */
  30049. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  30050. /**
  30051. * 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)
  30052. * @param uniformName Name of the variable.
  30053. * @param array array to be set.
  30054. * @returns this effect.
  30055. */
  30056. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  30057. /**
  30058. * Sets an array on a uniform variable.
  30059. * @param uniformName Name of the variable.
  30060. * @param array array to be set.
  30061. * @returns this effect.
  30062. */
  30063. setArray(uniformName: string, array: number[]): Effect;
  30064. /**
  30065. * 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)
  30066. * @param uniformName Name of the variable.
  30067. * @param array array to be set.
  30068. * @returns this effect.
  30069. */
  30070. setArray2(uniformName: string, array: number[]): Effect;
  30071. /**
  30072. * 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)
  30073. * @param uniformName Name of the variable.
  30074. * @param array array to be set.
  30075. * @returns this effect.
  30076. */
  30077. setArray3(uniformName: string, array: number[]): Effect;
  30078. /**
  30079. * 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)
  30080. * @param uniformName Name of the variable.
  30081. * @param array array to be set.
  30082. * @returns this effect.
  30083. */
  30084. setArray4(uniformName: string, array: number[]): Effect;
  30085. /**
  30086. * Sets matrices on a uniform variable.
  30087. * @param uniformName Name of the variable.
  30088. * @param matrices matrices to be set.
  30089. * @returns this effect.
  30090. */
  30091. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  30092. /**
  30093. * Sets matrix on a uniform variable.
  30094. * @param uniformName Name of the variable.
  30095. * @param matrix matrix to be set.
  30096. * @returns this effect.
  30097. */
  30098. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  30099. /**
  30100. * 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)
  30101. * @param uniformName Name of the variable.
  30102. * @param matrix matrix to be set.
  30103. * @returns this effect.
  30104. */
  30105. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  30106. /**
  30107. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  30108. * @param uniformName Name of the variable.
  30109. * @param matrix matrix to be set.
  30110. * @returns this effect.
  30111. */
  30112. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  30113. /**
  30114. * Sets a float on a uniform variable.
  30115. * @param uniformName Name of the variable.
  30116. * @param value value to be set.
  30117. * @returns this effect.
  30118. */
  30119. setFloat(uniformName: string, value: number): Effect;
  30120. /**
  30121. * Sets a boolean on a uniform variable.
  30122. * @param uniformName Name of the variable.
  30123. * @param bool value to be set.
  30124. * @returns this effect.
  30125. */
  30126. setBool(uniformName: string, bool: boolean): Effect;
  30127. /**
  30128. * Sets a Vector2 on a uniform variable.
  30129. * @param uniformName Name of the variable.
  30130. * @param vector2 vector2 to be set.
  30131. * @returns this effect.
  30132. */
  30133. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  30134. /**
  30135. * Sets a float2 on a uniform variable.
  30136. * @param uniformName Name of the variable.
  30137. * @param x First float in float2.
  30138. * @param y Second float in float2.
  30139. * @returns this effect.
  30140. */
  30141. setFloat2(uniformName: string, x: number, y: number): Effect;
  30142. /**
  30143. * Sets a Vector3 on a uniform variable.
  30144. * @param uniformName Name of the variable.
  30145. * @param vector3 Value to be set.
  30146. * @returns this effect.
  30147. */
  30148. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  30149. /**
  30150. * Sets a float3 on a uniform variable.
  30151. * @param uniformName Name of the variable.
  30152. * @param x First float in float3.
  30153. * @param y Second float in float3.
  30154. * @param z Third float in float3.
  30155. * @returns this effect.
  30156. */
  30157. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  30158. /**
  30159. * Sets a Vector4 on a uniform variable.
  30160. * @param uniformName Name of the variable.
  30161. * @param vector4 Value to be set.
  30162. * @returns this effect.
  30163. */
  30164. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  30165. /**
  30166. * Sets a float4 on a uniform variable.
  30167. * @param uniformName Name of the variable.
  30168. * @param x First float in float4.
  30169. * @param y Second float in float4.
  30170. * @param z Third float in float4.
  30171. * @param w Fourth float in float4.
  30172. * @returns this effect.
  30173. */
  30174. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  30175. /**
  30176. * Sets a Color3 on a uniform variable.
  30177. * @param uniformName Name of the variable.
  30178. * @param color3 Value to be set.
  30179. * @returns this effect.
  30180. */
  30181. setColor3(uniformName: string, color3: IColor3Like): Effect;
  30182. /**
  30183. * Sets a Color4 on a uniform variable.
  30184. * @param uniformName Name of the variable.
  30185. * @param color3 Value to be set.
  30186. * @param alpha Alpha value to be set.
  30187. * @returns this effect.
  30188. */
  30189. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  30190. /**
  30191. * Sets a Color4 on a uniform variable
  30192. * @param uniformName defines the name of the variable
  30193. * @param color4 defines the value to be set
  30194. * @returns this effect.
  30195. */
  30196. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  30197. /** Release all associated resources */
  30198. dispose(): void;
  30199. /**
  30200. * This function will add a new shader to the shader store
  30201. * @param name the name of the shader
  30202. * @param pixelShader optional pixel shader content
  30203. * @param vertexShader optional vertex shader content
  30204. */
  30205. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  30206. /**
  30207. * Store of each shader (The can be looked up using effect.key)
  30208. */
  30209. static ShadersStore: {
  30210. [key: string]: string;
  30211. };
  30212. /**
  30213. * Store of each included file for a shader (The can be looked up using effect.key)
  30214. */
  30215. static IncludesShadersStore: {
  30216. [key: string]: string;
  30217. };
  30218. /**
  30219. * Resets the cache of effects.
  30220. */
  30221. static ResetCache(): void;
  30222. }
  30223. }
  30224. declare module BABYLON {
  30225. /**
  30226. * Interface used to describe the capabilities of the engine relatively to the current browser
  30227. */
  30228. export interface EngineCapabilities {
  30229. /** Maximum textures units per fragment shader */
  30230. maxTexturesImageUnits: number;
  30231. /** Maximum texture units per vertex shader */
  30232. maxVertexTextureImageUnits: number;
  30233. /** Maximum textures units in the entire pipeline */
  30234. maxCombinedTexturesImageUnits: number;
  30235. /** Maximum texture size */
  30236. maxTextureSize: number;
  30237. /** Maximum texture samples */
  30238. maxSamples?: number;
  30239. /** Maximum cube texture size */
  30240. maxCubemapTextureSize: number;
  30241. /** Maximum render texture size */
  30242. maxRenderTextureSize: number;
  30243. /** Maximum number of vertex attributes */
  30244. maxVertexAttribs: number;
  30245. /** Maximum number of varyings */
  30246. maxVaryingVectors: number;
  30247. /** Maximum number of uniforms per vertex shader */
  30248. maxVertexUniformVectors: number;
  30249. /** Maximum number of uniforms per fragment shader */
  30250. maxFragmentUniformVectors: number;
  30251. /** Defines if standard derivates (dx/dy) are supported */
  30252. standardDerivatives: boolean;
  30253. /** Defines if s3tc texture compression is supported */
  30254. s3tc?: WEBGL_compressed_texture_s3tc;
  30255. /** Defines if pvrtc texture compression is supported */
  30256. pvrtc: any;
  30257. /** Defines if etc1 texture compression is supported */
  30258. etc1: any;
  30259. /** Defines if etc2 texture compression is supported */
  30260. etc2: any;
  30261. /** Defines if astc texture compression is supported */
  30262. astc: any;
  30263. /** Defines if float textures are supported */
  30264. textureFloat: boolean;
  30265. /** Defines if vertex array objects are supported */
  30266. vertexArrayObject: boolean;
  30267. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  30268. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  30269. /** Gets the maximum level of anisotropy supported */
  30270. maxAnisotropy: number;
  30271. /** Defines if instancing is supported */
  30272. instancedArrays: boolean;
  30273. /** Defines if 32 bits indices are supported */
  30274. uintIndices: boolean;
  30275. /** Defines if high precision shaders are supported */
  30276. highPrecisionShaderSupported: boolean;
  30277. /** Defines if depth reading in the fragment shader is supported */
  30278. fragmentDepthSupported: boolean;
  30279. /** Defines if float texture linear filtering is supported*/
  30280. textureFloatLinearFiltering: boolean;
  30281. /** Defines if rendering to float textures is supported */
  30282. textureFloatRender: boolean;
  30283. /** Defines if half float textures are supported*/
  30284. textureHalfFloat: boolean;
  30285. /** Defines if half float texture linear filtering is supported*/
  30286. textureHalfFloatLinearFiltering: boolean;
  30287. /** Defines if rendering to half float textures is supported */
  30288. textureHalfFloatRender: boolean;
  30289. /** Defines if textureLOD shader command is supported */
  30290. textureLOD: boolean;
  30291. /** Defines if draw buffers extension is supported */
  30292. drawBuffersExtension: boolean;
  30293. /** Defines if depth textures are supported */
  30294. depthTextureExtension: boolean;
  30295. /** Defines if float color buffer are supported */
  30296. colorBufferFloat: boolean;
  30297. /** Gets disjoint timer query extension (null if not supported) */
  30298. timerQuery?: EXT_disjoint_timer_query;
  30299. /** Defines if timestamp can be used with timer query */
  30300. canUseTimestampForTimerQuery: boolean;
  30301. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  30302. multiview?: any;
  30303. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  30304. oculusMultiview?: any;
  30305. /** Function used to let the system compiles shaders in background */
  30306. parallelShaderCompile?: {
  30307. COMPLETION_STATUS_KHR: number;
  30308. };
  30309. /** Max number of texture samples for MSAA */
  30310. maxMSAASamples: number;
  30311. /** Defines if the blend min max extension is supported */
  30312. blendMinMax: boolean;
  30313. }
  30314. }
  30315. declare module BABYLON {
  30316. /**
  30317. * @hidden
  30318. **/
  30319. export class DepthCullingState {
  30320. private _isDepthTestDirty;
  30321. private _isDepthMaskDirty;
  30322. private _isDepthFuncDirty;
  30323. private _isCullFaceDirty;
  30324. private _isCullDirty;
  30325. private _isZOffsetDirty;
  30326. private _isFrontFaceDirty;
  30327. private _depthTest;
  30328. private _depthMask;
  30329. private _depthFunc;
  30330. private _cull;
  30331. private _cullFace;
  30332. private _zOffset;
  30333. private _frontFace;
  30334. /**
  30335. * Initializes the state.
  30336. */
  30337. constructor();
  30338. get isDirty(): boolean;
  30339. get zOffset(): number;
  30340. set zOffset(value: number);
  30341. get cullFace(): Nullable<number>;
  30342. set cullFace(value: Nullable<number>);
  30343. get cull(): Nullable<boolean>;
  30344. set cull(value: Nullable<boolean>);
  30345. get depthFunc(): Nullable<number>;
  30346. set depthFunc(value: Nullable<number>);
  30347. get depthMask(): boolean;
  30348. set depthMask(value: boolean);
  30349. get depthTest(): boolean;
  30350. set depthTest(value: boolean);
  30351. get frontFace(): Nullable<number>;
  30352. set frontFace(value: Nullable<number>);
  30353. reset(): void;
  30354. apply(gl: WebGLRenderingContext): void;
  30355. }
  30356. }
  30357. declare module BABYLON {
  30358. /**
  30359. * @hidden
  30360. **/
  30361. export class StencilState {
  30362. /** 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 */
  30363. static readonly ALWAYS: number;
  30364. /** Passed to stencilOperation to specify that stencil value must be kept */
  30365. static readonly KEEP: number;
  30366. /** Passed to stencilOperation to specify that stencil value must be replaced */
  30367. static readonly REPLACE: number;
  30368. private _isStencilTestDirty;
  30369. private _isStencilMaskDirty;
  30370. private _isStencilFuncDirty;
  30371. private _isStencilOpDirty;
  30372. private _stencilTest;
  30373. private _stencilMask;
  30374. private _stencilFunc;
  30375. private _stencilFuncRef;
  30376. private _stencilFuncMask;
  30377. private _stencilOpStencilFail;
  30378. private _stencilOpDepthFail;
  30379. private _stencilOpStencilDepthPass;
  30380. get isDirty(): boolean;
  30381. get stencilFunc(): number;
  30382. set stencilFunc(value: number);
  30383. get stencilFuncRef(): number;
  30384. set stencilFuncRef(value: number);
  30385. get stencilFuncMask(): number;
  30386. set stencilFuncMask(value: number);
  30387. get stencilOpStencilFail(): number;
  30388. set stencilOpStencilFail(value: number);
  30389. get stencilOpDepthFail(): number;
  30390. set stencilOpDepthFail(value: number);
  30391. get stencilOpStencilDepthPass(): number;
  30392. set stencilOpStencilDepthPass(value: number);
  30393. get stencilMask(): number;
  30394. set stencilMask(value: number);
  30395. get stencilTest(): boolean;
  30396. set stencilTest(value: boolean);
  30397. constructor();
  30398. reset(): void;
  30399. apply(gl: WebGLRenderingContext): void;
  30400. }
  30401. }
  30402. declare module BABYLON {
  30403. /**
  30404. * @hidden
  30405. **/
  30406. export class AlphaState {
  30407. private _isAlphaBlendDirty;
  30408. private _isBlendFunctionParametersDirty;
  30409. private _isBlendEquationParametersDirty;
  30410. private _isBlendConstantsDirty;
  30411. private _alphaBlend;
  30412. private _blendFunctionParameters;
  30413. private _blendEquationParameters;
  30414. private _blendConstants;
  30415. /**
  30416. * Initializes the state.
  30417. */
  30418. constructor();
  30419. get isDirty(): boolean;
  30420. get alphaBlend(): boolean;
  30421. set alphaBlend(value: boolean);
  30422. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  30423. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  30424. setAlphaEquationParameters(rgb: number, alpha: number): void;
  30425. reset(): void;
  30426. apply(gl: WebGLRenderingContext): void;
  30427. }
  30428. }
  30429. declare module BABYLON {
  30430. /** @hidden */
  30431. export class WebGL2ShaderProcessor implements IShaderProcessor {
  30432. attributeProcessor(attribute: string): string;
  30433. varyingProcessor(varying: string, isFragment: boolean): string;
  30434. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  30435. }
  30436. }
  30437. declare module BABYLON {
  30438. /**
  30439. * Interface for attribute information associated with buffer instanciation
  30440. */
  30441. export interface InstancingAttributeInfo {
  30442. /**
  30443. * Name of the GLSL attribute
  30444. * if attribute index is not specified, this is used to retrieve the index from the effect
  30445. */
  30446. attributeName: string;
  30447. /**
  30448. * Index/offset of the attribute in the vertex shader
  30449. * if not specified, this will be computes from the name.
  30450. */
  30451. index?: number;
  30452. /**
  30453. * size of the attribute, 1, 2, 3 or 4
  30454. */
  30455. attributeSize: number;
  30456. /**
  30457. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  30458. */
  30459. offset: number;
  30460. /**
  30461. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  30462. * default to 1
  30463. */
  30464. divisor?: number;
  30465. /**
  30466. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  30467. * default is FLOAT
  30468. */
  30469. attributeType?: number;
  30470. /**
  30471. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  30472. */
  30473. normalized?: boolean;
  30474. }
  30475. }
  30476. declare module BABYLON {
  30477. interface ThinEngine {
  30478. /**
  30479. * Update a video texture
  30480. * @param texture defines the texture to update
  30481. * @param video defines the video element to use
  30482. * @param invertY defines if data must be stored with Y axis inverted
  30483. */
  30484. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  30485. }
  30486. }
  30487. declare module BABYLON {
  30488. /**
  30489. * Settings for finer control over video usage
  30490. */
  30491. export interface VideoTextureSettings {
  30492. /**
  30493. * Applies `autoplay` to video, if specified
  30494. */
  30495. autoPlay?: boolean;
  30496. /**
  30497. * Applies `loop` to video, if specified
  30498. */
  30499. loop?: boolean;
  30500. /**
  30501. * Automatically updates internal texture from video at every frame in the render loop
  30502. */
  30503. autoUpdateTexture: boolean;
  30504. /**
  30505. * Image src displayed during the video loading or until the user interacts with the video.
  30506. */
  30507. poster?: string;
  30508. }
  30509. /**
  30510. * If you want to display a video in your scene, this is the special texture for that.
  30511. * This special texture works similar to other textures, with the exception of a few parameters.
  30512. * @see https://doc.babylonjs.com/how_to/video_texture
  30513. */
  30514. export class VideoTexture extends Texture {
  30515. /**
  30516. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  30517. */
  30518. readonly autoUpdateTexture: boolean;
  30519. /**
  30520. * The video instance used by the texture internally
  30521. */
  30522. readonly video: HTMLVideoElement;
  30523. private _onUserActionRequestedObservable;
  30524. /**
  30525. * Event triggerd when a dom action is required by the user to play the video.
  30526. * This happens due to recent changes in browser policies preventing video to auto start.
  30527. */
  30528. get onUserActionRequestedObservable(): Observable<Texture>;
  30529. private _generateMipMaps;
  30530. private _engine;
  30531. private _stillImageCaptured;
  30532. private _displayingPosterTexture;
  30533. private _settings;
  30534. private _createInternalTextureOnEvent;
  30535. private _frameId;
  30536. /**
  30537. * Creates a video texture.
  30538. * If you want to display a video in your scene, this is the special texture for that.
  30539. * This special texture works similar to other textures, with the exception of a few parameters.
  30540. * @see https://doc.babylonjs.com/how_to/video_texture
  30541. * @param name optional name, will detect from video source, if not defined
  30542. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  30543. * @param scene is obviously the current scene.
  30544. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  30545. * @param invertY is false by default but can be used to invert video on Y axis
  30546. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  30547. * @param settings allows finer control over video usage
  30548. */
  30549. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  30550. private _getName;
  30551. private _getVideo;
  30552. private _createInternalTexture;
  30553. private reset;
  30554. /**
  30555. * @hidden Internal method to initiate `update`.
  30556. */
  30557. _rebuild(): void;
  30558. /**
  30559. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  30560. */
  30561. update(): void;
  30562. /**
  30563. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  30564. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  30565. */
  30566. updateTexture(isVisible: boolean): void;
  30567. protected _updateInternalTexture: () => void;
  30568. /**
  30569. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  30570. * @param url New url.
  30571. */
  30572. updateURL(url: string): void;
  30573. /**
  30574. * Dispose the texture and release its associated resources.
  30575. */
  30576. dispose(): void;
  30577. /**
  30578. * Creates a video texture straight from a stream.
  30579. * @param scene Define the scene the texture should be created in
  30580. * @param stream Define the stream the texture should be created from
  30581. * @returns The created video texture as a promise
  30582. */
  30583. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  30584. /**
  30585. * Creates a video texture straight from your WebCam video feed.
  30586. * @param scene Define the scene the texture should be created in
  30587. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30588. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30589. * @returns The created video texture as a promise
  30590. */
  30591. static CreateFromWebCamAsync(scene: Scene, constraints: {
  30592. minWidth: number;
  30593. maxWidth: number;
  30594. minHeight: number;
  30595. maxHeight: number;
  30596. deviceId: string;
  30597. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  30598. /**
  30599. * Creates a video texture straight from your WebCam video feed.
  30600. * @param scene Define the scene the texture should be created in
  30601. * @param onReady Define a callback to triggered once the texture will be ready
  30602. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30603. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30604. */
  30605. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  30606. minWidth: number;
  30607. maxWidth: number;
  30608. minHeight: number;
  30609. maxHeight: number;
  30610. deviceId: string;
  30611. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  30612. }
  30613. }
  30614. declare module BABYLON {
  30615. /**
  30616. * Defines the interface used by objects working like Scene
  30617. * @hidden
  30618. */
  30619. interface ISceneLike {
  30620. _addPendingData(data: any): void;
  30621. _removePendingData(data: any): void;
  30622. offlineProvider: IOfflineProvider;
  30623. }
  30624. /** Interface defining initialization parameters for Engine class */
  30625. export interface EngineOptions extends WebGLContextAttributes {
  30626. /**
  30627. * Defines if the engine should no exceed a specified device ratio
  30628. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  30629. */
  30630. limitDeviceRatio?: number;
  30631. /**
  30632. * Defines if webvr should be enabled automatically
  30633. * @see http://doc.babylonjs.com/how_to/webvr_camera
  30634. */
  30635. autoEnableWebVR?: boolean;
  30636. /**
  30637. * Defines if webgl2 should be turned off even if supported
  30638. * @see http://doc.babylonjs.com/features/webgl2
  30639. */
  30640. disableWebGL2Support?: boolean;
  30641. /**
  30642. * Defines if webaudio should be initialized as well
  30643. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30644. */
  30645. audioEngine?: boolean;
  30646. /**
  30647. * Defines if animations should run using a deterministic lock step
  30648. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30649. */
  30650. deterministicLockstep?: boolean;
  30651. /** Defines the maximum steps to use with deterministic lock step mode */
  30652. lockstepMaxSteps?: number;
  30653. /** Defines the seconds between each deterministic lock step */
  30654. timeStep?: number;
  30655. /**
  30656. * Defines that engine should ignore context lost events
  30657. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  30658. */
  30659. doNotHandleContextLost?: boolean;
  30660. /**
  30661. * Defines that engine should ignore modifying touch action attribute and style
  30662. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  30663. */
  30664. doNotHandleTouchAction?: boolean;
  30665. /**
  30666. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  30667. */
  30668. useHighPrecisionFloats?: boolean;
  30669. }
  30670. /**
  30671. * The base engine class (root of all engines)
  30672. */
  30673. export class ThinEngine {
  30674. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  30675. static ExceptionList: ({
  30676. key: string;
  30677. capture: string;
  30678. captureConstraint: number;
  30679. targets: string[];
  30680. } | {
  30681. key: string;
  30682. capture: null;
  30683. captureConstraint: null;
  30684. targets: string[];
  30685. })[];
  30686. /** @hidden */
  30687. static _TextureLoaders: IInternalTextureLoader[];
  30688. /**
  30689. * Returns the current npm package of the sdk
  30690. */
  30691. static get NpmPackage(): string;
  30692. /**
  30693. * Returns the current version of the framework
  30694. */
  30695. static get Version(): string;
  30696. /**
  30697. * Returns a string describing the current engine
  30698. */
  30699. get description(): string;
  30700. /**
  30701. * Gets or sets the epsilon value used by collision engine
  30702. */
  30703. static CollisionsEpsilon: number;
  30704. /**
  30705. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30706. */
  30707. static get ShadersRepository(): string;
  30708. static set ShadersRepository(value: string);
  30709. /**
  30710. * Gets or sets the textures that the engine should not attempt to load as compressed
  30711. */
  30712. protected _excludedCompressedTextures: string[];
  30713. /**
  30714. * Filters the compressed texture formats to only include
  30715. * files that are not included in the skippable list
  30716. *
  30717. * @param url the current extension
  30718. * @param textureFormatInUse the current compressed texture format
  30719. * @returns "format" string
  30720. */
  30721. excludedCompressedTextureFormats(url: Nullable<string>, textureFormatInUse: Nullable<string>): Nullable<string>;
  30722. /** @hidden */
  30723. _shaderProcessor: IShaderProcessor;
  30724. /**
  30725. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  30726. */
  30727. forcePOTTextures: boolean;
  30728. /**
  30729. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  30730. */
  30731. isFullscreen: boolean;
  30732. /**
  30733. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  30734. */
  30735. cullBackFaces: boolean;
  30736. /**
  30737. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  30738. */
  30739. renderEvenInBackground: boolean;
  30740. /**
  30741. * Gets or sets a boolean indicating that cache can be kept between frames
  30742. */
  30743. preventCacheWipeBetweenFrames: boolean;
  30744. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  30745. validateShaderPrograms: boolean;
  30746. /**
  30747. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  30748. * This can provide greater z depth for distant objects.
  30749. */
  30750. useReverseDepthBuffer: boolean;
  30751. /**
  30752. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  30753. */
  30754. disableUniformBuffers: boolean;
  30755. /** @hidden */
  30756. _uniformBuffers: UniformBuffer[];
  30757. /**
  30758. * Gets a boolean indicating that the engine supports uniform buffers
  30759. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30760. */
  30761. get supportsUniformBuffers(): boolean;
  30762. /** @hidden */
  30763. _gl: WebGLRenderingContext;
  30764. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  30765. protected _windowIsBackground: boolean;
  30766. protected _webGLVersion: number;
  30767. protected _creationOptions: EngineOptions;
  30768. protected _highPrecisionShadersAllowed: boolean;
  30769. /** @hidden */
  30770. get _shouldUseHighPrecisionShader(): boolean;
  30771. /**
  30772. * Gets a boolean indicating that only power of 2 textures are supported
  30773. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  30774. */
  30775. get needPOTTextures(): boolean;
  30776. /** @hidden */
  30777. _badOS: boolean;
  30778. /** @hidden */
  30779. _badDesktopOS: boolean;
  30780. private _hardwareScalingLevel;
  30781. /** @hidden */
  30782. _caps: EngineCapabilities;
  30783. private _isStencilEnable;
  30784. private _glVersion;
  30785. private _glRenderer;
  30786. private _glVendor;
  30787. /** @hidden */
  30788. _videoTextureSupported: boolean;
  30789. protected _renderingQueueLaunched: boolean;
  30790. protected _activeRenderLoops: (() => void)[];
  30791. /**
  30792. * Observable signaled when a context lost event is raised
  30793. */
  30794. onContextLostObservable: Observable<ThinEngine>;
  30795. /**
  30796. * Observable signaled when a context restored event is raised
  30797. */
  30798. onContextRestoredObservable: Observable<ThinEngine>;
  30799. private _onContextLost;
  30800. private _onContextRestored;
  30801. protected _contextWasLost: boolean;
  30802. /** @hidden */
  30803. _doNotHandleContextLost: boolean;
  30804. /**
  30805. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  30806. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  30807. */
  30808. get doNotHandleContextLost(): boolean;
  30809. set doNotHandleContextLost(value: boolean);
  30810. /**
  30811. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  30812. */
  30813. disableVertexArrayObjects: boolean;
  30814. /** @hidden */
  30815. protected _colorWrite: boolean;
  30816. /** @hidden */
  30817. protected _colorWriteChanged: boolean;
  30818. /** @hidden */
  30819. protected _depthCullingState: DepthCullingState;
  30820. /** @hidden */
  30821. protected _stencilState: StencilState;
  30822. /** @hidden */
  30823. _alphaState: AlphaState;
  30824. /** @hidden */
  30825. _alphaMode: number;
  30826. /** @hidden */
  30827. _alphaEquation: number;
  30828. /** @hidden */
  30829. _internalTexturesCache: InternalTexture[];
  30830. /** @hidden */
  30831. protected _activeChannel: number;
  30832. private _currentTextureChannel;
  30833. /** @hidden */
  30834. protected _boundTexturesCache: {
  30835. [key: string]: Nullable<InternalTexture>;
  30836. };
  30837. /** @hidden */
  30838. protected _currentEffect: Nullable<Effect>;
  30839. /** @hidden */
  30840. protected _currentProgram: Nullable<WebGLProgram>;
  30841. private _compiledEffects;
  30842. private _vertexAttribArraysEnabled;
  30843. /** @hidden */
  30844. protected _cachedViewport: Nullable<IViewportLike>;
  30845. private _cachedVertexArrayObject;
  30846. /** @hidden */
  30847. protected _cachedVertexBuffers: any;
  30848. /** @hidden */
  30849. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  30850. /** @hidden */
  30851. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  30852. /** @hidden */
  30853. _currentRenderTarget: Nullable<InternalTexture>;
  30854. private _uintIndicesCurrentlySet;
  30855. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  30856. /** @hidden */
  30857. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  30858. private _currentBufferPointers;
  30859. private _currentInstanceLocations;
  30860. private _currentInstanceBuffers;
  30861. private _textureUnits;
  30862. /** @hidden */
  30863. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  30864. /** @hidden */
  30865. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  30866. /** @hidden */
  30867. _boundRenderFunction: any;
  30868. private _vaoRecordInProgress;
  30869. private _mustWipeVertexAttributes;
  30870. private _emptyTexture;
  30871. private _emptyCubeTexture;
  30872. private _emptyTexture3D;
  30873. private _emptyTexture2DArray;
  30874. /** @hidden */
  30875. _frameHandler: number;
  30876. private _nextFreeTextureSlots;
  30877. private _maxSimultaneousTextures;
  30878. private _activeRequests;
  30879. protected _texturesSupported: string[];
  30880. /** @hidden */
  30881. _textureFormatInUse: Nullable<string>;
  30882. protected get _supportsHardwareTextureRescaling(): boolean;
  30883. /**
  30884. * Gets the list of texture formats supported
  30885. */
  30886. get texturesSupported(): Array<string>;
  30887. /**
  30888. * Gets the list of texture formats in use
  30889. */
  30890. get textureFormatInUse(): Nullable<string>;
  30891. /**
  30892. * Gets the current viewport
  30893. */
  30894. get currentViewport(): Nullable<IViewportLike>;
  30895. /**
  30896. * Gets the default empty texture
  30897. */
  30898. get emptyTexture(): InternalTexture;
  30899. /**
  30900. * Gets the default empty 3D texture
  30901. */
  30902. get emptyTexture3D(): InternalTexture;
  30903. /**
  30904. * Gets the default empty 2D array texture
  30905. */
  30906. get emptyTexture2DArray(): InternalTexture;
  30907. /**
  30908. * Gets the default empty cube texture
  30909. */
  30910. get emptyCubeTexture(): InternalTexture;
  30911. /**
  30912. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  30913. */
  30914. readonly premultipliedAlpha: boolean;
  30915. /**
  30916. * Observable event triggered before each texture is initialized
  30917. */
  30918. onBeforeTextureInitObservable: Observable<Texture>;
  30919. /**
  30920. * Creates a new engine
  30921. * @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
  30922. * @param antialias defines enable antialiasing (default: false)
  30923. * @param options defines further options to be sent to the getContext() function
  30924. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  30925. */
  30926. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  30927. private _rebuildInternalTextures;
  30928. private _rebuildEffects;
  30929. /**
  30930. * Gets a boolean indicating if all created effects are ready
  30931. * @returns true if all effects are ready
  30932. */
  30933. areAllEffectsReady(): boolean;
  30934. protected _rebuildBuffers(): void;
  30935. private _initGLContext;
  30936. /**
  30937. * Gets version of the current webGL context
  30938. */
  30939. get webGLVersion(): number;
  30940. /**
  30941. * Gets a string idenfifying the name of the class
  30942. * @returns "Engine" string
  30943. */
  30944. getClassName(): string;
  30945. /**
  30946. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  30947. */
  30948. get isStencilEnable(): boolean;
  30949. /** @hidden */
  30950. _prepareWorkingCanvas(): void;
  30951. /**
  30952. * Reset the texture cache to empty state
  30953. */
  30954. resetTextureCache(): void;
  30955. /**
  30956. * Gets an object containing information about the current webGL context
  30957. * @returns an object containing the vender, the renderer and the version of the current webGL context
  30958. */
  30959. getGlInfo(): {
  30960. vendor: string;
  30961. renderer: string;
  30962. version: string;
  30963. };
  30964. /**
  30965. * Defines the hardware scaling level.
  30966. * By default the hardware scaling level is computed from the window device ratio.
  30967. * 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.
  30968. * @param level defines the level to use
  30969. */
  30970. setHardwareScalingLevel(level: number): void;
  30971. /**
  30972. * Gets the current hardware scaling level.
  30973. * By default the hardware scaling level is computed from the window device ratio.
  30974. * 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.
  30975. * @returns a number indicating the current hardware scaling level
  30976. */
  30977. getHardwareScalingLevel(): number;
  30978. /**
  30979. * Gets the list of loaded textures
  30980. * @returns an array containing all loaded textures
  30981. */
  30982. getLoadedTexturesCache(): InternalTexture[];
  30983. /**
  30984. * Gets the object containing all engine capabilities
  30985. * @returns the EngineCapabilities object
  30986. */
  30987. getCaps(): EngineCapabilities;
  30988. /**
  30989. * stop executing a render loop function and remove it from the execution array
  30990. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  30991. */
  30992. stopRenderLoop(renderFunction?: () => void): void;
  30993. /** @hidden */
  30994. _renderLoop(): void;
  30995. /**
  30996. * Gets the HTML canvas attached with the current webGL context
  30997. * @returns a HTML canvas
  30998. */
  30999. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  31000. /**
  31001. * Gets host window
  31002. * @returns the host window object
  31003. */
  31004. getHostWindow(): Nullable<Window>;
  31005. /**
  31006. * Gets the current render width
  31007. * @param useScreen defines if screen size must be used (or the current render target if any)
  31008. * @returns a number defining the current render width
  31009. */
  31010. getRenderWidth(useScreen?: boolean): number;
  31011. /**
  31012. * Gets the current render height
  31013. * @param useScreen defines if screen size must be used (or the current render target if any)
  31014. * @returns a number defining the current render height
  31015. */
  31016. getRenderHeight(useScreen?: boolean): number;
  31017. /**
  31018. * Can be used to override the current requestAnimationFrame requester.
  31019. * @hidden
  31020. */
  31021. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  31022. /**
  31023. * Register and execute a render loop. The engine can have more than one render function
  31024. * @param renderFunction defines the function to continuously execute
  31025. */
  31026. runRenderLoop(renderFunction: () => void): void;
  31027. /**
  31028. * Clear the current render buffer or the current render target (if any is set up)
  31029. * @param color defines the color to use
  31030. * @param backBuffer defines if the back buffer must be cleared
  31031. * @param depth defines if the depth buffer must be cleared
  31032. * @param stencil defines if the stencil buffer must be cleared
  31033. */
  31034. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  31035. private _viewportCached;
  31036. /** @hidden */
  31037. _viewport(x: number, y: number, width: number, height: number): void;
  31038. /**
  31039. * Set the WebGL's viewport
  31040. * @param viewport defines the viewport element to be used
  31041. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  31042. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  31043. */
  31044. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  31045. /**
  31046. * Begin a new frame
  31047. */
  31048. beginFrame(): void;
  31049. /**
  31050. * Enf the current frame
  31051. */
  31052. endFrame(): void;
  31053. /**
  31054. * Resize the view according to the canvas' size
  31055. */
  31056. resize(): void;
  31057. /**
  31058. * Force a specific size of the canvas
  31059. * @param width defines the new canvas' width
  31060. * @param height defines the new canvas' height
  31061. */
  31062. setSize(width: number, height: number): void;
  31063. /**
  31064. * Binds the frame buffer to the specified texture.
  31065. * @param texture The texture to render to or null for the default canvas
  31066. * @param faceIndex The face of the texture to render to in case of cube texture
  31067. * @param requiredWidth The width of the target to render to
  31068. * @param requiredHeight The height of the target to render to
  31069. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  31070. * @param depthStencilTexture The depth stencil texture to use to render
  31071. * @param lodLevel defines le lod level to bind to the frame buffer
  31072. */
  31073. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  31074. /** @hidden */
  31075. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  31076. /**
  31077. * Unbind the current render target texture from the webGL context
  31078. * @param texture defines the render target texture to unbind
  31079. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  31080. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  31081. */
  31082. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  31083. /**
  31084. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  31085. */
  31086. flushFramebuffer(): void;
  31087. /**
  31088. * Unbind the current render target and bind the default framebuffer
  31089. */
  31090. restoreDefaultFramebuffer(): void;
  31091. /** @hidden */
  31092. protected _resetVertexBufferBinding(): void;
  31093. /**
  31094. * Creates a vertex buffer
  31095. * @param data the data for the vertex buffer
  31096. * @returns the new WebGL static buffer
  31097. */
  31098. createVertexBuffer(data: DataArray): DataBuffer;
  31099. private _createVertexBuffer;
  31100. /**
  31101. * Creates a dynamic vertex buffer
  31102. * @param data the data for the dynamic vertex buffer
  31103. * @returns the new WebGL dynamic buffer
  31104. */
  31105. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  31106. protected _resetIndexBufferBinding(): void;
  31107. /**
  31108. * Creates a new index buffer
  31109. * @param indices defines the content of the index buffer
  31110. * @param updatable defines if the index buffer must be updatable
  31111. * @returns a new webGL buffer
  31112. */
  31113. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  31114. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  31115. /**
  31116. * Bind a webGL buffer to the webGL context
  31117. * @param buffer defines the buffer to bind
  31118. */
  31119. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  31120. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  31121. private bindBuffer;
  31122. /**
  31123. * update the bound buffer with the given data
  31124. * @param data defines the data to update
  31125. */
  31126. updateArrayBuffer(data: Float32Array): void;
  31127. private _vertexAttribPointer;
  31128. private _bindIndexBufferWithCache;
  31129. private _bindVertexBuffersAttributes;
  31130. /**
  31131. * Records a vertex array object
  31132. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31133. * @param vertexBuffers defines the list of vertex buffers to store
  31134. * @param indexBuffer defines the index buffer to store
  31135. * @param effect defines the effect to store
  31136. * @returns the new vertex array object
  31137. */
  31138. recordVertexArrayObject(vertexBuffers: {
  31139. [key: string]: VertexBuffer;
  31140. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  31141. /**
  31142. * Bind a specific vertex array object
  31143. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31144. * @param vertexArrayObject defines the vertex array object to bind
  31145. * @param indexBuffer defines the index buffer to bind
  31146. */
  31147. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  31148. /**
  31149. * Bind webGl buffers directly to the webGL context
  31150. * @param vertexBuffer defines the vertex buffer to bind
  31151. * @param indexBuffer defines the index buffer to bind
  31152. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  31153. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  31154. * @param effect defines the effect associated with the vertex buffer
  31155. */
  31156. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  31157. private _unbindVertexArrayObject;
  31158. /**
  31159. * Bind a list of vertex buffers to the webGL context
  31160. * @param vertexBuffers defines the list of vertex buffers to bind
  31161. * @param indexBuffer defines the index buffer to bind
  31162. * @param effect defines the effect associated with the vertex buffers
  31163. */
  31164. bindBuffers(vertexBuffers: {
  31165. [key: string]: Nullable<VertexBuffer>;
  31166. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  31167. /**
  31168. * Unbind all instance attributes
  31169. */
  31170. unbindInstanceAttributes(): void;
  31171. /**
  31172. * Release and free the memory of a vertex array object
  31173. * @param vao defines the vertex array object to delete
  31174. */
  31175. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  31176. /** @hidden */
  31177. _releaseBuffer(buffer: DataBuffer): boolean;
  31178. protected _deleteBuffer(buffer: DataBuffer): void;
  31179. /**
  31180. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  31181. * @param instancesBuffer defines the webGL buffer to update and bind
  31182. * @param data defines the data to store in the buffer
  31183. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  31184. */
  31185. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  31186. /**
  31187. * Bind the content of a webGL buffer used with instanciation
  31188. * @param instancesBuffer defines the webGL buffer to bind
  31189. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  31190. * @param computeStride defines Wether to compute the strides from the info or use the default 0
  31191. */
  31192. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  31193. /**
  31194. * Disable the instance attribute corresponding to the name in parameter
  31195. * @param name defines the name of the attribute to disable
  31196. */
  31197. disableInstanceAttributeByName(name: string): void;
  31198. /**
  31199. * Disable the instance attribute corresponding to the location in parameter
  31200. * @param attributeLocation defines the attribute location of the attribute to disable
  31201. */
  31202. disableInstanceAttribute(attributeLocation: number): void;
  31203. /**
  31204. * Disable the attribute corresponding to the location in parameter
  31205. * @param attributeLocation defines the attribute location of the attribute to disable
  31206. */
  31207. disableAttributeByIndex(attributeLocation: number): void;
  31208. /**
  31209. * Send a draw order
  31210. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31211. * @param indexStart defines the starting index
  31212. * @param indexCount defines the number of index to draw
  31213. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31214. */
  31215. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  31216. /**
  31217. * Draw a list of points
  31218. * @param verticesStart defines the index of first vertex to draw
  31219. * @param verticesCount defines the count of vertices to draw
  31220. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31221. */
  31222. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31223. /**
  31224. * Draw a list of unindexed primitives
  31225. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31226. * @param verticesStart defines the index of first vertex to draw
  31227. * @param verticesCount defines the count of vertices to draw
  31228. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31229. */
  31230. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31231. /**
  31232. * Draw a list of indexed primitives
  31233. * @param fillMode defines the primitive to use
  31234. * @param indexStart defines the starting index
  31235. * @param indexCount defines the number of index to draw
  31236. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31237. */
  31238. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  31239. /**
  31240. * Draw a list of unindexed primitives
  31241. * @param fillMode defines the primitive to use
  31242. * @param verticesStart defines the index of first vertex to draw
  31243. * @param verticesCount defines the count of vertices to draw
  31244. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31245. */
  31246. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31247. private _drawMode;
  31248. /** @hidden */
  31249. protected _reportDrawCall(): void;
  31250. /** @hidden */
  31251. _releaseEffect(effect: Effect): void;
  31252. /** @hidden */
  31253. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  31254. /**
  31255. * Create a new effect (used to store vertex/fragment shaders)
  31256. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  31257. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  31258. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  31259. * @param samplers defines an array of string used to represent textures
  31260. * @param defines defines the string containing the defines to use to compile the shaders
  31261. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  31262. * @param onCompiled defines a function to call when the effect creation is successful
  31263. * @param onError defines a function to call when the effect creation has failed
  31264. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  31265. * @returns the new Effect
  31266. */
  31267. 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;
  31268. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  31269. private _compileShader;
  31270. private _compileRawShader;
  31271. /**
  31272. * Directly creates a webGL program
  31273. * @param pipelineContext defines the pipeline context to attach to
  31274. * @param vertexCode defines the vertex shader code to use
  31275. * @param fragmentCode defines the fragment shader code to use
  31276. * @param context defines the webGL context to use (if not set, the current one will be used)
  31277. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31278. * @returns the new webGL program
  31279. */
  31280. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31281. /**
  31282. * Creates a webGL program
  31283. * @param pipelineContext defines the pipeline context to attach to
  31284. * @param vertexCode defines the vertex shader code to use
  31285. * @param fragmentCode defines the fragment shader code to use
  31286. * @param defines defines the string containing the defines to use to compile the shaders
  31287. * @param context defines the webGL context to use (if not set, the current one will be used)
  31288. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31289. * @returns the new webGL program
  31290. */
  31291. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31292. /**
  31293. * Creates a new pipeline context
  31294. * @returns the new pipeline
  31295. */
  31296. createPipelineContext(): IPipelineContext;
  31297. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31298. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  31299. /** @hidden */
  31300. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  31301. /** @hidden */
  31302. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  31303. /** @hidden */
  31304. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  31305. /**
  31306. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  31307. * @param pipelineContext defines the pipeline context to use
  31308. * @param uniformsNames defines the list of uniform names
  31309. * @returns an array of webGL uniform locations
  31310. */
  31311. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  31312. /**
  31313. * Gets the lsit of active attributes for a given webGL program
  31314. * @param pipelineContext defines the pipeline context to use
  31315. * @param attributesNames defines the list of attribute names to get
  31316. * @returns an array of indices indicating the offset of each attribute
  31317. */
  31318. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  31319. /**
  31320. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  31321. * @param effect defines the effect to activate
  31322. */
  31323. enableEffect(effect: Nullable<Effect>): void;
  31324. /**
  31325. * Set the value of an uniform to a number (int)
  31326. * @param uniform defines the webGL uniform location where to store the value
  31327. * @param value defines the int number to store
  31328. */
  31329. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31330. /**
  31331. * Set the value of an uniform to an array of int32
  31332. * @param uniform defines the webGL uniform location where to store the value
  31333. * @param array defines the array of int32 to store
  31334. */
  31335. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31336. /**
  31337. * Set the value of an uniform to an array of int32 (stored as vec2)
  31338. * @param uniform defines the webGL uniform location where to store the value
  31339. * @param array defines the array of int32 to store
  31340. */
  31341. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31342. /**
  31343. * Set the value of an uniform to an array of int32 (stored as vec3)
  31344. * @param uniform defines the webGL uniform location where to store the value
  31345. * @param array defines the array of int32 to store
  31346. */
  31347. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31348. /**
  31349. * Set the value of an uniform to an array of int32 (stored as vec4)
  31350. * @param uniform defines the webGL uniform location where to store the value
  31351. * @param array defines the array of int32 to store
  31352. */
  31353. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31354. /**
  31355. * Set the value of an uniform to an array of number
  31356. * @param uniform defines the webGL uniform location where to store the value
  31357. * @param array defines the array of number to store
  31358. */
  31359. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31360. /**
  31361. * Set the value of an uniform to an array of number (stored as vec2)
  31362. * @param uniform defines the webGL uniform location where to store the value
  31363. * @param array defines the array of number to store
  31364. */
  31365. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31366. /**
  31367. * Set the value of an uniform to an array of number (stored as vec3)
  31368. * @param uniform defines the webGL uniform location where to store the value
  31369. * @param array defines the array of number to store
  31370. */
  31371. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31372. /**
  31373. * Set the value of an uniform to an array of number (stored as vec4)
  31374. * @param uniform defines the webGL uniform location where to store the value
  31375. * @param array defines the array of number to store
  31376. */
  31377. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31378. /**
  31379. * Set the value of an uniform to an array of float32 (stored as matrices)
  31380. * @param uniform defines the webGL uniform location where to store the value
  31381. * @param matrices defines the array of float32 to store
  31382. */
  31383. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  31384. /**
  31385. * Set the value of an uniform to a matrix (3x3)
  31386. * @param uniform defines the webGL uniform location where to store the value
  31387. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  31388. */
  31389. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31390. /**
  31391. * Set the value of an uniform to a matrix (2x2)
  31392. * @param uniform defines the webGL uniform location where to store the value
  31393. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  31394. */
  31395. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31396. /**
  31397. * Set the value of an uniform to a number (float)
  31398. * @param uniform defines the webGL uniform location where to store the value
  31399. * @param value defines the float number to store
  31400. */
  31401. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31402. /**
  31403. * Set the value of an uniform to a vec2
  31404. * @param uniform defines the webGL uniform location where to store the value
  31405. * @param x defines the 1st component of the value
  31406. * @param y defines the 2nd component of the value
  31407. */
  31408. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  31409. /**
  31410. * Set the value of an uniform to a vec3
  31411. * @param uniform defines the webGL uniform location where to store the value
  31412. * @param x defines the 1st component of the value
  31413. * @param y defines the 2nd component of the value
  31414. * @param z defines the 3rd component of the value
  31415. */
  31416. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  31417. /**
  31418. * Set the value of an uniform to a vec4
  31419. * @param uniform defines the webGL uniform location where to store the value
  31420. * @param x defines the 1st component of the value
  31421. * @param y defines the 2nd component of the value
  31422. * @param z defines the 3rd component of the value
  31423. * @param w defines the 4th component of the value
  31424. */
  31425. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  31426. /**
  31427. * Apply all cached states (depth, culling, stencil and alpha)
  31428. */
  31429. applyStates(): void;
  31430. /**
  31431. * Enable or disable color writing
  31432. * @param enable defines the state to set
  31433. */
  31434. setColorWrite(enable: boolean): void;
  31435. /**
  31436. * Gets a boolean indicating if color writing is enabled
  31437. * @returns the current color writing state
  31438. */
  31439. getColorWrite(): boolean;
  31440. /**
  31441. * Gets the depth culling state manager
  31442. */
  31443. get depthCullingState(): DepthCullingState;
  31444. /**
  31445. * Gets the alpha state manager
  31446. */
  31447. get alphaState(): AlphaState;
  31448. /**
  31449. * Gets the stencil state manager
  31450. */
  31451. get stencilState(): StencilState;
  31452. /**
  31453. * Clears the list of texture accessible through engine.
  31454. * This can help preventing texture load conflict due to name collision.
  31455. */
  31456. clearInternalTexturesCache(): void;
  31457. /**
  31458. * Force the entire cache to be cleared
  31459. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  31460. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  31461. */
  31462. wipeCaches(bruteForce?: boolean): void;
  31463. /** @hidden */
  31464. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  31465. min: number;
  31466. mag: number;
  31467. };
  31468. /** @hidden */
  31469. _createTexture(): WebGLTexture;
  31470. /**
  31471. * Usually called from Texture.ts.
  31472. * Passed information to create a WebGLTexture
  31473. * @param urlArg defines a value which contains one of the following:
  31474. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  31475. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  31476. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  31477. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  31478. * @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)
  31479. * @param scene needed for loading to the correct scene
  31480. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  31481. * @param onLoad optional callback to be called upon successful completion
  31482. * @param onError optional callback to be called upon failure
  31483. * @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
  31484. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  31485. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  31486. * @param forcedExtension defines the extension to use to pick the right loader
  31487. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  31488. * @param mimeType defines an optional mime type
  31489. * @returns a InternalTexture for assignment back into BABYLON.Texture
  31490. */
  31491. 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;
  31492. /**
  31493. * @hidden
  31494. */
  31495. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  31496. /**
  31497. * Creates a raw texture
  31498. * @param data defines the data to store in the texture
  31499. * @param width defines the width of the texture
  31500. * @param height defines the height of the texture
  31501. * @param format defines the format of the data
  31502. * @param generateMipMaps defines if the engine should generate the mip levels
  31503. * @param invertY defines if data must be stored with Y axis inverted
  31504. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  31505. * @param compression defines the compression used (null by default)
  31506. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  31507. * @returns the raw texture inside an InternalTexture
  31508. */
  31509. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  31510. /**
  31511. * Creates a new raw cube texture
  31512. * @param data defines the array of data to use to create each face
  31513. * @param size defines the size of the textures
  31514. * @param format defines the format of the data
  31515. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  31516. * @param generateMipMaps defines if the engine should generate the mip levels
  31517. * @param invertY defines if data must be stored with Y axis inverted
  31518. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31519. * @param compression defines the compression used (null by default)
  31520. * @returns the cube texture as an InternalTexture
  31521. */
  31522. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  31523. /**
  31524. * Creates a new raw 3D texture
  31525. * @param data defines the data used to create the texture
  31526. * @param width defines the width of the texture
  31527. * @param height defines the height of the texture
  31528. * @param depth defines the depth of the texture
  31529. * @param format defines the format of the texture
  31530. * @param generateMipMaps defines if the engine must generate mip levels
  31531. * @param invertY defines if data must be stored with Y axis inverted
  31532. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31533. * @param compression defines the compressed used (can be null)
  31534. * @param textureType defines the compressed used (can be null)
  31535. * @returns a new raw 3D texture (stored in an InternalTexture)
  31536. */
  31537. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  31538. /**
  31539. * Creates a new raw 2D array texture
  31540. * @param data defines the data used to create the texture
  31541. * @param width defines the width of the texture
  31542. * @param height defines the height of the texture
  31543. * @param depth defines the number of layers of the texture
  31544. * @param format defines the format of the texture
  31545. * @param generateMipMaps defines if the engine must generate mip levels
  31546. * @param invertY defines if data must be stored with Y axis inverted
  31547. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31548. * @param compression defines the compressed used (can be null)
  31549. * @param textureType defines the compressed used (can be null)
  31550. * @returns a new raw 2D array texture (stored in an InternalTexture)
  31551. */
  31552. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  31553. private _unpackFlipYCached;
  31554. /**
  31555. * In case you are sharing the context with other applications, it might
  31556. * be interested to not cache the unpack flip y state to ensure a consistent
  31557. * value would be set.
  31558. */
  31559. enableUnpackFlipYCached: boolean;
  31560. /** @hidden */
  31561. _unpackFlipY(value: boolean): void;
  31562. /** @hidden */
  31563. _getUnpackAlignement(): number;
  31564. private _getTextureTarget;
  31565. /**
  31566. * Update the sampling mode of a given texture
  31567. * @param samplingMode defines the required sampling mode
  31568. * @param texture defines the texture to update
  31569. * @param generateMipMaps defines whether to generate mipmaps for the texture
  31570. */
  31571. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  31572. /**
  31573. * Update the sampling mode of a given texture
  31574. * @param texture defines the texture to update
  31575. * @param wrapU defines the texture wrap mode of the u coordinates
  31576. * @param wrapV defines the texture wrap mode of the v coordinates
  31577. * @param wrapR defines the texture wrap mode of the r coordinates
  31578. */
  31579. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  31580. /** @hidden */
  31581. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  31582. width: number;
  31583. height: number;
  31584. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  31585. /** @hidden */
  31586. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31587. /** @hidden */
  31588. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  31589. /** @hidden */
  31590. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31591. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  31592. private _prepareWebGLTexture;
  31593. /** @hidden */
  31594. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  31595. private _getDepthStencilBuffer;
  31596. /** @hidden */
  31597. _releaseFramebufferObjects(texture: InternalTexture): void;
  31598. /** @hidden */
  31599. _releaseTexture(texture: InternalTexture): void;
  31600. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  31601. protected _setProgram(program: WebGLProgram): void;
  31602. protected _boundUniforms: {
  31603. [key: number]: WebGLUniformLocation;
  31604. };
  31605. /**
  31606. * Binds an effect to the webGL context
  31607. * @param effect defines the effect to bind
  31608. */
  31609. bindSamplers(effect: Effect): void;
  31610. private _activateCurrentTexture;
  31611. /** @hidden */
  31612. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  31613. /** @hidden */
  31614. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  31615. /**
  31616. * Unbind all textures from the webGL context
  31617. */
  31618. unbindAllTextures(): void;
  31619. /**
  31620. * Sets a texture to the according uniform.
  31621. * @param channel The texture channel
  31622. * @param uniform The uniform to set
  31623. * @param texture The texture to apply
  31624. */
  31625. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  31626. private _bindSamplerUniformToChannel;
  31627. private _getTextureWrapMode;
  31628. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  31629. /**
  31630. * Sets an array of texture to the webGL context
  31631. * @param channel defines the channel where the texture array must be set
  31632. * @param uniform defines the associated uniform location
  31633. * @param textures defines the array of textures to bind
  31634. */
  31635. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  31636. /** @hidden */
  31637. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  31638. private _setTextureParameterFloat;
  31639. private _setTextureParameterInteger;
  31640. /**
  31641. * Unbind all vertex attributes from the webGL context
  31642. */
  31643. unbindAllAttributes(): void;
  31644. /**
  31645. * 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
  31646. */
  31647. releaseEffects(): void;
  31648. /**
  31649. * Dispose and release all associated resources
  31650. */
  31651. dispose(): void;
  31652. /**
  31653. * Attach a new callback raised when context lost event is fired
  31654. * @param callback defines the callback to call
  31655. */
  31656. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31657. /**
  31658. * Attach a new callback raised when context restored event is fired
  31659. * @param callback defines the callback to call
  31660. */
  31661. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31662. /**
  31663. * Get the current error code of the webGL context
  31664. * @returns the error code
  31665. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  31666. */
  31667. getError(): number;
  31668. private _canRenderToFloatFramebuffer;
  31669. private _canRenderToHalfFloatFramebuffer;
  31670. private _canRenderToFramebuffer;
  31671. /** @hidden */
  31672. _getWebGLTextureType(type: number): number;
  31673. /** @hidden */
  31674. _getInternalFormat(format: number): number;
  31675. /** @hidden */
  31676. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  31677. /** @hidden */
  31678. _getRGBAMultiSampleBufferFormat(type: number): number;
  31679. /** @hidden */
  31680. _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;
  31681. /**
  31682. * Reads pixels from the current frame buffer. Please note that this function can be slow
  31683. * @param x defines the x coordinate of the rectangle where pixels must be read
  31684. * @param y defines the y coordinate of the rectangle where pixels must be read
  31685. * @param width defines the width of the rectangle where pixels must be read
  31686. * @param height defines the height of the rectangle where pixels must be read
  31687. * @param hasAlpha defines wether the output should have alpha or not (defaults to true)
  31688. * @returns a Uint8Array containing RGBA colors
  31689. */
  31690. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  31691. private static _isSupported;
  31692. /**
  31693. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  31694. * @returns true if the engine can be created
  31695. * @ignorenaming
  31696. */
  31697. static isSupported(): boolean;
  31698. /**
  31699. * Find the next highest power of two.
  31700. * @param x Number to start search from.
  31701. * @return Next highest power of two.
  31702. */
  31703. static CeilingPOT(x: number): number;
  31704. /**
  31705. * Find the next lowest power of two.
  31706. * @param x Number to start search from.
  31707. * @return Next lowest power of two.
  31708. */
  31709. static FloorPOT(x: number): number;
  31710. /**
  31711. * Find the nearest power of two.
  31712. * @param x Number to start search from.
  31713. * @return Next nearest power of two.
  31714. */
  31715. static NearestPOT(x: number): number;
  31716. /**
  31717. * Get the closest exponent of two
  31718. * @param value defines the value to approximate
  31719. * @param max defines the maximum value to return
  31720. * @param mode defines how to define the closest value
  31721. * @returns closest exponent of two of the given value
  31722. */
  31723. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31724. /**
  31725. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31726. * @param func - the function to be called
  31727. * @param requester - the object that will request the next frame. Falls back to window.
  31728. * @returns frame number
  31729. */
  31730. static QueueNewFrame(func: () => void, requester?: any): number;
  31731. /**
  31732. * Gets host document
  31733. * @returns the host document object
  31734. */
  31735. getHostDocument(): Nullable<Document>;
  31736. }
  31737. }
  31738. declare module BABYLON {
  31739. /**
  31740. * Class representing spherical harmonics coefficients to the 3rd degree
  31741. */
  31742. export class SphericalHarmonics {
  31743. /**
  31744. * Defines whether or not the harmonics have been prescaled for rendering.
  31745. */
  31746. preScaled: boolean;
  31747. /**
  31748. * The l0,0 coefficients of the spherical harmonics
  31749. */
  31750. l00: Vector3;
  31751. /**
  31752. * The l1,-1 coefficients of the spherical harmonics
  31753. */
  31754. l1_1: Vector3;
  31755. /**
  31756. * The l1,0 coefficients of the spherical harmonics
  31757. */
  31758. l10: Vector3;
  31759. /**
  31760. * The l1,1 coefficients of the spherical harmonics
  31761. */
  31762. l11: Vector3;
  31763. /**
  31764. * The l2,-2 coefficients of the spherical harmonics
  31765. */
  31766. l2_2: Vector3;
  31767. /**
  31768. * The l2,-1 coefficients of the spherical harmonics
  31769. */
  31770. l2_1: Vector3;
  31771. /**
  31772. * The l2,0 coefficients of the spherical harmonics
  31773. */
  31774. l20: Vector3;
  31775. /**
  31776. * The l2,1 coefficients of the spherical harmonics
  31777. */
  31778. l21: Vector3;
  31779. /**
  31780. * The l2,2 coefficients of the spherical harmonics
  31781. */
  31782. l22: Vector3;
  31783. /**
  31784. * Adds a light to the spherical harmonics
  31785. * @param direction the direction of the light
  31786. * @param color the color of the light
  31787. * @param deltaSolidAngle the delta solid angle of the light
  31788. */
  31789. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  31790. /**
  31791. * Scales the spherical harmonics by the given amount
  31792. * @param scale the amount to scale
  31793. */
  31794. scaleInPlace(scale: number): void;
  31795. /**
  31796. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  31797. *
  31798. * ```
  31799. * E_lm = A_l * L_lm
  31800. * ```
  31801. *
  31802. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  31803. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  31804. * the scaling factors are given in equation 9.
  31805. */
  31806. convertIncidentRadianceToIrradiance(): void;
  31807. /**
  31808. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  31809. *
  31810. * ```
  31811. * L = (1/pi) * E * rho
  31812. * ```
  31813. *
  31814. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  31815. */
  31816. convertIrradianceToLambertianRadiance(): void;
  31817. /**
  31818. * Integrates the reconstruction coefficients directly in to the SH preventing further
  31819. * required operations at run time.
  31820. *
  31821. * This is simply done by scaling back the SH with Ylm constants parameter.
  31822. * The trigonometric part being applied by the shader at run time.
  31823. */
  31824. preScaleForRendering(): void;
  31825. /**
  31826. * Constructs a spherical harmonics from an array.
  31827. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  31828. * @returns the spherical harmonics
  31829. */
  31830. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  31831. /**
  31832. * Gets the spherical harmonics from polynomial
  31833. * @param polynomial the spherical polynomial
  31834. * @returns the spherical harmonics
  31835. */
  31836. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  31837. }
  31838. /**
  31839. * Class representing spherical polynomial coefficients to the 3rd degree
  31840. */
  31841. export class SphericalPolynomial {
  31842. private _harmonics;
  31843. /**
  31844. * The spherical harmonics used to create the polynomials.
  31845. */
  31846. get preScaledHarmonics(): SphericalHarmonics;
  31847. /**
  31848. * The x coefficients of the spherical polynomial
  31849. */
  31850. x: Vector3;
  31851. /**
  31852. * The y coefficients of the spherical polynomial
  31853. */
  31854. y: Vector3;
  31855. /**
  31856. * The z coefficients of the spherical polynomial
  31857. */
  31858. z: Vector3;
  31859. /**
  31860. * The xx coefficients of the spherical polynomial
  31861. */
  31862. xx: Vector3;
  31863. /**
  31864. * The yy coefficients of the spherical polynomial
  31865. */
  31866. yy: Vector3;
  31867. /**
  31868. * The zz coefficients of the spherical polynomial
  31869. */
  31870. zz: Vector3;
  31871. /**
  31872. * The xy coefficients of the spherical polynomial
  31873. */
  31874. xy: Vector3;
  31875. /**
  31876. * The yz coefficients of the spherical polynomial
  31877. */
  31878. yz: Vector3;
  31879. /**
  31880. * The zx coefficients of the spherical polynomial
  31881. */
  31882. zx: Vector3;
  31883. /**
  31884. * Adds an ambient color to the spherical polynomial
  31885. * @param color the color to add
  31886. */
  31887. addAmbient(color: Color3): void;
  31888. /**
  31889. * Scales the spherical polynomial by the given amount
  31890. * @param scale the amount to scale
  31891. */
  31892. scaleInPlace(scale: number): void;
  31893. /**
  31894. * Gets the spherical polynomial from harmonics
  31895. * @param harmonics the spherical harmonics
  31896. * @returns the spherical polynomial
  31897. */
  31898. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  31899. /**
  31900. * Constructs a spherical polynomial from an array.
  31901. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  31902. * @returns the spherical polynomial
  31903. */
  31904. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  31905. }
  31906. }
  31907. declare module BABYLON {
  31908. /**
  31909. * Defines the source of the internal texture
  31910. */
  31911. export enum InternalTextureSource {
  31912. /**
  31913. * The source of the texture data is unknown
  31914. */
  31915. Unknown = 0,
  31916. /**
  31917. * Texture data comes from an URL
  31918. */
  31919. Url = 1,
  31920. /**
  31921. * Texture data is only used for temporary storage
  31922. */
  31923. Temp = 2,
  31924. /**
  31925. * Texture data comes from raw data (ArrayBuffer)
  31926. */
  31927. Raw = 3,
  31928. /**
  31929. * Texture content is dynamic (video or dynamic texture)
  31930. */
  31931. Dynamic = 4,
  31932. /**
  31933. * Texture content is generated by rendering to it
  31934. */
  31935. RenderTarget = 5,
  31936. /**
  31937. * Texture content is part of a multi render target process
  31938. */
  31939. MultiRenderTarget = 6,
  31940. /**
  31941. * Texture data comes from a cube data file
  31942. */
  31943. Cube = 7,
  31944. /**
  31945. * Texture data comes from a raw cube data
  31946. */
  31947. CubeRaw = 8,
  31948. /**
  31949. * Texture data come from a prefiltered cube data file
  31950. */
  31951. CubePrefiltered = 9,
  31952. /**
  31953. * Texture content is raw 3D data
  31954. */
  31955. Raw3D = 10,
  31956. /**
  31957. * Texture content is raw 2D array data
  31958. */
  31959. Raw2DArray = 11,
  31960. /**
  31961. * Texture content is a depth texture
  31962. */
  31963. Depth = 12,
  31964. /**
  31965. * Texture data comes from a raw cube data encoded with RGBD
  31966. */
  31967. CubeRawRGBD = 13
  31968. }
  31969. /**
  31970. * Class used to store data associated with WebGL texture data for the engine
  31971. * This class should not be used directly
  31972. */
  31973. export class InternalTexture {
  31974. /** @hidden */
  31975. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  31976. /**
  31977. * Defines if the texture is ready
  31978. */
  31979. isReady: boolean;
  31980. /**
  31981. * Defines if the texture is a cube texture
  31982. */
  31983. isCube: boolean;
  31984. /**
  31985. * Defines if the texture contains 3D data
  31986. */
  31987. is3D: boolean;
  31988. /**
  31989. * Defines if the texture contains 2D array data
  31990. */
  31991. is2DArray: boolean;
  31992. /**
  31993. * Defines if the texture contains multiview data
  31994. */
  31995. isMultiview: boolean;
  31996. /**
  31997. * Gets the URL used to load this texture
  31998. */
  31999. url: string;
  32000. /**
  32001. * Gets the sampling mode of the texture
  32002. */
  32003. samplingMode: number;
  32004. /**
  32005. * Gets a boolean indicating if the texture needs mipmaps generation
  32006. */
  32007. generateMipMaps: boolean;
  32008. /**
  32009. * Gets the number of samples used by the texture (WebGL2+ only)
  32010. */
  32011. samples: number;
  32012. /**
  32013. * Gets the type of the texture (int, float...)
  32014. */
  32015. type: number;
  32016. /**
  32017. * Gets the format of the texture (RGB, RGBA...)
  32018. */
  32019. format: number;
  32020. /**
  32021. * Observable called when the texture is loaded
  32022. */
  32023. onLoadedObservable: Observable<InternalTexture>;
  32024. /**
  32025. * Gets the width of the texture
  32026. */
  32027. width: number;
  32028. /**
  32029. * Gets the height of the texture
  32030. */
  32031. height: number;
  32032. /**
  32033. * Gets the depth of the texture
  32034. */
  32035. depth: number;
  32036. /**
  32037. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  32038. */
  32039. baseWidth: number;
  32040. /**
  32041. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  32042. */
  32043. baseHeight: number;
  32044. /**
  32045. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  32046. */
  32047. baseDepth: number;
  32048. /**
  32049. * Gets a boolean indicating if the texture is inverted on Y axis
  32050. */
  32051. invertY: boolean;
  32052. /** @hidden */
  32053. _invertVScale: boolean;
  32054. /** @hidden */
  32055. _associatedChannel: number;
  32056. /** @hidden */
  32057. _source: InternalTextureSource;
  32058. /** @hidden */
  32059. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  32060. /** @hidden */
  32061. _bufferView: Nullable<ArrayBufferView>;
  32062. /** @hidden */
  32063. _bufferViewArray: Nullable<ArrayBufferView[]>;
  32064. /** @hidden */
  32065. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  32066. /** @hidden */
  32067. _size: number;
  32068. /** @hidden */
  32069. _extension: string;
  32070. /** @hidden */
  32071. _files: Nullable<string[]>;
  32072. /** @hidden */
  32073. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  32074. /** @hidden */
  32075. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  32076. /** @hidden */
  32077. _framebuffer: Nullable<WebGLFramebuffer>;
  32078. /** @hidden */
  32079. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  32080. /** @hidden */
  32081. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  32082. /** @hidden */
  32083. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  32084. /** @hidden */
  32085. _attachments: Nullable<number[]>;
  32086. /** @hidden */
  32087. _cachedCoordinatesMode: Nullable<number>;
  32088. /** @hidden */
  32089. _cachedWrapU: Nullable<number>;
  32090. /** @hidden */
  32091. _cachedWrapV: Nullable<number>;
  32092. /** @hidden */
  32093. _cachedWrapR: Nullable<number>;
  32094. /** @hidden */
  32095. _cachedAnisotropicFilteringLevel: Nullable<number>;
  32096. /** @hidden */
  32097. _isDisabled: boolean;
  32098. /** @hidden */
  32099. _compression: Nullable<string>;
  32100. /** @hidden */
  32101. _generateStencilBuffer: boolean;
  32102. /** @hidden */
  32103. _generateDepthBuffer: boolean;
  32104. /** @hidden */
  32105. _comparisonFunction: number;
  32106. /** @hidden */
  32107. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  32108. /** @hidden */
  32109. _lodGenerationScale: number;
  32110. /** @hidden */
  32111. _lodGenerationOffset: number;
  32112. /** @hidden */
  32113. _colorTextureArray: Nullable<WebGLTexture>;
  32114. /** @hidden */
  32115. _depthStencilTextureArray: Nullable<WebGLTexture>;
  32116. /** @hidden */
  32117. _lodTextureHigh: Nullable<BaseTexture>;
  32118. /** @hidden */
  32119. _lodTextureMid: Nullable<BaseTexture>;
  32120. /** @hidden */
  32121. _lodTextureLow: Nullable<BaseTexture>;
  32122. /** @hidden */
  32123. _isRGBD: boolean;
  32124. /** @hidden */
  32125. _linearSpecularLOD: boolean;
  32126. /** @hidden */
  32127. _irradianceTexture: Nullable<BaseTexture>;
  32128. /** @hidden */
  32129. _webGLTexture: Nullable<WebGLTexture>;
  32130. /** @hidden */
  32131. _references: number;
  32132. private _engine;
  32133. /**
  32134. * Gets the Engine the texture belongs to.
  32135. * @returns The babylon engine
  32136. */
  32137. getEngine(): ThinEngine;
  32138. /**
  32139. * Gets the data source type of the texture
  32140. */
  32141. get source(): InternalTextureSource;
  32142. /**
  32143. * Creates a new InternalTexture
  32144. * @param engine defines the engine to use
  32145. * @param source defines the type of data that will be used
  32146. * @param delayAllocation if the texture allocation should be delayed (default: false)
  32147. */
  32148. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  32149. /**
  32150. * Increments the number of references (ie. the number of Texture that point to it)
  32151. */
  32152. incrementReferences(): void;
  32153. /**
  32154. * Change the size of the texture (not the size of the content)
  32155. * @param width defines the new width
  32156. * @param height defines the new height
  32157. * @param depth defines the new depth (1 by default)
  32158. */
  32159. updateSize(width: int, height: int, depth?: int): void;
  32160. /** @hidden */
  32161. _rebuild(): void;
  32162. /** @hidden */
  32163. _swapAndDie(target: InternalTexture): void;
  32164. /**
  32165. * Dispose the current allocated resources
  32166. */
  32167. dispose(): void;
  32168. }
  32169. }
  32170. declare module BABYLON {
  32171. /**
  32172. * Class used to work with sound analyzer using fast fourier transform (FFT)
  32173. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32174. */
  32175. export class Analyser {
  32176. /**
  32177. * Gets or sets the smoothing
  32178. * @ignorenaming
  32179. */
  32180. SMOOTHING: number;
  32181. /**
  32182. * Gets or sets the FFT table size
  32183. * @ignorenaming
  32184. */
  32185. FFT_SIZE: number;
  32186. /**
  32187. * Gets or sets the bar graph amplitude
  32188. * @ignorenaming
  32189. */
  32190. BARGRAPHAMPLITUDE: number;
  32191. /**
  32192. * Gets or sets the position of the debug canvas
  32193. * @ignorenaming
  32194. */
  32195. DEBUGCANVASPOS: {
  32196. x: number;
  32197. y: number;
  32198. };
  32199. /**
  32200. * Gets or sets the debug canvas size
  32201. * @ignorenaming
  32202. */
  32203. DEBUGCANVASSIZE: {
  32204. width: number;
  32205. height: number;
  32206. };
  32207. private _byteFreqs;
  32208. private _byteTime;
  32209. private _floatFreqs;
  32210. private _webAudioAnalyser;
  32211. private _debugCanvas;
  32212. private _debugCanvasContext;
  32213. private _scene;
  32214. private _registerFunc;
  32215. private _audioEngine;
  32216. /**
  32217. * Creates a new analyser
  32218. * @param scene defines hosting scene
  32219. */
  32220. constructor(scene: Scene);
  32221. /**
  32222. * Get the number of data values you will have to play with for the visualization
  32223. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  32224. * @returns a number
  32225. */
  32226. getFrequencyBinCount(): number;
  32227. /**
  32228. * Gets the current frequency data as a byte array
  32229. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  32230. * @returns a Uint8Array
  32231. */
  32232. getByteFrequencyData(): Uint8Array;
  32233. /**
  32234. * Gets the current waveform as a byte array
  32235. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  32236. * @returns a Uint8Array
  32237. */
  32238. getByteTimeDomainData(): Uint8Array;
  32239. /**
  32240. * Gets the current frequency data as a float array
  32241. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  32242. * @returns a Float32Array
  32243. */
  32244. getFloatFrequencyData(): Float32Array;
  32245. /**
  32246. * Renders the debug canvas
  32247. */
  32248. drawDebugCanvas(): void;
  32249. /**
  32250. * Stops rendering the debug canvas and removes it
  32251. */
  32252. stopDebugCanvas(): void;
  32253. /**
  32254. * Connects two audio nodes
  32255. * @param inputAudioNode defines first node to connect
  32256. * @param outputAudioNode defines second node to connect
  32257. */
  32258. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  32259. /**
  32260. * Releases all associated resources
  32261. */
  32262. dispose(): void;
  32263. }
  32264. }
  32265. declare module BABYLON {
  32266. /**
  32267. * This represents an audio engine and it is responsible
  32268. * to play, synchronize and analyse sounds throughout the application.
  32269. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32270. */
  32271. export interface IAudioEngine extends IDisposable {
  32272. /**
  32273. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  32274. */
  32275. readonly canUseWebAudio: boolean;
  32276. /**
  32277. * Gets the current AudioContext if available.
  32278. */
  32279. readonly audioContext: Nullable<AudioContext>;
  32280. /**
  32281. * The master gain node defines the global audio volume of your audio engine.
  32282. */
  32283. readonly masterGain: GainNode;
  32284. /**
  32285. * Gets whether or not mp3 are supported by your browser.
  32286. */
  32287. readonly isMP3supported: boolean;
  32288. /**
  32289. * Gets whether or not ogg are supported by your browser.
  32290. */
  32291. readonly isOGGsupported: boolean;
  32292. /**
  32293. * Defines if Babylon should emit a warning if WebAudio is not supported.
  32294. * @ignoreNaming
  32295. */
  32296. WarnedWebAudioUnsupported: boolean;
  32297. /**
  32298. * Defines if the audio engine relies on a custom unlocked button.
  32299. * In this case, the embedded button will not be displayed.
  32300. */
  32301. useCustomUnlockedButton: boolean;
  32302. /**
  32303. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  32304. */
  32305. readonly unlocked: boolean;
  32306. /**
  32307. * Event raised when audio has been unlocked on the browser.
  32308. */
  32309. onAudioUnlockedObservable: Observable<AudioEngine>;
  32310. /**
  32311. * Event raised when audio has been locked on the browser.
  32312. */
  32313. onAudioLockedObservable: Observable<AudioEngine>;
  32314. /**
  32315. * Flags the audio engine in Locked state.
  32316. * This happens due to new browser policies preventing audio to autoplay.
  32317. */
  32318. lock(): void;
  32319. /**
  32320. * Unlocks the audio engine once a user action has been done on the dom.
  32321. * This is helpful to resume play once browser policies have been satisfied.
  32322. */
  32323. unlock(): void;
  32324. }
  32325. /**
  32326. * This represents the default audio engine used in babylon.
  32327. * It is responsible to play, synchronize and analyse sounds throughout the application.
  32328. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32329. */
  32330. export class AudioEngine implements IAudioEngine {
  32331. private _audioContext;
  32332. private _audioContextInitialized;
  32333. private _muteButton;
  32334. private _hostElement;
  32335. /**
  32336. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  32337. */
  32338. canUseWebAudio: boolean;
  32339. /**
  32340. * The master gain node defines the global audio volume of your audio engine.
  32341. */
  32342. masterGain: GainNode;
  32343. /**
  32344. * Defines if Babylon should emit a warning if WebAudio is not supported.
  32345. * @ignoreNaming
  32346. */
  32347. WarnedWebAudioUnsupported: boolean;
  32348. /**
  32349. * Gets whether or not mp3 are supported by your browser.
  32350. */
  32351. isMP3supported: boolean;
  32352. /**
  32353. * Gets whether or not ogg are supported by your browser.
  32354. */
  32355. isOGGsupported: boolean;
  32356. /**
  32357. * Gets whether audio has been unlocked on the device.
  32358. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  32359. * a user interaction has happened.
  32360. */
  32361. unlocked: boolean;
  32362. /**
  32363. * Defines if the audio engine relies on a custom unlocked button.
  32364. * In this case, the embedded button will not be displayed.
  32365. */
  32366. useCustomUnlockedButton: boolean;
  32367. /**
  32368. * Event raised when audio has been unlocked on the browser.
  32369. */
  32370. onAudioUnlockedObservable: Observable<AudioEngine>;
  32371. /**
  32372. * Event raised when audio has been locked on the browser.
  32373. */
  32374. onAudioLockedObservable: Observable<AudioEngine>;
  32375. /**
  32376. * Gets the current AudioContext if available.
  32377. */
  32378. get audioContext(): Nullable<AudioContext>;
  32379. private _connectedAnalyser;
  32380. /**
  32381. * Instantiates a new audio engine.
  32382. *
  32383. * There should be only one per page as some browsers restrict the number
  32384. * of audio contexts you can create.
  32385. * @param hostElement defines the host element where to display the mute icon if necessary
  32386. */
  32387. constructor(hostElement?: Nullable<HTMLElement>);
  32388. /**
  32389. * Flags the audio engine in Locked state.
  32390. * This happens due to new browser policies preventing audio to autoplay.
  32391. */
  32392. lock(): void;
  32393. /**
  32394. * Unlocks the audio engine once a user action has been done on the dom.
  32395. * This is helpful to resume play once browser policies have been satisfied.
  32396. */
  32397. unlock(): void;
  32398. private _resumeAudioContext;
  32399. private _initializeAudioContext;
  32400. private _tryToRun;
  32401. private _triggerRunningState;
  32402. private _triggerSuspendedState;
  32403. private _displayMuteButton;
  32404. private _moveButtonToTopLeft;
  32405. private _onResize;
  32406. private _hideMuteButton;
  32407. /**
  32408. * Destroy and release the resources associated with the audio ccontext.
  32409. */
  32410. dispose(): void;
  32411. /**
  32412. * Gets the global volume sets on the master gain.
  32413. * @returns the global volume if set or -1 otherwise
  32414. */
  32415. getGlobalVolume(): number;
  32416. /**
  32417. * Sets the global volume of your experience (sets on the master gain).
  32418. * @param newVolume Defines the new global volume of the application
  32419. */
  32420. setGlobalVolume(newVolume: number): void;
  32421. /**
  32422. * Connect the audio engine to an audio analyser allowing some amazing
  32423. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  32424. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  32425. * @param analyser The analyser to connect to the engine
  32426. */
  32427. connectToAnalyser(analyser: Analyser): void;
  32428. }
  32429. }
  32430. declare module BABYLON {
  32431. /**
  32432. * Interface used to present a loading screen while loading a scene
  32433. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32434. */
  32435. export interface ILoadingScreen {
  32436. /**
  32437. * Function called to display the loading screen
  32438. */
  32439. displayLoadingUI: () => void;
  32440. /**
  32441. * Function called to hide the loading screen
  32442. */
  32443. hideLoadingUI: () => void;
  32444. /**
  32445. * Gets or sets the color to use for the background
  32446. */
  32447. loadingUIBackgroundColor: string;
  32448. /**
  32449. * Gets or sets the text to display while loading
  32450. */
  32451. loadingUIText: string;
  32452. }
  32453. /**
  32454. * Class used for the default loading screen
  32455. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32456. */
  32457. export class DefaultLoadingScreen implements ILoadingScreen {
  32458. private _renderingCanvas;
  32459. private _loadingText;
  32460. private _loadingDivBackgroundColor;
  32461. private _loadingDiv;
  32462. private _loadingTextDiv;
  32463. /** Gets or sets the logo url to use for the default loading screen */
  32464. static DefaultLogoUrl: string;
  32465. /** Gets or sets the spinner url to use for the default loading screen */
  32466. static DefaultSpinnerUrl: string;
  32467. /**
  32468. * Creates a new default loading screen
  32469. * @param _renderingCanvas defines the canvas used to render the scene
  32470. * @param _loadingText defines the default text to display
  32471. * @param _loadingDivBackgroundColor defines the default background color
  32472. */
  32473. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  32474. /**
  32475. * Function called to display the loading screen
  32476. */
  32477. displayLoadingUI(): void;
  32478. /**
  32479. * Function called to hide the loading screen
  32480. */
  32481. hideLoadingUI(): void;
  32482. /**
  32483. * Gets or sets the text to display while loading
  32484. */
  32485. set loadingUIText(text: string);
  32486. get loadingUIText(): string;
  32487. /**
  32488. * Gets or sets the color to use for the background
  32489. */
  32490. get loadingUIBackgroundColor(): string;
  32491. set loadingUIBackgroundColor(color: string);
  32492. private _resizeLoadingUI;
  32493. }
  32494. }
  32495. declare module BABYLON {
  32496. /**
  32497. * Interface for any object that can request an animation frame
  32498. */
  32499. export interface ICustomAnimationFrameRequester {
  32500. /**
  32501. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  32502. */
  32503. renderFunction?: Function;
  32504. /**
  32505. * Called to request the next frame to render to
  32506. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  32507. */
  32508. requestAnimationFrame: Function;
  32509. /**
  32510. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  32511. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  32512. */
  32513. requestID?: number;
  32514. }
  32515. }
  32516. declare module BABYLON {
  32517. /**
  32518. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  32519. */
  32520. export class PerformanceMonitor {
  32521. private _enabled;
  32522. private _rollingFrameTime;
  32523. private _lastFrameTimeMs;
  32524. /**
  32525. * constructor
  32526. * @param frameSampleSize The number of samples required to saturate the sliding window
  32527. */
  32528. constructor(frameSampleSize?: number);
  32529. /**
  32530. * Samples current frame
  32531. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  32532. */
  32533. sampleFrame(timeMs?: number): void;
  32534. /**
  32535. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  32536. */
  32537. get averageFrameTime(): number;
  32538. /**
  32539. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  32540. */
  32541. get averageFrameTimeVariance(): number;
  32542. /**
  32543. * Returns the frame time of the most recent frame
  32544. */
  32545. get instantaneousFrameTime(): number;
  32546. /**
  32547. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  32548. */
  32549. get averageFPS(): number;
  32550. /**
  32551. * Returns the average framerate in frames per second using the most recent frame time
  32552. */
  32553. get instantaneousFPS(): number;
  32554. /**
  32555. * Returns true if enough samples have been taken to completely fill the sliding window
  32556. */
  32557. get isSaturated(): boolean;
  32558. /**
  32559. * Enables contributions to the sliding window sample set
  32560. */
  32561. enable(): void;
  32562. /**
  32563. * Disables contributions to the sliding window sample set
  32564. * Samples will not be interpolated over the disabled period
  32565. */
  32566. disable(): void;
  32567. /**
  32568. * Returns true if sampling is enabled
  32569. */
  32570. get isEnabled(): boolean;
  32571. /**
  32572. * Resets performance monitor
  32573. */
  32574. reset(): void;
  32575. }
  32576. /**
  32577. * RollingAverage
  32578. *
  32579. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  32580. */
  32581. export class RollingAverage {
  32582. /**
  32583. * Current average
  32584. */
  32585. average: number;
  32586. /**
  32587. * Current variance
  32588. */
  32589. variance: number;
  32590. protected _samples: Array<number>;
  32591. protected _sampleCount: number;
  32592. protected _pos: number;
  32593. protected _m2: number;
  32594. /**
  32595. * constructor
  32596. * @param length The number of samples required to saturate the sliding window
  32597. */
  32598. constructor(length: number);
  32599. /**
  32600. * Adds a sample to the sample set
  32601. * @param v The sample value
  32602. */
  32603. add(v: number): void;
  32604. /**
  32605. * Returns previously added values or null if outside of history or outside the sliding window domain
  32606. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  32607. * @return Value previously recorded with add() or null if outside of range
  32608. */
  32609. history(i: number): number;
  32610. /**
  32611. * Returns true if enough samples have been taken to completely fill the sliding window
  32612. * @return true if sample-set saturated
  32613. */
  32614. isSaturated(): boolean;
  32615. /**
  32616. * Resets the rolling average (equivalent to 0 samples taken so far)
  32617. */
  32618. reset(): void;
  32619. /**
  32620. * Wraps a value around the sample range boundaries
  32621. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  32622. * @return Wrapped position in sample range
  32623. */
  32624. protected _wrapPosition(i: number): number;
  32625. }
  32626. }
  32627. declare module BABYLON {
  32628. /**
  32629. * This class is used to track a performance counter which is number based.
  32630. * The user has access to many properties which give statistics of different nature.
  32631. *
  32632. * The implementer can track two kinds of Performance Counter: time and count.
  32633. * 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.
  32634. * 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.
  32635. */
  32636. export class PerfCounter {
  32637. /**
  32638. * Gets or sets a global boolean to turn on and off all the counters
  32639. */
  32640. static Enabled: boolean;
  32641. /**
  32642. * Returns the smallest value ever
  32643. */
  32644. get min(): number;
  32645. /**
  32646. * Returns the biggest value ever
  32647. */
  32648. get max(): number;
  32649. /**
  32650. * Returns the average value since the performance counter is running
  32651. */
  32652. get average(): number;
  32653. /**
  32654. * Returns the average value of the last second the counter was monitored
  32655. */
  32656. get lastSecAverage(): number;
  32657. /**
  32658. * Returns the current value
  32659. */
  32660. get current(): number;
  32661. /**
  32662. * Gets the accumulated total
  32663. */
  32664. get total(): number;
  32665. /**
  32666. * Gets the total value count
  32667. */
  32668. get count(): number;
  32669. /**
  32670. * Creates a new counter
  32671. */
  32672. constructor();
  32673. /**
  32674. * Call this method to start monitoring a new frame.
  32675. * 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.
  32676. */
  32677. fetchNewFrame(): void;
  32678. /**
  32679. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  32680. * @param newCount the count value to add to the monitored count
  32681. * @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.
  32682. */
  32683. addCount(newCount: number, fetchResult: boolean): void;
  32684. /**
  32685. * Start monitoring this performance counter
  32686. */
  32687. beginMonitoring(): void;
  32688. /**
  32689. * Compute the time lapsed since the previous beginMonitoring() call.
  32690. * @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
  32691. */
  32692. endMonitoring(newFrame?: boolean): void;
  32693. private _fetchResult;
  32694. private _startMonitoringTime;
  32695. private _min;
  32696. private _max;
  32697. private _average;
  32698. private _current;
  32699. private _totalValueCount;
  32700. private _totalAccumulated;
  32701. private _lastSecAverage;
  32702. private _lastSecAccumulated;
  32703. private _lastSecTime;
  32704. private _lastSecValueCount;
  32705. }
  32706. }
  32707. declare module BABYLON {
  32708. interface ThinEngine {
  32709. /**
  32710. * Sets alpha constants used by some alpha blending modes
  32711. * @param r defines the red component
  32712. * @param g defines the green component
  32713. * @param b defines the blue component
  32714. * @param a defines the alpha component
  32715. */
  32716. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  32717. /**
  32718. * Sets the current alpha mode
  32719. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  32720. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  32721. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32722. */
  32723. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  32724. /**
  32725. * Gets the current alpha mode
  32726. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32727. * @returns the current alpha mode
  32728. */
  32729. getAlphaMode(): number;
  32730. /**
  32731. * Sets the current alpha equation
  32732. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  32733. */
  32734. setAlphaEquation(equation: number): void;
  32735. /**
  32736. * Gets the current alpha equation.
  32737. * @returns the current alpha equation
  32738. */
  32739. getAlphaEquation(): number;
  32740. }
  32741. }
  32742. declare module BABYLON {
  32743. /**
  32744. * Defines the interface used by display changed events
  32745. */
  32746. export interface IDisplayChangedEventArgs {
  32747. /** Gets the vrDisplay object (if any) */
  32748. vrDisplay: Nullable<any>;
  32749. /** Gets a boolean indicating if webVR is supported */
  32750. vrSupported: boolean;
  32751. }
  32752. /**
  32753. * Defines the interface used by objects containing a viewport (like a camera)
  32754. */
  32755. interface IViewportOwnerLike {
  32756. /**
  32757. * Gets or sets the viewport
  32758. */
  32759. viewport: IViewportLike;
  32760. }
  32761. /**
  32762. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  32763. */
  32764. export class Engine extends ThinEngine {
  32765. /** Defines that alpha blending is disabled */
  32766. static readonly ALPHA_DISABLE: number;
  32767. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  32768. static readonly ALPHA_ADD: number;
  32769. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  32770. static readonly ALPHA_COMBINE: number;
  32771. /** Defines that alpha blending to DEST - SRC * DEST */
  32772. static readonly ALPHA_SUBTRACT: number;
  32773. /** Defines that alpha blending to SRC * DEST */
  32774. static readonly ALPHA_MULTIPLY: number;
  32775. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  32776. static readonly ALPHA_MAXIMIZED: number;
  32777. /** Defines that alpha blending to SRC + DEST */
  32778. static readonly ALPHA_ONEONE: number;
  32779. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  32780. static readonly ALPHA_PREMULTIPLIED: number;
  32781. /**
  32782. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  32783. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  32784. */
  32785. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  32786. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  32787. static readonly ALPHA_INTERPOLATE: number;
  32788. /**
  32789. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  32790. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  32791. */
  32792. static readonly ALPHA_SCREENMODE: number;
  32793. /** Defines that the ressource is not delayed*/
  32794. static readonly DELAYLOADSTATE_NONE: number;
  32795. /** Defines that the ressource was successfully delay loaded */
  32796. static readonly DELAYLOADSTATE_LOADED: number;
  32797. /** Defines that the ressource is currently delay loading */
  32798. static readonly DELAYLOADSTATE_LOADING: number;
  32799. /** Defines that the ressource is delayed and has not started loading */
  32800. static readonly DELAYLOADSTATE_NOTLOADED: number;
  32801. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  32802. static readonly NEVER: number;
  32803. /** 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 */
  32804. static readonly ALWAYS: number;
  32805. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  32806. static readonly LESS: number;
  32807. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  32808. static readonly EQUAL: number;
  32809. /** 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 */
  32810. static readonly LEQUAL: number;
  32811. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  32812. static readonly GREATER: number;
  32813. /** 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 */
  32814. static readonly GEQUAL: number;
  32815. /** 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 */
  32816. static readonly NOTEQUAL: number;
  32817. /** Passed to stencilOperation to specify that stencil value must be kept */
  32818. static readonly KEEP: number;
  32819. /** Passed to stencilOperation to specify that stencil value must be replaced */
  32820. static readonly REPLACE: number;
  32821. /** Passed to stencilOperation to specify that stencil value must be incremented */
  32822. static readonly INCR: number;
  32823. /** Passed to stencilOperation to specify that stencil value must be decremented */
  32824. static readonly DECR: number;
  32825. /** Passed to stencilOperation to specify that stencil value must be inverted */
  32826. static readonly INVERT: number;
  32827. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  32828. static readonly INCR_WRAP: number;
  32829. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  32830. static readonly DECR_WRAP: number;
  32831. /** Texture is not repeating outside of 0..1 UVs */
  32832. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  32833. /** Texture is repeating outside of 0..1 UVs */
  32834. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  32835. /** Texture is repeating and mirrored */
  32836. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  32837. /** ALPHA */
  32838. static readonly TEXTUREFORMAT_ALPHA: number;
  32839. /** LUMINANCE */
  32840. static readonly TEXTUREFORMAT_LUMINANCE: number;
  32841. /** LUMINANCE_ALPHA */
  32842. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  32843. /** RGB */
  32844. static readonly TEXTUREFORMAT_RGB: number;
  32845. /** RGBA */
  32846. static readonly TEXTUREFORMAT_RGBA: number;
  32847. /** RED */
  32848. static readonly TEXTUREFORMAT_RED: number;
  32849. /** RED (2nd reference) */
  32850. static readonly TEXTUREFORMAT_R: number;
  32851. /** RG */
  32852. static readonly TEXTUREFORMAT_RG: number;
  32853. /** RED_INTEGER */
  32854. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  32855. /** RED_INTEGER (2nd reference) */
  32856. static readonly TEXTUREFORMAT_R_INTEGER: number;
  32857. /** RG_INTEGER */
  32858. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  32859. /** RGB_INTEGER */
  32860. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  32861. /** RGBA_INTEGER */
  32862. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  32863. /** UNSIGNED_BYTE */
  32864. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  32865. /** UNSIGNED_BYTE (2nd reference) */
  32866. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  32867. /** FLOAT */
  32868. static readonly TEXTURETYPE_FLOAT: number;
  32869. /** HALF_FLOAT */
  32870. static readonly TEXTURETYPE_HALF_FLOAT: number;
  32871. /** BYTE */
  32872. static readonly TEXTURETYPE_BYTE: number;
  32873. /** SHORT */
  32874. static readonly TEXTURETYPE_SHORT: number;
  32875. /** UNSIGNED_SHORT */
  32876. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  32877. /** INT */
  32878. static readonly TEXTURETYPE_INT: number;
  32879. /** UNSIGNED_INT */
  32880. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  32881. /** UNSIGNED_SHORT_4_4_4_4 */
  32882. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  32883. /** UNSIGNED_SHORT_5_5_5_1 */
  32884. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  32885. /** UNSIGNED_SHORT_5_6_5 */
  32886. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  32887. /** UNSIGNED_INT_2_10_10_10_REV */
  32888. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  32889. /** UNSIGNED_INT_24_8 */
  32890. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  32891. /** UNSIGNED_INT_10F_11F_11F_REV */
  32892. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  32893. /** UNSIGNED_INT_5_9_9_9_REV */
  32894. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  32895. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  32896. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  32897. /** nearest is mag = nearest and min = nearest and mip = linear */
  32898. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  32899. /** Bilinear is mag = linear and min = linear and mip = nearest */
  32900. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  32901. /** Trilinear is mag = linear and min = linear and mip = linear */
  32902. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  32903. /** nearest is mag = nearest and min = nearest and mip = linear */
  32904. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  32905. /** Bilinear is mag = linear and min = linear and mip = nearest */
  32906. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  32907. /** Trilinear is mag = linear and min = linear and mip = linear */
  32908. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  32909. /** mag = nearest and min = nearest and mip = nearest */
  32910. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  32911. /** mag = nearest and min = linear and mip = nearest */
  32912. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  32913. /** mag = nearest and min = linear and mip = linear */
  32914. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  32915. /** mag = nearest and min = linear and mip = none */
  32916. static readonly TEXTURE_NEAREST_LINEAR: number;
  32917. /** mag = nearest and min = nearest and mip = none */
  32918. static readonly TEXTURE_NEAREST_NEAREST: number;
  32919. /** mag = linear and min = nearest and mip = nearest */
  32920. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  32921. /** mag = linear and min = nearest and mip = linear */
  32922. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  32923. /** mag = linear and min = linear and mip = none */
  32924. static readonly TEXTURE_LINEAR_LINEAR: number;
  32925. /** mag = linear and min = nearest and mip = none */
  32926. static readonly TEXTURE_LINEAR_NEAREST: number;
  32927. /** Explicit coordinates mode */
  32928. static readonly TEXTURE_EXPLICIT_MODE: number;
  32929. /** Spherical coordinates mode */
  32930. static readonly TEXTURE_SPHERICAL_MODE: number;
  32931. /** Planar coordinates mode */
  32932. static readonly TEXTURE_PLANAR_MODE: number;
  32933. /** Cubic coordinates mode */
  32934. static readonly TEXTURE_CUBIC_MODE: number;
  32935. /** Projection coordinates mode */
  32936. static readonly TEXTURE_PROJECTION_MODE: number;
  32937. /** Skybox coordinates mode */
  32938. static readonly TEXTURE_SKYBOX_MODE: number;
  32939. /** Inverse Cubic coordinates mode */
  32940. static readonly TEXTURE_INVCUBIC_MODE: number;
  32941. /** Equirectangular coordinates mode */
  32942. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  32943. /** Equirectangular Fixed coordinates mode */
  32944. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  32945. /** Equirectangular Fixed Mirrored coordinates mode */
  32946. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  32947. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  32948. static readonly SCALEMODE_FLOOR: number;
  32949. /** Defines that texture rescaling will look for the nearest power of 2 size */
  32950. static readonly SCALEMODE_NEAREST: number;
  32951. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  32952. static readonly SCALEMODE_CEILING: number;
  32953. /**
  32954. * Returns the current npm package of the sdk
  32955. */
  32956. static get NpmPackage(): string;
  32957. /**
  32958. * Returns the current version of the framework
  32959. */
  32960. static get Version(): string;
  32961. /** Gets the list of created engines */
  32962. static get Instances(): Engine[];
  32963. /**
  32964. * Gets the latest created engine
  32965. */
  32966. static get LastCreatedEngine(): Nullable<Engine>;
  32967. /**
  32968. * Gets the latest created scene
  32969. */
  32970. static get LastCreatedScene(): Nullable<Scene>;
  32971. /**
  32972. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  32973. * @param flag defines which part of the materials must be marked as dirty
  32974. * @param predicate defines a predicate used to filter which materials should be affected
  32975. */
  32976. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  32977. /**
  32978. * Method called to create the default loading screen.
  32979. * This can be overriden in your own app.
  32980. * @param canvas The rendering canvas element
  32981. * @returns The loading screen
  32982. */
  32983. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  32984. /**
  32985. * Method called to create the default rescale post process on each engine.
  32986. */
  32987. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  32988. /**
  32989. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  32990. **/
  32991. enableOfflineSupport: boolean;
  32992. /**
  32993. * 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)
  32994. **/
  32995. disableManifestCheck: boolean;
  32996. /**
  32997. * Gets the list of created scenes
  32998. */
  32999. scenes: Scene[];
  33000. /**
  33001. * Event raised when a new scene is created
  33002. */
  33003. onNewSceneAddedObservable: Observable<Scene>;
  33004. /**
  33005. * Gets the list of created postprocesses
  33006. */
  33007. postProcesses: PostProcess[];
  33008. /**
  33009. * Gets a boolean indicating if the pointer is currently locked
  33010. */
  33011. isPointerLock: boolean;
  33012. /**
  33013. * Observable event triggered each time the rendering canvas is resized
  33014. */
  33015. onResizeObservable: Observable<Engine>;
  33016. /**
  33017. * Observable event triggered each time the canvas loses focus
  33018. */
  33019. onCanvasBlurObservable: Observable<Engine>;
  33020. /**
  33021. * Observable event triggered each time the canvas gains focus
  33022. */
  33023. onCanvasFocusObservable: Observable<Engine>;
  33024. /**
  33025. * Observable event triggered each time the canvas receives pointerout event
  33026. */
  33027. onCanvasPointerOutObservable: Observable<PointerEvent>;
  33028. /**
  33029. * Observable raised when the engine begins a new frame
  33030. */
  33031. onBeginFrameObservable: Observable<Engine>;
  33032. /**
  33033. * If set, will be used to request the next animation frame for the render loop
  33034. */
  33035. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  33036. /**
  33037. * Observable raised when the engine ends the current frame
  33038. */
  33039. onEndFrameObservable: Observable<Engine>;
  33040. /**
  33041. * Observable raised when the engine is about to compile a shader
  33042. */
  33043. onBeforeShaderCompilationObservable: Observable<Engine>;
  33044. /**
  33045. * Observable raised when the engine has jsut compiled a shader
  33046. */
  33047. onAfterShaderCompilationObservable: Observable<Engine>;
  33048. /**
  33049. * Gets the audio engine
  33050. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33051. * @ignorenaming
  33052. */
  33053. static audioEngine: IAudioEngine;
  33054. /**
  33055. * Default AudioEngine factory responsible of creating the Audio Engine.
  33056. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  33057. */
  33058. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  33059. /**
  33060. * Default offline support factory responsible of creating a tool used to store data locally.
  33061. * By default, this will create a Database object if the workload has been embedded.
  33062. */
  33063. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  33064. private _loadingScreen;
  33065. private _pointerLockRequested;
  33066. private _dummyFramebuffer;
  33067. private _rescalePostProcess;
  33068. private _deterministicLockstep;
  33069. private _lockstepMaxSteps;
  33070. private _timeStep;
  33071. protected get _supportsHardwareTextureRescaling(): boolean;
  33072. private _fps;
  33073. private _deltaTime;
  33074. /** @hidden */
  33075. _drawCalls: PerfCounter;
  33076. /**
  33077. * Turn this value on if you want to pause FPS computation when in background
  33078. */
  33079. disablePerformanceMonitorInBackground: boolean;
  33080. private _performanceMonitor;
  33081. /**
  33082. * Gets the performance monitor attached to this engine
  33083. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  33084. */
  33085. get performanceMonitor(): PerformanceMonitor;
  33086. private _onFocus;
  33087. private _onBlur;
  33088. private _onCanvasPointerOut;
  33089. private _onCanvasBlur;
  33090. private _onCanvasFocus;
  33091. private _onFullscreenChange;
  33092. private _onPointerLockChange;
  33093. /**
  33094. * Gets the HTML element used to attach event listeners
  33095. * @returns a HTML element
  33096. */
  33097. getInputElement(): Nullable<HTMLElement>;
  33098. /**
  33099. * Creates a new engine
  33100. * @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
  33101. * @param antialias defines enable antialiasing (default: false)
  33102. * @param options defines further options to be sent to the getContext() function
  33103. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  33104. */
  33105. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  33106. /**
  33107. * Gets current aspect ratio
  33108. * @param viewportOwner defines the camera to use to get the aspect ratio
  33109. * @param useScreen defines if screen size must be used (or the current render target if any)
  33110. * @returns a number defining the aspect ratio
  33111. */
  33112. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  33113. /**
  33114. * Gets current screen aspect ratio
  33115. * @returns a number defining the aspect ratio
  33116. */
  33117. getScreenAspectRatio(): number;
  33118. /**
  33119. * Gets the client rect of the HTML canvas attached with the current webGL context
  33120. * @returns a client rectanglee
  33121. */
  33122. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  33123. /**
  33124. * Gets the client rect of the HTML element used for events
  33125. * @returns a client rectanglee
  33126. */
  33127. getInputElementClientRect(): Nullable<ClientRect>;
  33128. /**
  33129. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  33130. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33131. * @returns true if engine is in deterministic lock step mode
  33132. */
  33133. isDeterministicLockStep(): boolean;
  33134. /**
  33135. * Gets the max steps when engine is running in deterministic lock step
  33136. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33137. * @returns the max steps
  33138. */
  33139. getLockstepMaxSteps(): number;
  33140. /**
  33141. * Returns the time in ms between steps when using deterministic lock step.
  33142. * @returns time step in (ms)
  33143. */
  33144. getTimeStep(): number;
  33145. /**
  33146. * Force the mipmap generation for the given render target texture
  33147. * @param texture defines the render target texture to use
  33148. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  33149. */
  33150. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  33151. /** States */
  33152. /**
  33153. * Set various states to the webGL context
  33154. * @param culling defines backface culling state
  33155. * @param zOffset defines the value to apply to zOffset (0 by default)
  33156. * @param force defines if states must be applied even if cache is up to date
  33157. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  33158. */
  33159. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  33160. /**
  33161. * Set the z offset to apply to current rendering
  33162. * @param value defines the offset to apply
  33163. */
  33164. setZOffset(value: number): void;
  33165. /**
  33166. * Gets the current value of the zOffset
  33167. * @returns the current zOffset state
  33168. */
  33169. getZOffset(): number;
  33170. /**
  33171. * Enable or disable depth buffering
  33172. * @param enable defines the state to set
  33173. */
  33174. setDepthBuffer(enable: boolean): void;
  33175. /**
  33176. * Gets a boolean indicating if depth writing is enabled
  33177. * @returns the current depth writing state
  33178. */
  33179. getDepthWrite(): boolean;
  33180. /**
  33181. * Enable or disable depth writing
  33182. * @param enable defines the state to set
  33183. */
  33184. setDepthWrite(enable: boolean): void;
  33185. /**
  33186. * Gets a boolean indicating if stencil buffer is enabled
  33187. * @returns the current stencil buffer state
  33188. */
  33189. getStencilBuffer(): boolean;
  33190. /**
  33191. * Enable or disable the stencil buffer
  33192. * @param enable defines if the stencil buffer must be enabled or disabled
  33193. */
  33194. setStencilBuffer(enable: boolean): void;
  33195. /**
  33196. * Gets the current stencil mask
  33197. * @returns a number defining the new stencil mask to use
  33198. */
  33199. getStencilMask(): number;
  33200. /**
  33201. * Sets the current stencil mask
  33202. * @param mask defines the new stencil mask to use
  33203. */
  33204. setStencilMask(mask: number): void;
  33205. /**
  33206. * Gets the current stencil function
  33207. * @returns a number defining the stencil function to use
  33208. */
  33209. getStencilFunction(): number;
  33210. /**
  33211. * Gets the current stencil reference value
  33212. * @returns a number defining the stencil reference value to use
  33213. */
  33214. getStencilFunctionReference(): number;
  33215. /**
  33216. * Gets the current stencil mask
  33217. * @returns a number defining the stencil mask to use
  33218. */
  33219. getStencilFunctionMask(): number;
  33220. /**
  33221. * Sets the current stencil function
  33222. * @param stencilFunc defines the new stencil function to use
  33223. */
  33224. setStencilFunction(stencilFunc: number): void;
  33225. /**
  33226. * Sets the current stencil reference
  33227. * @param reference defines the new stencil reference to use
  33228. */
  33229. setStencilFunctionReference(reference: number): void;
  33230. /**
  33231. * Sets the current stencil mask
  33232. * @param mask defines the new stencil mask to use
  33233. */
  33234. setStencilFunctionMask(mask: number): void;
  33235. /**
  33236. * Gets the current stencil operation when stencil fails
  33237. * @returns a number defining stencil operation to use when stencil fails
  33238. */
  33239. getStencilOperationFail(): number;
  33240. /**
  33241. * Gets the current stencil operation when depth fails
  33242. * @returns a number defining stencil operation to use when depth fails
  33243. */
  33244. getStencilOperationDepthFail(): number;
  33245. /**
  33246. * Gets the current stencil operation when stencil passes
  33247. * @returns a number defining stencil operation to use when stencil passes
  33248. */
  33249. getStencilOperationPass(): number;
  33250. /**
  33251. * Sets the stencil operation to use when stencil fails
  33252. * @param operation defines the stencil operation to use when stencil fails
  33253. */
  33254. setStencilOperationFail(operation: number): void;
  33255. /**
  33256. * Sets the stencil operation to use when depth fails
  33257. * @param operation defines the stencil operation to use when depth fails
  33258. */
  33259. setStencilOperationDepthFail(operation: number): void;
  33260. /**
  33261. * Sets the stencil operation to use when stencil passes
  33262. * @param operation defines the stencil operation to use when stencil passes
  33263. */
  33264. setStencilOperationPass(operation: number): void;
  33265. /**
  33266. * Sets a boolean indicating if the dithering state is enabled or disabled
  33267. * @param value defines the dithering state
  33268. */
  33269. setDitheringState(value: boolean): void;
  33270. /**
  33271. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  33272. * @param value defines the rasterizer state
  33273. */
  33274. setRasterizerState(value: boolean): void;
  33275. /**
  33276. * Gets the current depth function
  33277. * @returns a number defining the depth function
  33278. */
  33279. getDepthFunction(): Nullable<number>;
  33280. /**
  33281. * Sets the current depth function
  33282. * @param depthFunc defines the function to use
  33283. */
  33284. setDepthFunction(depthFunc: number): void;
  33285. /**
  33286. * Sets the current depth function to GREATER
  33287. */
  33288. setDepthFunctionToGreater(): void;
  33289. /**
  33290. * Sets the current depth function to GEQUAL
  33291. */
  33292. setDepthFunctionToGreaterOrEqual(): void;
  33293. /**
  33294. * Sets the current depth function to LESS
  33295. */
  33296. setDepthFunctionToLess(): void;
  33297. /**
  33298. * Sets the current depth function to LEQUAL
  33299. */
  33300. setDepthFunctionToLessOrEqual(): void;
  33301. private _cachedStencilBuffer;
  33302. private _cachedStencilFunction;
  33303. private _cachedStencilMask;
  33304. private _cachedStencilOperationPass;
  33305. private _cachedStencilOperationFail;
  33306. private _cachedStencilOperationDepthFail;
  33307. private _cachedStencilReference;
  33308. /**
  33309. * Caches the the state of the stencil buffer
  33310. */
  33311. cacheStencilState(): void;
  33312. /**
  33313. * Restores the state of the stencil buffer
  33314. */
  33315. restoreStencilState(): void;
  33316. /**
  33317. * Directly set the WebGL Viewport
  33318. * @param x defines the x coordinate of the viewport (in screen space)
  33319. * @param y defines the y coordinate of the viewport (in screen space)
  33320. * @param width defines the width of the viewport (in screen space)
  33321. * @param height defines the height of the viewport (in screen space)
  33322. * @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
  33323. */
  33324. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  33325. /**
  33326. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  33327. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  33328. * @param y defines the y-coordinate of the corner of the clear rectangle
  33329. * @param width defines the width of the clear rectangle
  33330. * @param height defines the height of the clear rectangle
  33331. * @param clearColor defines the clear color
  33332. */
  33333. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  33334. /**
  33335. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  33336. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  33337. * @param y defines the y-coordinate of the corner of the clear rectangle
  33338. * @param width defines the width of the clear rectangle
  33339. * @param height defines the height of the clear rectangle
  33340. */
  33341. enableScissor(x: number, y: number, width: number, height: number): void;
  33342. /**
  33343. * Disable previously set scissor test rectangle
  33344. */
  33345. disableScissor(): void;
  33346. protected _reportDrawCall(): void;
  33347. /**
  33348. * Initializes a webVR display and starts listening to display change events
  33349. * The onVRDisplayChangedObservable will be notified upon these changes
  33350. * @returns The onVRDisplayChangedObservable
  33351. */
  33352. initWebVR(): Observable<IDisplayChangedEventArgs>;
  33353. /** @hidden */
  33354. _prepareVRComponent(): void;
  33355. /** @hidden */
  33356. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  33357. /** @hidden */
  33358. _submitVRFrame(): void;
  33359. /**
  33360. * Call this function to leave webVR mode
  33361. * Will do nothing if webVR is not supported or if there is no webVR device
  33362. * @see http://doc.babylonjs.com/how_to/webvr_camera
  33363. */
  33364. disableVR(): void;
  33365. /**
  33366. * Gets a boolean indicating that the system is in VR mode and is presenting
  33367. * @returns true if VR mode is engaged
  33368. */
  33369. isVRPresenting(): boolean;
  33370. /** @hidden */
  33371. _requestVRFrame(): void;
  33372. /** @hidden */
  33373. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  33374. /**
  33375. * Gets the source code of the vertex shader associated with a specific webGL program
  33376. * @param program defines the program to use
  33377. * @returns a string containing the source code of the vertex shader associated with the program
  33378. */
  33379. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  33380. /**
  33381. * Gets the source code of the fragment shader associated with a specific webGL program
  33382. * @param program defines the program to use
  33383. * @returns a string containing the source code of the fragment shader associated with the program
  33384. */
  33385. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  33386. /**
  33387. * Sets a depth stencil texture from a render target to the according uniform.
  33388. * @param channel The texture channel
  33389. * @param uniform The uniform to set
  33390. * @param texture The render target texture containing the depth stencil texture to apply
  33391. */
  33392. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  33393. /**
  33394. * Sets a texture to the webGL context from a postprocess
  33395. * @param channel defines the channel to use
  33396. * @param postProcess defines the source postprocess
  33397. */
  33398. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  33399. /**
  33400. * Binds the output of the passed in post process to the texture channel specified
  33401. * @param channel The channel the texture should be bound to
  33402. * @param postProcess The post process which's output should be bound
  33403. */
  33404. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  33405. /** @hidden */
  33406. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  33407. protected _rebuildBuffers(): void;
  33408. /** @hidden */
  33409. _renderFrame(): void;
  33410. _renderLoop(): void;
  33411. /** @hidden */
  33412. _renderViews(): boolean;
  33413. /**
  33414. * Toggle full screen mode
  33415. * @param requestPointerLock defines if a pointer lock should be requested from the user
  33416. */
  33417. switchFullscreen(requestPointerLock: boolean): void;
  33418. /**
  33419. * Enters full screen mode
  33420. * @param requestPointerLock defines if a pointer lock should be requested from the user
  33421. */
  33422. enterFullscreen(requestPointerLock: boolean): void;
  33423. /**
  33424. * Exits full screen mode
  33425. */
  33426. exitFullscreen(): void;
  33427. /**
  33428. * Enters Pointerlock mode
  33429. */
  33430. enterPointerlock(): void;
  33431. /**
  33432. * Exits Pointerlock mode
  33433. */
  33434. exitPointerlock(): void;
  33435. /**
  33436. * Begin a new frame
  33437. */
  33438. beginFrame(): void;
  33439. /**
  33440. * Enf the current frame
  33441. */
  33442. endFrame(): void;
  33443. resize(): void;
  33444. /**
  33445. * Set the compressed texture format to use, based on the formats you have, and the formats
  33446. * supported by the hardware / browser.
  33447. *
  33448. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  33449. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  33450. * to API arguments needed to compressed textures. This puts the burden on the container
  33451. * generator to house the arcane code for determining these for current & future formats.
  33452. *
  33453. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  33454. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  33455. *
  33456. * Note: The result of this call is not taken into account when a texture is base64.
  33457. *
  33458. * @param formatsAvailable defines the list of those format families you have created
  33459. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  33460. *
  33461. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  33462. * @returns The extension selected.
  33463. */
  33464. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  33465. /**
  33466. * Set the compressed texture extensions or file names to skip.
  33467. *
  33468. * @param skippedFiles defines the list of those texture files you want to skip
  33469. * Example: [".dds", ".env", "myfile.png"]
  33470. */
  33471. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  33472. /**
  33473. * Force a specific size of the canvas
  33474. * @param width defines the new canvas' width
  33475. * @param height defines the new canvas' height
  33476. */
  33477. setSize(width: number, height: number): void;
  33478. /**
  33479. * Updates a dynamic vertex buffer.
  33480. * @param vertexBuffer the vertex buffer to update
  33481. * @param data the data used to update the vertex buffer
  33482. * @param byteOffset the byte offset of the data
  33483. * @param byteLength the byte length of the data
  33484. */
  33485. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  33486. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  33487. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  33488. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  33489. _releaseTexture(texture: InternalTexture): void;
  33490. /**
  33491. * @hidden
  33492. * Rescales a texture
  33493. * @param source input texutre
  33494. * @param destination destination texture
  33495. * @param scene scene to use to render the resize
  33496. * @param internalFormat format to use when resizing
  33497. * @param onComplete callback to be called when resize has completed
  33498. */
  33499. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  33500. /**
  33501. * Gets the current framerate
  33502. * @returns a number representing the framerate
  33503. */
  33504. getFps(): number;
  33505. /**
  33506. * Gets the time spent between current and previous frame
  33507. * @returns a number representing the delta time in ms
  33508. */
  33509. getDeltaTime(): number;
  33510. private _measureFps;
  33511. /** @hidden */
  33512. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  33513. /**
  33514. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  33515. * @param renderTarget The render target to set the frame buffer for
  33516. */
  33517. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  33518. /**
  33519. * Update a dynamic index buffer
  33520. * @param indexBuffer defines the target index buffer
  33521. * @param indices defines the data to update
  33522. * @param offset defines the offset in the target index buffer where update should start
  33523. */
  33524. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  33525. /**
  33526. * Updates the sample count of a render target texture
  33527. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  33528. * @param texture defines the texture to update
  33529. * @param samples defines the sample count to set
  33530. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  33531. */
  33532. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  33533. /**
  33534. * Updates a depth texture Comparison Mode and Function.
  33535. * If the comparison Function is equal to 0, the mode will be set to none.
  33536. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  33537. * @param texture The texture to set the comparison function for
  33538. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  33539. */
  33540. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  33541. /**
  33542. * Creates a webGL buffer to use with instanciation
  33543. * @param capacity defines the size of the buffer
  33544. * @returns the webGL buffer
  33545. */
  33546. createInstancesBuffer(capacity: number): DataBuffer;
  33547. /**
  33548. * Delete a webGL buffer used with instanciation
  33549. * @param buffer defines the webGL buffer to delete
  33550. */
  33551. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  33552. /** @hidden */
  33553. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  33554. dispose(): void;
  33555. private _disableTouchAction;
  33556. /**
  33557. * Display the loading screen
  33558. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33559. */
  33560. displayLoadingUI(): void;
  33561. /**
  33562. * Hide the loading screen
  33563. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33564. */
  33565. hideLoadingUI(): void;
  33566. /**
  33567. * Gets the current loading screen object
  33568. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33569. */
  33570. get loadingScreen(): ILoadingScreen;
  33571. /**
  33572. * Sets the current loading screen object
  33573. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33574. */
  33575. set loadingScreen(loadingScreen: ILoadingScreen);
  33576. /**
  33577. * Sets the current loading screen text
  33578. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33579. */
  33580. set loadingUIText(text: string);
  33581. /**
  33582. * Sets the current loading screen background color
  33583. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33584. */
  33585. set loadingUIBackgroundColor(color: string);
  33586. /** Pointerlock and fullscreen */
  33587. /**
  33588. * Ask the browser to promote the current element to pointerlock mode
  33589. * @param element defines the DOM element to promote
  33590. */
  33591. static _RequestPointerlock(element: HTMLElement): void;
  33592. /**
  33593. * Asks the browser to exit pointerlock mode
  33594. */
  33595. static _ExitPointerlock(): void;
  33596. /**
  33597. * Ask the browser to promote the current element to fullscreen rendering mode
  33598. * @param element defines the DOM element to promote
  33599. */
  33600. static _RequestFullscreen(element: HTMLElement): void;
  33601. /**
  33602. * Asks the browser to exit fullscreen mode
  33603. */
  33604. static _ExitFullscreen(): void;
  33605. }
  33606. }
  33607. declare module BABYLON {
  33608. /**
  33609. * The engine store class is responsible to hold all the instances of Engine and Scene created
  33610. * during the life time of the application.
  33611. */
  33612. export class EngineStore {
  33613. /** Gets the list of created engines */
  33614. static Instances: Engine[];
  33615. /** @hidden */
  33616. static _LastCreatedScene: Nullable<Scene>;
  33617. /**
  33618. * Gets the latest created engine
  33619. */
  33620. static get LastCreatedEngine(): Nullable<Engine>;
  33621. /**
  33622. * Gets the latest created scene
  33623. */
  33624. static get LastCreatedScene(): Nullable<Scene>;
  33625. /**
  33626. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  33627. * @ignorenaming
  33628. */
  33629. static UseFallbackTexture: boolean;
  33630. /**
  33631. * Texture content used if a texture cannot loaded
  33632. * @ignorenaming
  33633. */
  33634. static FallbackTexture: string;
  33635. }
  33636. }
  33637. declare module BABYLON {
  33638. /**
  33639. * Helper class that provides a small promise polyfill
  33640. */
  33641. export class PromisePolyfill {
  33642. /**
  33643. * Static function used to check if the polyfill is required
  33644. * If this is the case then the function will inject the polyfill to window.Promise
  33645. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  33646. */
  33647. static Apply(force?: boolean): void;
  33648. }
  33649. }
  33650. declare module BABYLON {
  33651. /**
  33652. * Interface for screenshot methods with describe argument called `size` as object with options
  33653. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  33654. */
  33655. export interface IScreenshotSize {
  33656. /**
  33657. * number in pixels for canvas height
  33658. */
  33659. height?: number;
  33660. /**
  33661. * multiplier allowing render at a higher or lower resolution
  33662. * If value is defined then height and width will be ignored and taken from camera
  33663. */
  33664. precision?: number;
  33665. /**
  33666. * number in pixels for canvas width
  33667. */
  33668. width?: number;
  33669. }
  33670. }
  33671. declare module BABYLON {
  33672. interface IColor4Like {
  33673. r: float;
  33674. g: float;
  33675. b: float;
  33676. a: float;
  33677. }
  33678. /**
  33679. * Class containing a set of static utilities functions
  33680. */
  33681. export class Tools {
  33682. /**
  33683. * Gets or sets the base URL to use to load assets
  33684. */
  33685. static get BaseUrl(): string;
  33686. static set BaseUrl(value: string);
  33687. /**
  33688. * Enable/Disable Custom HTTP Request Headers globally.
  33689. * default = false
  33690. * @see CustomRequestHeaders
  33691. */
  33692. static UseCustomRequestHeaders: boolean;
  33693. /**
  33694. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  33695. * i.e. when loading files, where the server/service expects an Authorization header
  33696. */
  33697. static CustomRequestHeaders: {
  33698. [key: string]: string;
  33699. };
  33700. /**
  33701. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  33702. */
  33703. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  33704. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  33705. /**
  33706. * Default behaviour for cors in the application.
  33707. * It can be a string if the expected behavior is identical in the entire app.
  33708. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  33709. */
  33710. static CorsBehavior: string | ((url: string | string[]) => string);
  33711. /**
  33712. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  33713. * @ignorenaming
  33714. */
  33715. static get UseFallbackTexture(): boolean;
  33716. static set UseFallbackTexture(value: boolean);
  33717. /**
  33718. * Use this object to register external classes like custom textures or material
  33719. * to allow the laoders to instantiate them
  33720. */
  33721. static get RegisteredExternalClasses(): {
  33722. [key: string]: Object;
  33723. };
  33724. static set RegisteredExternalClasses(classes: {
  33725. [key: string]: Object;
  33726. });
  33727. /**
  33728. * Texture content used if a texture cannot loaded
  33729. * @ignorenaming
  33730. */
  33731. static get fallbackTexture(): string;
  33732. static set fallbackTexture(value: string);
  33733. /**
  33734. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  33735. * @param u defines the coordinate on X axis
  33736. * @param v defines the coordinate on Y axis
  33737. * @param width defines the width of the source data
  33738. * @param height defines the height of the source data
  33739. * @param pixels defines the source byte array
  33740. * @param color defines the output color
  33741. */
  33742. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  33743. /**
  33744. * Interpolates between a and b via alpha
  33745. * @param a The lower value (returned when alpha = 0)
  33746. * @param b The upper value (returned when alpha = 1)
  33747. * @param alpha The interpolation-factor
  33748. * @return The mixed value
  33749. */
  33750. static Mix(a: number, b: number, alpha: number): number;
  33751. /**
  33752. * Tries to instantiate a new object from a given class name
  33753. * @param className defines the class name to instantiate
  33754. * @returns the new object or null if the system was not able to do the instantiation
  33755. */
  33756. static Instantiate(className: string): any;
  33757. /**
  33758. * Provides a slice function that will work even on IE
  33759. * @param data defines the array to slice
  33760. * @param start defines the start of the data (optional)
  33761. * @param end defines the end of the data (optional)
  33762. * @returns the new sliced array
  33763. */
  33764. static Slice<T>(data: T, start?: number, end?: number): T;
  33765. /**
  33766. * Polyfill for setImmediate
  33767. * @param action defines the action to execute after the current execution block
  33768. */
  33769. static SetImmediate(action: () => void): void;
  33770. /**
  33771. * Function indicating if a number is an exponent of 2
  33772. * @param value defines the value to test
  33773. * @returns true if the value is an exponent of 2
  33774. */
  33775. static IsExponentOfTwo(value: number): boolean;
  33776. private static _tmpFloatArray;
  33777. /**
  33778. * Returns the nearest 32-bit single precision float representation of a Number
  33779. * @param value A Number. If the parameter is of a different type, it will get converted
  33780. * to a number or to NaN if it cannot be converted
  33781. * @returns number
  33782. */
  33783. static FloatRound(value: number): number;
  33784. /**
  33785. * Extracts the filename from a path
  33786. * @param path defines the path to use
  33787. * @returns the filename
  33788. */
  33789. static GetFilename(path: string): string;
  33790. /**
  33791. * Extracts the "folder" part of a path (everything before the filename).
  33792. * @param uri The URI to extract the info from
  33793. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  33794. * @returns The "folder" part of the path
  33795. */
  33796. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  33797. /**
  33798. * Extracts text content from a DOM element hierarchy
  33799. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  33800. */
  33801. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  33802. /**
  33803. * Convert an angle in radians to degrees
  33804. * @param angle defines the angle to convert
  33805. * @returns the angle in degrees
  33806. */
  33807. static ToDegrees(angle: number): number;
  33808. /**
  33809. * Convert an angle in degrees to radians
  33810. * @param angle defines the angle to convert
  33811. * @returns the angle in radians
  33812. */
  33813. static ToRadians(angle: number): number;
  33814. /**
  33815. * Returns an array if obj is not an array
  33816. * @param obj defines the object to evaluate as an array
  33817. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  33818. * @returns either obj directly if obj is an array or a new array containing obj
  33819. */
  33820. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  33821. /**
  33822. * Gets the pointer prefix to use
  33823. * @returns "pointer" if touch is enabled. Else returns "mouse"
  33824. */
  33825. static GetPointerPrefix(): string;
  33826. /**
  33827. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  33828. * @param url define the url we are trying
  33829. * @param element define the dom element where to configure the cors policy
  33830. */
  33831. static SetCorsBehavior(url: string | string[], element: {
  33832. crossOrigin: string | null;
  33833. }): void;
  33834. /**
  33835. * Removes unwanted characters from an url
  33836. * @param url defines the url to clean
  33837. * @returns the cleaned url
  33838. */
  33839. static CleanUrl(url: string): string;
  33840. /**
  33841. * Gets or sets a function used to pre-process url before using them to load assets
  33842. */
  33843. static get PreprocessUrl(): (url: string) => string;
  33844. static set PreprocessUrl(processor: (url: string) => string);
  33845. /**
  33846. * Loads an image as an HTMLImageElement.
  33847. * @param input url string, ArrayBuffer, or Blob to load
  33848. * @param onLoad callback called when the image successfully loads
  33849. * @param onError callback called when the image fails to load
  33850. * @param offlineProvider offline provider for caching
  33851. * @param mimeType optional mime type
  33852. * @returns the HTMLImageElement of the loaded image
  33853. */
  33854. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  33855. /**
  33856. * Loads a file from a url
  33857. * @param url url string, ArrayBuffer, or Blob to load
  33858. * @param onSuccess callback called when the file successfully loads
  33859. * @param onProgress callback called while file is loading (if the server supports this mode)
  33860. * @param offlineProvider defines the offline provider for caching
  33861. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  33862. * @param onError callback called when the file fails to load
  33863. * @returns a file request object
  33864. */
  33865. 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;
  33866. /**
  33867. * Loads a file from a url
  33868. * @param url the file url to load
  33869. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  33870. */
  33871. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  33872. /**
  33873. * Load a script (identified by an url). When the url returns, the
  33874. * content of this file is added into a new script element, attached to the DOM (body element)
  33875. * @param scriptUrl defines the url of the script to laod
  33876. * @param onSuccess defines the callback called when the script is loaded
  33877. * @param onError defines the callback to call if an error occurs
  33878. * @param scriptId defines the id of the script element
  33879. */
  33880. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  33881. /**
  33882. * Load an asynchronous script (identified by an url). When the url returns, the
  33883. * content of this file is added into a new script element, attached to the DOM (body element)
  33884. * @param scriptUrl defines the url of the script to laod
  33885. * @param scriptId defines the id of the script element
  33886. * @returns a promise request object
  33887. */
  33888. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  33889. /**
  33890. * Loads a file from a blob
  33891. * @param fileToLoad defines the blob to use
  33892. * @param callback defines the callback to call when data is loaded
  33893. * @param progressCallback defines the callback to call during loading process
  33894. * @returns a file request object
  33895. */
  33896. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  33897. /**
  33898. * Reads a file from a File object
  33899. * @param file defines the file to load
  33900. * @param onSuccess defines the callback to call when data is loaded
  33901. * @param onProgress defines the callback to call during loading process
  33902. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  33903. * @param onError defines the callback to call when an error occurs
  33904. * @returns a file request object
  33905. */
  33906. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  33907. /**
  33908. * Creates a data url from a given string content
  33909. * @param content defines the content to convert
  33910. * @returns the new data url link
  33911. */
  33912. static FileAsURL(content: string): string;
  33913. /**
  33914. * Format the given number to a specific decimal format
  33915. * @param value defines the number to format
  33916. * @param decimals defines the number of decimals to use
  33917. * @returns the formatted string
  33918. */
  33919. static Format(value: number, decimals?: number): string;
  33920. /**
  33921. * Tries to copy an object by duplicating every property
  33922. * @param source defines the source object
  33923. * @param destination defines the target object
  33924. * @param doNotCopyList defines a list of properties to avoid
  33925. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  33926. */
  33927. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  33928. /**
  33929. * Gets a boolean indicating if the given object has no own property
  33930. * @param obj defines the object to test
  33931. * @returns true if object has no own property
  33932. */
  33933. static IsEmpty(obj: any): boolean;
  33934. /**
  33935. * Function used to register events at window level
  33936. * @param windowElement defines the Window object to use
  33937. * @param events defines the events to register
  33938. */
  33939. static RegisterTopRootEvents(windowElement: Window, events: {
  33940. name: string;
  33941. handler: Nullable<(e: FocusEvent) => any>;
  33942. }[]): void;
  33943. /**
  33944. * Function used to unregister events from window level
  33945. * @param windowElement defines the Window object to use
  33946. * @param events defines the events to unregister
  33947. */
  33948. static UnregisterTopRootEvents(windowElement: Window, events: {
  33949. name: string;
  33950. handler: Nullable<(e: FocusEvent) => any>;
  33951. }[]): void;
  33952. /**
  33953. * @ignore
  33954. */
  33955. static _ScreenshotCanvas: HTMLCanvasElement;
  33956. /**
  33957. * Dumps the current bound framebuffer
  33958. * @param width defines the rendering width
  33959. * @param height defines the rendering height
  33960. * @param engine defines the hosting engine
  33961. * @param successCallback defines the callback triggered once the data are available
  33962. * @param mimeType defines the mime type of the result
  33963. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  33964. */
  33965. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  33966. /**
  33967. * Converts the canvas data to blob.
  33968. * This acts as a polyfill for browsers not supporting the to blob function.
  33969. * @param canvas Defines the canvas to extract the data from
  33970. * @param successCallback Defines the callback triggered once the data are available
  33971. * @param mimeType Defines the mime type of the result
  33972. */
  33973. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  33974. /**
  33975. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  33976. * @param successCallback defines the callback triggered once the data are available
  33977. * @param mimeType defines the mime type of the result
  33978. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  33979. */
  33980. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  33981. /**
  33982. * Downloads a blob in the browser
  33983. * @param blob defines the blob to download
  33984. * @param fileName defines the name of the downloaded file
  33985. */
  33986. static Download(blob: Blob, fileName: string): void;
  33987. /**
  33988. * Captures a screenshot of the current rendering
  33989. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33990. * @param engine defines the rendering engine
  33991. * @param camera defines the source camera
  33992. * @param size This parameter can be set to a single number or to an object with the
  33993. * following (optional) properties: precision, width, height. If a single number is passed,
  33994. * it will be used for both width and height. If an object is passed, the screenshot size
  33995. * will be derived from the parameters. The precision property is a multiplier allowing
  33996. * rendering at a higher or lower resolution
  33997. * @param successCallback defines the callback receives a single parameter which contains the
  33998. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  33999. * src parameter of an <img> to display it
  34000. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34001. * Check your browser for supported MIME types
  34002. */
  34003. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  34004. /**
  34005. * Captures a screenshot of the current rendering
  34006. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34007. * @param engine defines the rendering engine
  34008. * @param camera defines the source camera
  34009. * @param size This parameter can be set to a single number or to an object with the
  34010. * following (optional) properties: precision, width, height. If a single number is passed,
  34011. * it will be used for both width and height. If an object is passed, the screenshot size
  34012. * will be derived from the parameters. The precision property is a multiplier allowing
  34013. * rendering at a higher or lower resolution
  34014. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34015. * Check your browser for supported MIME types
  34016. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  34017. * to the src parameter of an <img> to display it
  34018. */
  34019. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  34020. /**
  34021. * Generates an image screenshot from the specified camera.
  34022. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34023. * @param engine The engine to use for rendering
  34024. * @param camera The camera to use for rendering
  34025. * @param size This parameter can be set to a single number or to an object with the
  34026. * following (optional) properties: precision, width, height. If a single number is passed,
  34027. * it will be used for both width and height. If an object is passed, the screenshot size
  34028. * will be derived from the parameters. The precision property is a multiplier allowing
  34029. * rendering at a higher or lower resolution
  34030. * @param successCallback The callback receives a single parameter which contains the
  34031. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  34032. * src parameter of an <img> to display it
  34033. * @param mimeType The MIME type of the screenshot image (default: image/png).
  34034. * Check your browser for supported MIME types
  34035. * @param samples Texture samples (default: 1)
  34036. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  34037. * @param fileName A name for for the downloaded file.
  34038. */
  34039. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  34040. /**
  34041. * Generates an image screenshot from the specified camera.
  34042. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34043. * @param engine The engine to use for rendering
  34044. * @param camera The camera to use for rendering
  34045. * @param size This parameter can be set to a single number or to an object with the
  34046. * following (optional) properties: precision, width, height. If a single number is passed,
  34047. * it will be used for both width and height. If an object is passed, the screenshot size
  34048. * will be derived from the parameters. The precision property is a multiplier allowing
  34049. * rendering at a higher or lower resolution
  34050. * @param mimeType The MIME type of the screenshot image (default: image/png).
  34051. * Check your browser for supported MIME types
  34052. * @param samples Texture samples (default: 1)
  34053. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  34054. * @param fileName A name for for the downloaded file.
  34055. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  34056. * to the src parameter of an <img> to display it
  34057. */
  34058. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  34059. /**
  34060. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  34061. * Be aware Math.random() could cause collisions, but:
  34062. * "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"
  34063. * @returns a pseudo random id
  34064. */
  34065. static RandomId(): string;
  34066. /**
  34067. * Test if the given uri is a base64 string
  34068. * @param uri The uri to test
  34069. * @return True if the uri is a base64 string or false otherwise
  34070. */
  34071. static IsBase64(uri: string): boolean;
  34072. /**
  34073. * Decode the given base64 uri.
  34074. * @param uri The uri to decode
  34075. * @return The decoded base64 data.
  34076. */
  34077. static DecodeBase64(uri: string): ArrayBuffer;
  34078. /**
  34079. * Gets the absolute url.
  34080. * @param url the input url
  34081. * @return the absolute url
  34082. */
  34083. static GetAbsoluteUrl(url: string): string;
  34084. /**
  34085. * No log
  34086. */
  34087. static readonly NoneLogLevel: number;
  34088. /**
  34089. * Only message logs
  34090. */
  34091. static readonly MessageLogLevel: number;
  34092. /**
  34093. * Only warning logs
  34094. */
  34095. static readonly WarningLogLevel: number;
  34096. /**
  34097. * Only error logs
  34098. */
  34099. static readonly ErrorLogLevel: number;
  34100. /**
  34101. * All logs
  34102. */
  34103. static readonly AllLogLevel: number;
  34104. /**
  34105. * Gets a value indicating the number of loading errors
  34106. * @ignorenaming
  34107. */
  34108. static get errorsCount(): number;
  34109. /**
  34110. * Callback called when a new log is added
  34111. */
  34112. static OnNewCacheEntry: (entry: string) => void;
  34113. /**
  34114. * Log a message to the console
  34115. * @param message defines the message to log
  34116. */
  34117. static Log(message: string): void;
  34118. /**
  34119. * Write a warning message to the console
  34120. * @param message defines the message to log
  34121. */
  34122. static Warn(message: string): void;
  34123. /**
  34124. * Write an error message to the console
  34125. * @param message defines the message to log
  34126. */
  34127. static Error(message: string): void;
  34128. /**
  34129. * Gets current log cache (list of logs)
  34130. */
  34131. static get LogCache(): string;
  34132. /**
  34133. * Clears the log cache
  34134. */
  34135. static ClearLogCache(): void;
  34136. /**
  34137. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  34138. */
  34139. static set LogLevels(level: number);
  34140. /**
  34141. * Checks if the window object exists
  34142. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  34143. */
  34144. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  34145. /**
  34146. * No performance log
  34147. */
  34148. static readonly PerformanceNoneLogLevel: number;
  34149. /**
  34150. * Use user marks to log performance
  34151. */
  34152. static readonly PerformanceUserMarkLogLevel: number;
  34153. /**
  34154. * Log performance to the console
  34155. */
  34156. static readonly PerformanceConsoleLogLevel: number;
  34157. private static _performance;
  34158. /**
  34159. * Sets the current performance log level
  34160. */
  34161. static set PerformanceLogLevel(level: number);
  34162. private static _StartPerformanceCounterDisabled;
  34163. private static _EndPerformanceCounterDisabled;
  34164. private static _StartUserMark;
  34165. private static _EndUserMark;
  34166. private static _StartPerformanceConsole;
  34167. private static _EndPerformanceConsole;
  34168. /**
  34169. * Starts a performance counter
  34170. */
  34171. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  34172. /**
  34173. * Ends a specific performance coutner
  34174. */
  34175. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  34176. /**
  34177. * Gets either window.performance.now() if supported or Date.now() else
  34178. */
  34179. static get Now(): number;
  34180. /**
  34181. * This method will return the name of the class used to create the instance of the given object.
  34182. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  34183. * @param object the object to get the class name from
  34184. * @param isType defines if the object is actually a type
  34185. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  34186. */
  34187. static GetClassName(object: any, isType?: boolean): string;
  34188. /**
  34189. * Gets the first element of an array satisfying a given predicate
  34190. * @param array defines the array to browse
  34191. * @param predicate defines the predicate to use
  34192. * @returns null if not found or the element
  34193. */
  34194. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  34195. /**
  34196. * This method will return the name of the full name of the class, including its owning module (if any).
  34197. * 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).
  34198. * @param object the object to get the class name from
  34199. * @param isType defines if the object is actually a type
  34200. * @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.
  34201. * @ignorenaming
  34202. */
  34203. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  34204. /**
  34205. * Returns a promise that resolves after the given amount of time.
  34206. * @param delay Number of milliseconds to delay
  34207. * @returns Promise that resolves after the given amount of time
  34208. */
  34209. static DelayAsync(delay: number): Promise<void>;
  34210. }
  34211. /**
  34212. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  34213. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  34214. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  34215. * @param name The name of the class, case should be preserved
  34216. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  34217. */
  34218. export function className(name: string, module?: string): (target: Object) => void;
  34219. /**
  34220. * An implementation of a loop for asynchronous functions.
  34221. */
  34222. export class AsyncLoop {
  34223. /**
  34224. * Defines the number of iterations for the loop
  34225. */
  34226. iterations: number;
  34227. /**
  34228. * Defines the current index of the loop.
  34229. */
  34230. index: number;
  34231. private _done;
  34232. private _fn;
  34233. private _successCallback;
  34234. /**
  34235. * Constructor.
  34236. * @param iterations the number of iterations.
  34237. * @param func the function to run each iteration
  34238. * @param successCallback the callback that will be called upon succesful execution
  34239. * @param offset starting offset.
  34240. */
  34241. constructor(
  34242. /**
  34243. * Defines the number of iterations for the loop
  34244. */
  34245. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  34246. /**
  34247. * Execute the next iteration. Must be called after the last iteration was finished.
  34248. */
  34249. executeNext(): void;
  34250. /**
  34251. * Break the loop and run the success callback.
  34252. */
  34253. breakLoop(): void;
  34254. /**
  34255. * Create and run an async loop.
  34256. * @param iterations the number of iterations.
  34257. * @param fn the function to run each iteration
  34258. * @param successCallback the callback that will be called upon succesful execution
  34259. * @param offset starting offset.
  34260. * @returns the created async loop object
  34261. */
  34262. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  34263. /**
  34264. * A for-loop that will run a given number of iterations synchronous and the rest async.
  34265. * @param iterations total number of iterations
  34266. * @param syncedIterations number of synchronous iterations in each async iteration.
  34267. * @param fn the function to call each iteration.
  34268. * @param callback a success call back that will be called when iterating stops.
  34269. * @param breakFunction a break condition (optional)
  34270. * @param timeout timeout settings for the setTimeout function. default - 0.
  34271. * @returns the created async loop object
  34272. */
  34273. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  34274. }
  34275. }
  34276. declare module BABYLON {
  34277. /**
  34278. * This class implement a typical dictionary using a string as key and the generic type T as value.
  34279. * The underlying implementation relies on an associative array to ensure the best performances.
  34280. * The value can be anything including 'null' but except 'undefined'
  34281. */
  34282. export class StringDictionary<T> {
  34283. /**
  34284. * This will clear this dictionary and copy the content from the 'source' one.
  34285. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  34286. * @param source the dictionary to take the content from and copy to this dictionary
  34287. */
  34288. copyFrom(source: StringDictionary<T>): void;
  34289. /**
  34290. * Get a value based from its key
  34291. * @param key the given key to get the matching value from
  34292. * @return the value if found, otherwise undefined is returned
  34293. */
  34294. get(key: string): T | undefined;
  34295. /**
  34296. * Get a value from its key or add it if it doesn't exist.
  34297. * This method will ensure you that a given key/data will be present in the dictionary.
  34298. * @param key the given key to get the matching value from
  34299. * @param factory the factory that will create the value if the key is not present in the dictionary.
  34300. * The factory will only be invoked if there's no data for the given key.
  34301. * @return the value corresponding to the key.
  34302. */
  34303. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  34304. /**
  34305. * Get a value from its key if present in the dictionary otherwise add it
  34306. * @param key the key to get the value from
  34307. * @param val if there's no such key/value pair in the dictionary add it with this value
  34308. * @return the value corresponding to the key
  34309. */
  34310. getOrAdd(key: string, val: T): T;
  34311. /**
  34312. * Check if there's a given key in the dictionary
  34313. * @param key the key to check for
  34314. * @return true if the key is present, false otherwise
  34315. */
  34316. contains(key: string): boolean;
  34317. /**
  34318. * Add a new key and its corresponding value
  34319. * @param key the key to add
  34320. * @param value the value corresponding to the key
  34321. * @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
  34322. */
  34323. add(key: string, value: T): boolean;
  34324. /**
  34325. * Update a specific value associated to a key
  34326. * @param key defines the key to use
  34327. * @param value defines the value to store
  34328. * @returns true if the value was updated (or false if the key was not found)
  34329. */
  34330. set(key: string, value: T): boolean;
  34331. /**
  34332. * Get the element of the given key and remove it from the dictionary
  34333. * @param key defines the key to search
  34334. * @returns the value associated with the key or null if not found
  34335. */
  34336. getAndRemove(key: string): Nullable<T>;
  34337. /**
  34338. * Remove a key/value from the dictionary.
  34339. * @param key the key to remove
  34340. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  34341. */
  34342. remove(key: string): boolean;
  34343. /**
  34344. * Clear the whole content of the dictionary
  34345. */
  34346. clear(): void;
  34347. /**
  34348. * Gets the current count
  34349. */
  34350. get count(): number;
  34351. /**
  34352. * Execute a callback on each key/val of the dictionary.
  34353. * Note that you can remove any element in this dictionary in the callback implementation
  34354. * @param callback the callback to execute on a given key/value pair
  34355. */
  34356. forEach(callback: (key: string, val: T) => void): void;
  34357. /**
  34358. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  34359. * If the callback returns null or undefined the method will iterate to the next key/value pair
  34360. * Note that you can remove any element in this dictionary in the callback implementation
  34361. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  34362. * @returns the first item
  34363. */
  34364. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  34365. private _count;
  34366. private _data;
  34367. }
  34368. }
  34369. declare module BABYLON {
  34370. /** @hidden */
  34371. export interface ICollisionCoordinator {
  34372. createCollider(): Collider;
  34373. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  34374. init(scene: Scene): void;
  34375. }
  34376. /** @hidden */
  34377. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  34378. private _scene;
  34379. private _scaledPosition;
  34380. private _scaledVelocity;
  34381. private _finalPosition;
  34382. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  34383. createCollider(): Collider;
  34384. init(scene: Scene): void;
  34385. private _collideWithWorld;
  34386. }
  34387. }
  34388. declare module BABYLON {
  34389. /**
  34390. * Class used to manage all inputs for the scene.
  34391. */
  34392. export class InputManager {
  34393. /** The distance in pixel that you have to move to prevent some events */
  34394. static DragMovementThreshold: number;
  34395. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  34396. static LongPressDelay: number;
  34397. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  34398. static DoubleClickDelay: number;
  34399. /** If you need to check double click without raising a single click at first click, enable this flag */
  34400. static ExclusiveDoubleClickMode: boolean;
  34401. private _wheelEventName;
  34402. private _onPointerMove;
  34403. private _onPointerDown;
  34404. private _onPointerUp;
  34405. private _initClickEvent;
  34406. private _initActionManager;
  34407. private _delayedSimpleClick;
  34408. private _delayedSimpleClickTimeout;
  34409. private _previousDelayedSimpleClickTimeout;
  34410. private _meshPickProceed;
  34411. private _previousButtonPressed;
  34412. private _currentPickResult;
  34413. private _previousPickResult;
  34414. private _totalPointersPressed;
  34415. private _doubleClickOccured;
  34416. private _pointerOverMesh;
  34417. private _pickedDownMesh;
  34418. private _pickedUpMesh;
  34419. private _pointerX;
  34420. private _pointerY;
  34421. private _unTranslatedPointerX;
  34422. private _unTranslatedPointerY;
  34423. private _startingPointerPosition;
  34424. private _previousStartingPointerPosition;
  34425. private _startingPointerTime;
  34426. private _previousStartingPointerTime;
  34427. private _pointerCaptures;
  34428. private _onKeyDown;
  34429. private _onKeyUp;
  34430. private _onCanvasFocusObserver;
  34431. private _onCanvasBlurObserver;
  34432. private _scene;
  34433. /**
  34434. * Creates a new InputManager
  34435. * @param scene defines the hosting scene
  34436. */
  34437. constructor(scene: Scene);
  34438. /**
  34439. * Gets the mesh that is currently under the pointer
  34440. */
  34441. get meshUnderPointer(): Nullable<AbstractMesh>;
  34442. /**
  34443. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  34444. */
  34445. get unTranslatedPointer(): Vector2;
  34446. /**
  34447. * Gets or sets the current on-screen X position of the pointer
  34448. */
  34449. get pointerX(): number;
  34450. set pointerX(value: number);
  34451. /**
  34452. * Gets or sets the current on-screen Y position of the pointer
  34453. */
  34454. get pointerY(): number;
  34455. set pointerY(value: number);
  34456. private _updatePointerPosition;
  34457. private _processPointerMove;
  34458. private _setRayOnPointerInfo;
  34459. private _checkPrePointerObservable;
  34460. /**
  34461. * Use this method to simulate a pointer move on a mesh
  34462. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34463. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34464. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34465. */
  34466. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  34467. /**
  34468. * Use this method to simulate a pointer down on a mesh
  34469. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34470. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34471. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34472. */
  34473. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  34474. private _processPointerDown;
  34475. /** @hidden */
  34476. _isPointerSwiping(): boolean;
  34477. /**
  34478. * Use this method to simulate a pointer up on a mesh
  34479. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34480. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34481. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34482. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  34483. */
  34484. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  34485. private _processPointerUp;
  34486. /**
  34487. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  34488. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  34489. * @returns true if the pointer was captured
  34490. */
  34491. isPointerCaptured(pointerId?: number): boolean;
  34492. /**
  34493. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  34494. * @param attachUp defines if you want to attach events to pointerup
  34495. * @param attachDown defines if you want to attach events to pointerdown
  34496. * @param attachMove defines if you want to attach events to pointermove
  34497. */
  34498. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  34499. /**
  34500. * Detaches all event handlers
  34501. */
  34502. detachControl(): void;
  34503. /**
  34504. * Force the value of meshUnderPointer
  34505. * @param mesh defines the mesh to use
  34506. */
  34507. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34508. /**
  34509. * Gets the mesh under the pointer
  34510. * @returns a Mesh or null if no mesh is under the pointer
  34511. */
  34512. getPointerOverMesh(): Nullable<AbstractMesh>;
  34513. }
  34514. }
  34515. declare module BABYLON {
  34516. /**
  34517. * Helper class used to generate session unique ID
  34518. */
  34519. export class UniqueIdGenerator {
  34520. private static _UniqueIdCounter;
  34521. /**
  34522. * Gets an unique (relatively to the current scene) Id
  34523. */
  34524. static get UniqueId(): number;
  34525. }
  34526. }
  34527. declare module BABYLON {
  34528. /**
  34529. * This class defines the direct association between an animation and a target
  34530. */
  34531. export class TargetedAnimation {
  34532. /**
  34533. * Animation to perform
  34534. */
  34535. animation: Animation;
  34536. /**
  34537. * Target to animate
  34538. */
  34539. target: any;
  34540. /**
  34541. * Serialize the object
  34542. * @returns the JSON object representing the current entity
  34543. */
  34544. serialize(): any;
  34545. }
  34546. /**
  34547. * Use this class to create coordinated animations on multiple targets
  34548. */
  34549. export class AnimationGroup implements IDisposable {
  34550. /** The name of the animation group */
  34551. name: string;
  34552. private _scene;
  34553. private _targetedAnimations;
  34554. private _animatables;
  34555. private _from;
  34556. private _to;
  34557. private _isStarted;
  34558. private _isPaused;
  34559. private _speedRatio;
  34560. private _loopAnimation;
  34561. /**
  34562. * Gets or sets the unique id of the node
  34563. */
  34564. uniqueId: number;
  34565. /**
  34566. * This observable will notify when one animation have ended
  34567. */
  34568. onAnimationEndObservable: Observable<TargetedAnimation>;
  34569. /**
  34570. * Observer raised when one animation loops
  34571. */
  34572. onAnimationLoopObservable: Observable<TargetedAnimation>;
  34573. /**
  34574. * Observer raised when all animations have looped
  34575. */
  34576. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  34577. /**
  34578. * This observable will notify when all animations have ended.
  34579. */
  34580. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  34581. /**
  34582. * This observable will notify when all animations have paused.
  34583. */
  34584. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  34585. /**
  34586. * This observable will notify when all animations are playing.
  34587. */
  34588. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  34589. /**
  34590. * Gets the first frame
  34591. */
  34592. get from(): number;
  34593. /**
  34594. * Gets the last frame
  34595. */
  34596. get to(): number;
  34597. /**
  34598. * Define if the animations are started
  34599. */
  34600. get isStarted(): boolean;
  34601. /**
  34602. * Gets a value indicating that the current group is playing
  34603. */
  34604. get isPlaying(): boolean;
  34605. /**
  34606. * Gets or sets the speed ratio to use for all animations
  34607. */
  34608. get speedRatio(): number;
  34609. /**
  34610. * Gets or sets the speed ratio to use for all animations
  34611. */
  34612. set speedRatio(value: number);
  34613. /**
  34614. * Gets or sets if all animations should loop or not
  34615. */
  34616. get loopAnimation(): boolean;
  34617. set loopAnimation(value: boolean);
  34618. /**
  34619. * Gets the targeted animations for this animation group
  34620. */
  34621. get targetedAnimations(): Array<TargetedAnimation>;
  34622. /**
  34623. * returning the list of animatables controlled by this animation group.
  34624. */
  34625. get animatables(): Array<Animatable>;
  34626. /**
  34627. * Instantiates a new Animation Group.
  34628. * This helps managing several animations at once.
  34629. * @see http://doc.babylonjs.com/how_to/group
  34630. * @param name Defines the name of the group
  34631. * @param scene Defines the scene the group belongs to
  34632. */
  34633. constructor(
  34634. /** The name of the animation group */
  34635. name: string, scene?: Nullable<Scene>);
  34636. /**
  34637. * Add an animation (with its target) in the group
  34638. * @param animation defines the animation we want to add
  34639. * @param target defines the target of the animation
  34640. * @returns the TargetedAnimation object
  34641. */
  34642. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  34643. /**
  34644. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  34645. * It can add constant keys at begin or end
  34646. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  34647. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  34648. * @returns the animation group
  34649. */
  34650. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  34651. private _animationLoopCount;
  34652. private _animationLoopFlags;
  34653. private _processLoop;
  34654. /**
  34655. * Start all animations on given targets
  34656. * @param loop defines if animations must loop
  34657. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  34658. * @param from defines the from key (optional)
  34659. * @param to defines the to key (optional)
  34660. * @returns the current animation group
  34661. */
  34662. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  34663. /**
  34664. * Pause all animations
  34665. * @returns the animation group
  34666. */
  34667. pause(): AnimationGroup;
  34668. /**
  34669. * Play all animations to initial state
  34670. * This function will start() the animations if they were not started or will restart() them if they were paused
  34671. * @param loop defines if animations must loop
  34672. * @returns the animation group
  34673. */
  34674. play(loop?: boolean): AnimationGroup;
  34675. /**
  34676. * Reset all animations to initial state
  34677. * @returns the animation group
  34678. */
  34679. reset(): AnimationGroup;
  34680. /**
  34681. * Restart animations from key 0
  34682. * @returns the animation group
  34683. */
  34684. restart(): AnimationGroup;
  34685. /**
  34686. * Stop all animations
  34687. * @returns the animation group
  34688. */
  34689. stop(): AnimationGroup;
  34690. /**
  34691. * Set animation weight for all animatables
  34692. * @param weight defines the weight to use
  34693. * @return the animationGroup
  34694. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  34695. */
  34696. setWeightForAllAnimatables(weight: number): AnimationGroup;
  34697. /**
  34698. * Synchronize and normalize all animatables with a source animatable
  34699. * @param root defines the root animatable to synchronize with
  34700. * @return the animationGroup
  34701. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  34702. */
  34703. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  34704. /**
  34705. * Goes to a specific frame in this animation group
  34706. * @param frame the frame number to go to
  34707. * @return the animationGroup
  34708. */
  34709. goToFrame(frame: number): AnimationGroup;
  34710. /**
  34711. * Dispose all associated resources
  34712. */
  34713. dispose(): void;
  34714. private _checkAnimationGroupEnded;
  34715. /**
  34716. * Clone the current animation group and returns a copy
  34717. * @param newName defines the name of the new group
  34718. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  34719. * @returns the new aniamtion group
  34720. */
  34721. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  34722. /**
  34723. * Serializes the animationGroup to an object
  34724. * @returns Serialized object
  34725. */
  34726. serialize(): any;
  34727. /**
  34728. * Returns a new AnimationGroup object parsed from the source provided.
  34729. * @param parsedAnimationGroup defines the source
  34730. * @param scene defines the scene that will receive the animationGroup
  34731. * @returns a new AnimationGroup
  34732. */
  34733. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  34734. /**
  34735. * Returns the string "AnimationGroup"
  34736. * @returns "AnimationGroup"
  34737. */
  34738. getClassName(): string;
  34739. /**
  34740. * Creates a detailled string about the object
  34741. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  34742. * @returns a string representing the object
  34743. */
  34744. toString(fullDetails?: boolean): string;
  34745. }
  34746. }
  34747. declare module BABYLON {
  34748. /**
  34749. * Define an interface for all classes that will hold resources
  34750. */
  34751. export interface IDisposable {
  34752. /**
  34753. * Releases all held resources
  34754. */
  34755. dispose(): void;
  34756. }
  34757. /** Interface defining initialization parameters for Scene class */
  34758. export interface SceneOptions {
  34759. /**
  34760. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  34761. * It will improve performance when the number of geometries becomes important.
  34762. */
  34763. useGeometryUniqueIdsMap?: boolean;
  34764. /**
  34765. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  34766. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  34767. */
  34768. useMaterialMeshMap?: boolean;
  34769. /**
  34770. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  34771. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  34772. */
  34773. useClonedMeshhMap?: boolean;
  34774. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  34775. virtual?: boolean;
  34776. }
  34777. /**
  34778. * Represents a scene to be rendered by the engine.
  34779. * @see http://doc.babylonjs.com/features/scene
  34780. */
  34781. export class Scene extends AbstractScene implements IAnimatable {
  34782. /** The fog is deactivated */
  34783. static readonly FOGMODE_NONE: number;
  34784. /** The fog density is following an exponential function */
  34785. static readonly FOGMODE_EXP: number;
  34786. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  34787. static readonly FOGMODE_EXP2: number;
  34788. /** The fog density is following a linear function. */
  34789. static readonly FOGMODE_LINEAR: number;
  34790. /**
  34791. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  34792. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34793. */
  34794. static MinDeltaTime: number;
  34795. /**
  34796. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  34797. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34798. */
  34799. static MaxDeltaTime: number;
  34800. /**
  34801. * Factory used to create the default material.
  34802. * @param name The name of the material to create
  34803. * @param scene The scene to create the material for
  34804. * @returns The default material
  34805. */
  34806. static DefaultMaterialFactory(scene: Scene): Material;
  34807. /**
  34808. * Factory used to create the a collision coordinator.
  34809. * @returns The collision coordinator
  34810. */
  34811. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  34812. /** @hidden */
  34813. _inputManager: InputManager;
  34814. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  34815. cameraToUseForPointers: Nullable<Camera>;
  34816. /** @hidden */
  34817. readonly _isScene: boolean;
  34818. /**
  34819. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  34820. */
  34821. autoClear: boolean;
  34822. /**
  34823. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  34824. */
  34825. autoClearDepthAndStencil: boolean;
  34826. /**
  34827. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  34828. */
  34829. clearColor: Color4;
  34830. /**
  34831. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  34832. */
  34833. ambientColor: Color3;
  34834. /**
  34835. * This is use to store the default BRDF lookup for PBR materials in your scene.
  34836. * It should only be one of the following (if not the default embedded one):
  34837. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  34838. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  34839. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  34840. * The material properties need to be setup according to the type of texture in use.
  34841. */
  34842. environmentBRDFTexture: BaseTexture;
  34843. /** @hidden */
  34844. protected _environmentTexture: Nullable<BaseTexture>;
  34845. /**
  34846. * Texture used in all pbr material as the reflection texture.
  34847. * As in the majority of the scene they are the same (exception for multi room and so on),
  34848. * this is easier to reference from here than from all the materials.
  34849. */
  34850. get environmentTexture(): Nullable<BaseTexture>;
  34851. /**
  34852. * Texture used in all pbr material as the reflection texture.
  34853. * As in the majority of the scene they are the same (exception for multi room and so on),
  34854. * this is easier to set here than in all the materials.
  34855. */
  34856. set environmentTexture(value: Nullable<BaseTexture>);
  34857. /** @hidden */
  34858. protected _environmentIntensity: number;
  34859. /**
  34860. * Intensity of the environment in all pbr material.
  34861. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  34862. * As in the majority of the scene they are the same (exception for multi room and so on),
  34863. * this is easier to reference from here than from all the materials.
  34864. */
  34865. get environmentIntensity(): number;
  34866. /**
  34867. * Intensity of the environment in all pbr material.
  34868. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  34869. * As in the majority of the scene they are the same (exception for multi room and so on),
  34870. * this is easier to set here than in all the materials.
  34871. */
  34872. set environmentIntensity(value: number);
  34873. /** @hidden */
  34874. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  34875. /**
  34876. * Default image processing configuration used either in the rendering
  34877. * Forward main pass or through the imageProcessingPostProcess if present.
  34878. * As in the majority of the scene they are the same (exception for multi camera),
  34879. * this is easier to reference from here than from all the materials and post process.
  34880. *
  34881. * No setter as we it is a shared configuration, you can set the values instead.
  34882. */
  34883. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  34884. private _forceWireframe;
  34885. /**
  34886. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  34887. */
  34888. set forceWireframe(value: boolean);
  34889. get forceWireframe(): boolean;
  34890. private _forcePointsCloud;
  34891. /**
  34892. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  34893. */
  34894. set forcePointsCloud(value: boolean);
  34895. get forcePointsCloud(): boolean;
  34896. /**
  34897. * Gets or sets the active clipplane 1
  34898. */
  34899. clipPlane: Nullable<Plane>;
  34900. /**
  34901. * Gets or sets the active clipplane 2
  34902. */
  34903. clipPlane2: Nullable<Plane>;
  34904. /**
  34905. * Gets or sets the active clipplane 3
  34906. */
  34907. clipPlane3: Nullable<Plane>;
  34908. /**
  34909. * Gets or sets the active clipplane 4
  34910. */
  34911. clipPlane4: Nullable<Plane>;
  34912. /**
  34913. * Gets or sets the active clipplane 5
  34914. */
  34915. clipPlane5: Nullable<Plane>;
  34916. /**
  34917. * Gets or sets the active clipplane 6
  34918. */
  34919. clipPlane6: Nullable<Plane>;
  34920. /**
  34921. * Gets or sets a boolean indicating if animations are enabled
  34922. */
  34923. animationsEnabled: boolean;
  34924. private _animationPropertiesOverride;
  34925. /**
  34926. * Gets or sets the animation properties override
  34927. */
  34928. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  34929. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  34930. /**
  34931. * Gets or sets a boolean indicating if a constant deltatime has to be used
  34932. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  34933. */
  34934. useConstantAnimationDeltaTime: boolean;
  34935. /**
  34936. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  34937. * Please note that it requires to run a ray cast through the scene on every frame
  34938. */
  34939. constantlyUpdateMeshUnderPointer: boolean;
  34940. /**
  34941. * Defines the HTML cursor to use when hovering over interactive elements
  34942. */
  34943. hoverCursor: string;
  34944. /**
  34945. * Defines the HTML default cursor to use (empty by default)
  34946. */
  34947. defaultCursor: string;
  34948. /**
  34949. * Defines wether cursors are handled by the scene.
  34950. */
  34951. doNotHandleCursors: boolean;
  34952. /**
  34953. * This is used to call preventDefault() on pointer down
  34954. * in order to block unwanted artifacts like system double clicks
  34955. */
  34956. preventDefaultOnPointerDown: boolean;
  34957. /**
  34958. * This is used to call preventDefault() on pointer up
  34959. * in order to block unwanted artifacts like system double clicks
  34960. */
  34961. preventDefaultOnPointerUp: boolean;
  34962. /**
  34963. * Gets or sets user defined metadata
  34964. */
  34965. metadata: any;
  34966. /**
  34967. * For internal use only. Please do not use.
  34968. */
  34969. reservedDataStore: any;
  34970. /**
  34971. * Gets the name of the plugin used to load this scene (null by default)
  34972. */
  34973. loadingPluginName: string;
  34974. /**
  34975. * Use this array to add regular expressions used to disable offline support for specific urls
  34976. */
  34977. disableOfflineSupportExceptionRules: RegExp[];
  34978. /**
  34979. * An event triggered when the scene is disposed.
  34980. */
  34981. onDisposeObservable: Observable<Scene>;
  34982. private _onDisposeObserver;
  34983. /** Sets a function to be executed when this scene is disposed. */
  34984. set onDispose(callback: () => void);
  34985. /**
  34986. * An event triggered before rendering the scene (right after animations and physics)
  34987. */
  34988. onBeforeRenderObservable: Observable<Scene>;
  34989. private _onBeforeRenderObserver;
  34990. /** Sets a function to be executed before rendering this scene */
  34991. set beforeRender(callback: Nullable<() => void>);
  34992. /**
  34993. * An event triggered after rendering the scene
  34994. */
  34995. onAfterRenderObservable: Observable<Scene>;
  34996. /**
  34997. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  34998. */
  34999. onAfterRenderCameraObservable: Observable<Camera>;
  35000. private _onAfterRenderObserver;
  35001. /** Sets a function to be executed after rendering this scene */
  35002. set afterRender(callback: Nullable<() => void>);
  35003. /**
  35004. * An event triggered before animating the scene
  35005. */
  35006. onBeforeAnimationsObservable: Observable<Scene>;
  35007. /**
  35008. * An event triggered after animations processing
  35009. */
  35010. onAfterAnimationsObservable: Observable<Scene>;
  35011. /**
  35012. * An event triggered before draw calls are ready to be sent
  35013. */
  35014. onBeforeDrawPhaseObservable: Observable<Scene>;
  35015. /**
  35016. * An event triggered after draw calls have been sent
  35017. */
  35018. onAfterDrawPhaseObservable: Observable<Scene>;
  35019. /**
  35020. * An event triggered when the scene is ready
  35021. */
  35022. onReadyObservable: Observable<Scene>;
  35023. /**
  35024. * An event triggered before rendering a camera
  35025. */
  35026. onBeforeCameraRenderObservable: Observable<Camera>;
  35027. private _onBeforeCameraRenderObserver;
  35028. /** Sets a function to be executed before rendering a camera*/
  35029. set beforeCameraRender(callback: () => void);
  35030. /**
  35031. * An event triggered after rendering a camera
  35032. */
  35033. onAfterCameraRenderObservable: Observable<Camera>;
  35034. private _onAfterCameraRenderObserver;
  35035. /** Sets a function to be executed after rendering a camera*/
  35036. set afterCameraRender(callback: () => void);
  35037. /**
  35038. * An event triggered when active meshes evaluation is about to start
  35039. */
  35040. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  35041. /**
  35042. * An event triggered when active meshes evaluation is done
  35043. */
  35044. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  35045. /**
  35046. * An event triggered when particles rendering is about to start
  35047. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  35048. */
  35049. onBeforeParticlesRenderingObservable: Observable<Scene>;
  35050. /**
  35051. * An event triggered when particles rendering is done
  35052. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  35053. */
  35054. onAfterParticlesRenderingObservable: Observable<Scene>;
  35055. /**
  35056. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  35057. */
  35058. onDataLoadedObservable: Observable<Scene>;
  35059. /**
  35060. * An event triggered when a camera is created
  35061. */
  35062. onNewCameraAddedObservable: Observable<Camera>;
  35063. /**
  35064. * An event triggered when a camera is removed
  35065. */
  35066. onCameraRemovedObservable: Observable<Camera>;
  35067. /**
  35068. * An event triggered when a light is created
  35069. */
  35070. onNewLightAddedObservable: Observable<Light>;
  35071. /**
  35072. * An event triggered when a light is removed
  35073. */
  35074. onLightRemovedObservable: Observable<Light>;
  35075. /**
  35076. * An event triggered when a geometry is created
  35077. */
  35078. onNewGeometryAddedObservable: Observable<Geometry>;
  35079. /**
  35080. * An event triggered when a geometry is removed
  35081. */
  35082. onGeometryRemovedObservable: Observable<Geometry>;
  35083. /**
  35084. * An event triggered when a transform node is created
  35085. */
  35086. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  35087. /**
  35088. * An event triggered when a transform node is removed
  35089. */
  35090. onTransformNodeRemovedObservable: Observable<TransformNode>;
  35091. /**
  35092. * An event triggered when a mesh is created
  35093. */
  35094. onNewMeshAddedObservable: Observable<AbstractMesh>;
  35095. /**
  35096. * An event triggered when a mesh is removed
  35097. */
  35098. onMeshRemovedObservable: Observable<AbstractMesh>;
  35099. /**
  35100. * An event triggered when a skeleton is created
  35101. */
  35102. onNewSkeletonAddedObservable: Observable<Skeleton>;
  35103. /**
  35104. * An event triggered when a skeleton is removed
  35105. */
  35106. onSkeletonRemovedObservable: Observable<Skeleton>;
  35107. /**
  35108. * An event triggered when a material is created
  35109. */
  35110. onNewMaterialAddedObservable: Observable<Material>;
  35111. /**
  35112. * An event triggered when a material is removed
  35113. */
  35114. onMaterialRemovedObservable: Observable<Material>;
  35115. /**
  35116. * An event triggered when a texture is created
  35117. */
  35118. onNewTextureAddedObservable: Observable<BaseTexture>;
  35119. /**
  35120. * An event triggered when a texture is removed
  35121. */
  35122. onTextureRemovedObservable: Observable<BaseTexture>;
  35123. /**
  35124. * An event triggered when render targets are about to be rendered
  35125. * Can happen multiple times per frame.
  35126. */
  35127. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  35128. /**
  35129. * An event triggered when render targets were rendered.
  35130. * Can happen multiple times per frame.
  35131. */
  35132. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  35133. /**
  35134. * An event triggered before calculating deterministic simulation step
  35135. */
  35136. onBeforeStepObservable: Observable<Scene>;
  35137. /**
  35138. * An event triggered after calculating deterministic simulation step
  35139. */
  35140. onAfterStepObservable: Observable<Scene>;
  35141. /**
  35142. * An event triggered when the activeCamera property is updated
  35143. */
  35144. onActiveCameraChanged: Observable<Scene>;
  35145. /**
  35146. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  35147. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  35148. * 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)
  35149. */
  35150. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  35151. /**
  35152. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  35153. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  35154. * 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)
  35155. */
  35156. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  35157. /**
  35158. * This Observable will when a mesh has been imported into the scene.
  35159. */
  35160. onMeshImportedObservable: Observable<AbstractMesh>;
  35161. /**
  35162. * This Observable will when an animation file has been imported into the scene.
  35163. */
  35164. onAnimationFileImportedObservable: Observable<Scene>;
  35165. /**
  35166. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  35167. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  35168. */
  35169. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  35170. /** @hidden */
  35171. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  35172. /**
  35173. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  35174. */
  35175. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  35176. /**
  35177. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  35178. */
  35179. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  35180. /**
  35181. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  35182. */
  35183. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  35184. /** Callback called when a pointer move is detected */
  35185. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  35186. /** Callback called when a pointer down is detected */
  35187. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  35188. /** Callback called when a pointer up is detected */
  35189. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  35190. /** Callback called when a pointer pick is detected */
  35191. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  35192. /**
  35193. * 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).
  35194. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  35195. */
  35196. onPrePointerObservable: Observable<PointerInfoPre>;
  35197. /**
  35198. * Observable event triggered each time an input event is received from the rendering canvas
  35199. */
  35200. onPointerObservable: Observable<PointerInfo>;
  35201. /**
  35202. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  35203. */
  35204. get unTranslatedPointer(): Vector2;
  35205. /**
  35206. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  35207. */
  35208. static get DragMovementThreshold(): number;
  35209. static set DragMovementThreshold(value: number);
  35210. /**
  35211. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  35212. */
  35213. static get LongPressDelay(): number;
  35214. static set LongPressDelay(value: number);
  35215. /**
  35216. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  35217. */
  35218. static get DoubleClickDelay(): number;
  35219. static set DoubleClickDelay(value: number);
  35220. /** If you need to check double click without raising a single click at first click, enable this flag */
  35221. static get ExclusiveDoubleClickMode(): boolean;
  35222. static set ExclusiveDoubleClickMode(value: boolean);
  35223. /** @hidden */
  35224. _mirroredCameraPosition: Nullable<Vector3>;
  35225. /**
  35226. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  35227. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  35228. */
  35229. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  35230. /**
  35231. * Observable event triggered each time an keyboard event is received from the hosting window
  35232. */
  35233. onKeyboardObservable: Observable<KeyboardInfo>;
  35234. private _useRightHandedSystem;
  35235. /**
  35236. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  35237. */
  35238. set useRightHandedSystem(value: boolean);
  35239. get useRightHandedSystem(): boolean;
  35240. private _timeAccumulator;
  35241. private _currentStepId;
  35242. private _currentInternalStep;
  35243. /**
  35244. * Sets the step Id used by deterministic lock step
  35245. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35246. * @param newStepId defines the step Id
  35247. */
  35248. setStepId(newStepId: number): void;
  35249. /**
  35250. * Gets the step Id used by deterministic lock step
  35251. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35252. * @returns the step Id
  35253. */
  35254. getStepId(): number;
  35255. /**
  35256. * Gets the internal step used by deterministic lock step
  35257. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35258. * @returns the internal step
  35259. */
  35260. getInternalStep(): number;
  35261. private _fogEnabled;
  35262. /**
  35263. * Gets or sets a boolean indicating if fog is enabled on this scene
  35264. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35265. * (Default is true)
  35266. */
  35267. set fogEnabled(value: boolean);
  35268. get fogEnabled(): boolean;
  35269. private _fogMode;
  35270. /**
  35271. * Gets or sets the fog mode to use
  35272. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35273. * | mode | value |
  35274. * | --- | --- |
  35275. * | FOGMODE_NONE | 0 |
  35276. * | FOGMODE_EXP | 1 |
  35277. * | FOGMODE_EXP2 | 2 |
  35278. * | FOGMODE_LINEAR | 3 |
  35279. */
  35280. set fogMode(value: number);
  35281. get fogMode(): number;
  35282. /**
  35283. * Gets or sets the fog color to use
  35284. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35285. * (Default is Color3(0.2, 0.2, 0.3))
  35286. */
  35287. fogColor: Color3;
  35288. /**
  35289. * Gets or sets the fog density to use
  35290. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35291. * (Default is 0.1)
  35292. */
  35293. fogDensity: number;
  35294. /**
  35295. * Gets or sets the fog start distance to use
  35296. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35297. * (Default is 0)
  35298. */
  35299. fogStart: number;
  35300. /**
  35301. * Gets or sets the fog end distance to use
  35302. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35303. * (Default is 1000)
  35304. */
  35305. fogEnd: number;
  35306. private _shadowsEnabled;
  35307. /**
  35308. * Gets or sets a boolean indicating if shadows are enabled on this scene
  35309. */
  35310. set shadowsEnabled(value: boolean);
  35311. get shadowsEnabled(): boolean;
  35312. private _lightsEnabled;
  35313. /**
  35314. * Gets or sets a boolean indicating if lights are enabled on this scene
  35315. */
  35316. set lightsEnabled(value: boolean);
  35317. get lightsEnabled(): boolean;
  35318. /** All of the active cameras added to this scene. */
  35319. activeCameras: Camera[];
  35320. /** @hidden */
  35321. _activeCamera: Nullable<Camera>;
  35322. /** Gets or sets the current active camera */
  35323. get activeCamera(): Nullable<Camera>;
  35324. set activeCamera(value: Nullable<Camera>);
  35325. private _defaultMaterial;
  35326. /** The default material used on meshes when no material is affected */
  35327. get defaultMaterial(): Material;
  35328. /** The default material used on meshes when no material is affected */
  35329. set defaultMaterial(value: Material);
  35330. private _texturesEnabled;
  35331. /**
  35332. * Gets or sets a boolean indicating if textures are enabled on this scene
  35333. */
  35334. set texturesEnabled(value: boolean);
  35335. get texturesEnabled(): boolean;
  35336. /**
  35337. * Gets or sets a boolean indicating if particles are enabled on this scene
  35338. */
  35339. particlesEnabled: boolean;
  35340. /**
  35341. * Gets or sets a boolean indicating if sprites are enabled on this scene
  35342. */
  35343. spritesEnabled: boolean;
  35344. private _skeletonsEnabled;
  35345. /**
  35346. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  35347. */
  35348. set skeletonsEnabled(value: boolean);
  35349. get skeletonsEnabled(): boolean;
  35350. /**
  35351. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  35352. */
  35353. lensFlaresEnabled: boolean;
  35354. /**
  35355. * Gets or sets a boolean indicating if collisions are enabled on this scene
  35356. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35357. */
  35358. collisionsEnabled: boolean;
  35359. private _collisionCoordinator;
  35360. /** @hidden */
  35361. get collisionCoordinator(): ICollisionCoordinator;
  35362. /**
  35363. * Defines the gravity applied to this scene (used only for collisions)
  35364. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35365. */
  35366. gravity: Vector3;
  35367. /**
  35368. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  35369. */
  35370. postProcessesEnabled: boolean;
  35371. /**
  35372. * The list of postprocesses added to the scene
  35373. */
  35374. postProcesses: PostProcess[];
  35375. /**
  35376. * Gets the current postprocess manager
  35377. */
  35378. postProcessManager: PostProcessManager;
  35379. /**
  35380. * Gets or sets a boolean indicating if render targets are enabled on this scene
  35381. */
  35382. renderTargetsEnabled: boolean;
  35383. /**
  35384. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  35385. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  35386. */
  35387. dumpNextRenderTargets: boolean;
  35388. /**
  35389. * The list of user defined render targets added to the scene
  35390. */
  35391. customRenderTargets: RenderTargetTexture[];
  35392. /**
  35393. * Defines if texture loading must be delayed
  35394. * If true, textures will only be loaded when they need to be rendered
  35395. */
  35396. useDelayedTextureLoading: boolean;
  35397. /**
  35398. * Gets the list of meshes imported to the scene through SceneLoader
  35399. */
  35400. importedMeshesFiles: String[];
  35401. /**
  35402. * Gets or sets a boolean indicating if probes are enabled on this scene
  35403. */
  35404. probesEnabled: boolean;
  35405. /**
  35406. * Gets or sets the current offline provider to use to store scene data
  35407. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  35408. */
  35409. offlineProvider: IOfflineProvider;
  35410. /**
  35411. * Gets or sets the action manager associated with the scene
  35412. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35413. */
  35414. actionManager: AbstractActionManager;
  35415. private _meshesForIntersections;
  35416. /**
  35417. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  35418. */
  35419. proceduralTexturesEnabled: boolean;
  35420. private _engine;
  35421. private _totalVertices;
  35422. /** @hidden */
  35423. _activeIndices: PerfCounter;
  35424. /** @hidden */
  35425. _activeParticles: PerfCounter;
  35426. /** @hidden */
  35427. _activeBones: PerfCounter;
  35428. private _animationRatio;
  35429. /** @hidden */
  35430. _animationTimeLast: number;
  35431. /** @hidden */
  35432. _animationTime: number;
  35433. /**
  35434. * Gets or sets a general scale for animation speed
  35435. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  35436. */
  35437. animationTimeScale: number;
  35438. /** @hidden */
  35439. _cachedMaterial: Nullable<Material>;
  35440. /** @hidden */
  35441. _cachedEffect: Nullable<Effect>;
  35442. /** @hidden */
  35443. _cachedVisibility: Nullable<number>;
  35444. private _renderId;
  35445. private _frameId;
  35446. private _executeWhenReadyTimeoutId;
  35447. private _intermediateRendering;
  35448. private _viewUpdateFlag;
  35449. private _projectionUpdateFlag;
  35450. /** @hidden */
  35451. _toBeDisposed: Nullable<IDisposable>[];
  35452. private _activeRequests;
  35453. /** @hidden */
  35454. _pendingData: any[];
  35455. private _isDisposed;
  35456. /**
  35457. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  35458. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  35459. */
  35460. dispatchAllSubMeshesOfActiveMeshes: boolean;
  35461. private _activeMeshes;
  35462. private _processedMaterials;
  35463. private _renderTargets;
  35464. /** @hidden */
  35465. _activeParticleSystems: SmartArray<IParticleSystem>;
  35466. private _activeSkeletons;
  35467. private _softwareSkinnedMeshes;
  35468. private _renderingManager;
  35469. /** @hidden */
  35470. _activeAnimatables: Animatable[];
  35471. private _transformMatrix;
  35472. private _sceneUbo;
  35473. /** @hidden */
  35474. _viewMatrix: Matrix;
  35475. private _projectionMatrix;
  35476. /** @hidden */
  35477. _forcedViewPosition: Nullable<Vector3>;
  35478. /** @hidden */
  35479. _frustumPlanes: Plane[];
  35480. /**
  35481. * Gets the list of frustum planes (built from the active camera)
  35482. */
  35483. get frustumPlanes(): Plane[];
  35484. /**
  35485. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  35486. * This is useful if there are more lights that the maximum simulteanous authorized
  35487. */
  35488. requireLightSorting: boolean;
  35489. /** @hidden */
  35490. readonly useMaterialMeshMap: boolean;
  35491. /** @hidden */
  35492. readonly useClonedMeshhMap: boolean;
  35493. private _externalData;
  35494. private _uid;
  35495. /**
  35496. * @hidden
  35497. * Backing store of defined scene components.
  35498. */
  35499. _components: ISceneComponent[];
  35500. /**
  35501. * @hidden
  35502. * Backing store of defined scene components.
  35503. */
  35504. _serializableComponents: ISceneSerializableComponent[];
  35505. /**
  35506. * List of components to register on the next registration step.
  35507. */
  35508. private _transientComponents;
  35509. /**
  35510. * Registers the transient components if needed.
  35511. */
  35512. private _registerTransientComponents;
  35513. /**
  35514. * @hidden
  35515. * Add a component to the scene.
  35516. * Note that the ccomponent could be registered on th next frame if this is called after
  35517. * the register component stage.
  35518. * @param component Defines the component to add to the scene
  35519. */
  35520. _addComponent(component: ISceneComponent): void;
  35521. /**
  35522. * @hidden
  35523. * Gets a component from the scene.
  35524. * @param name defines the name of the component to retrieve
  35525. * @returns the component or null if not present
  35526. */
  35527. _getComponent(name: string): Nullable<ISceneComponent>;
  35528. /**
  35529. * @hidden
  35530. * Defines the actions happening before camera updates.
  35531. */
  35532. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  35533. /**
  35534. * @hidden
  35535. * Defines the actions happening before clear the canvas.
  35536. */
  35537. _beforeClearStage: Stage<SimpleStageAction>;
  35538. /**
  35539. * @hidden
  35540. * Defines the actions when collecting render targets for the frame.
  35541. */
  35542. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  35543. /**
  35544. * @hidden
  35545. * Defines the actions happening for one camera in the frame.
  35546. */
  35547. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  35548. /**
  35549. * @hidden
  35550. * Defines the actions happening during the per mesh ready checks.
  35551. */
  35552. _isReadyForMeshStage: Stage<MeshStageAction>;
  35553. /**
  35554. * @hidden
  35555. * Defines the actions happening before evaluate active mesh checks.
  35556. */
  35557. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  35558. /**
  35559. * @hidden
  35560. * Defines the actions happening during the evaluate sub mesh checks.
  35561. */
  35562. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  35563. /**
  35564. * @hidden
  35565. * Defines the actions happening during the active mesh stage.
  35566. */
  35567. _activeMeshStage: Stage<ActiveMeshStageAction>;
  35568. /**
  35569. * @hidden
  35570. * Defines the actions happening during the per camera render target step.
  35571. */
  35572. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  35573. /**
  35574. * @hidden
  35575. * Defines the actions happening just before the active camera is drawing.
  35576. */
  35577. _beforeCameraDrawStage: Stage<CameraStageAction>;
  35578. /**
  35579. * @hidden
  35580. * Defines the actions happening just before a render target is drawing.
  35581. */
  35582. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  35583. /**
  35584. * @hidden
  35585. * Defines the actions happening just before a rendering group is drawing.
  35586. */
  35587. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  35588. /**
  35589. * @hidden
  35590. * Defines the actions happening just before a mesh is drawing.
  35591. */
  35592. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  35593. /**
  35594. * @hidden
  35595. * Defines the actions happening just after a mesh has been drawn.
  35596. */
  35597. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  35598. /**
  35599. * @hidden
  35600. * Defines the actions happening just after a rendering group has been drawn.
  35601. */
  35602. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  35603. /**
  35604. * @hidden
  35605. * Defines the actions happening just after the active camera has been drawn.
  35606. */
  35607. _afterCameraDrawStage: Stage<CameraStageAction>;
  35608. /**
  35609. * @hidden
  35610. * Defines the actions happening just after a render target has been drawn.
  35611. */
  35612. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  35613. /**
  35614. * @hidden
  35615. * Defines the actions happening just after rendering all cameras and computing intersections.
  35616. */
  35617. _afterRenderStage: Stage<SimpleStageAction>;
  35618. /**
  35619. * @hidden
  35620. * Defines the actions happening when a pointer move event happens.
  35621. */
  35622. _pointerMoveStage: Stage<PointerMoveStageAction>;
  35623. /**
  35624. * @hidden
  35625. * Defines the actions happening when a pointer down event happens.
  35626. */
  35627. _pointerDownStage: Stage<PointerUpDownStageAction>;
  35628. /**
  35629. * @hidden
  35630. * Defines the actions happening when a pointer up event happens.
  35631. */
  35632. _pointerUpStage: Stage<PointerUpDownStageAction>;
  35633. /**
  35634. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  35635. */
  35636. private geometriesByUniqueId;
  35637. /**
  35638. * Creates a new Scene
  35639. * @param engine defines the engine to use to render this scene
  35640. * @param options defines the scene options
  35641. */
  35642. constructor(engine: Engine, options?: SceneOptions);
  35643. /**
  35644. * Gets a string idenfifying the name of the class
  35645. * @returns "Scene" string
  35646. */
  35647. getClassName(): string;
  35648. private _defaultMeshCandidates;
  35649. /**
  35650. * @hidden
  35651. */
  35652. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  35653. private _defaultSubMeshCandidates;
  35654. /**
  35655. * @hidden
  35656. */
  35657. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  35658. /**
  35659. * Sets the default candidate providers for the scene.
  35660. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  35661. * and getCollidingSubMeshCandidates to their default function
  35662. */
  35663. setDefaultCandidateProviders(): void;
  35664. /**
  35665. * Gets the mesh that is currently under the pointer
  35666. */
  35667. get meshUnderPointer(): Nullable<AbstractMesh>;
  35668. /**
  35669. * Gets or sets the current on-screen X position of the pointer
  35670. */
  35671. get pointerX(): number;
  35672. set pointerX(value: number);
  35673. /**
  35674. * Gets or sets the current on-screen Y position of the pointer
  35675. */
  35676. get pointerY(): number;
  35677. set pointerY(value: number);
  35678. /**
  35679. * Gets the cached material (ie. the latest rendered one)
  35680. * @returns the cached material
  35681. */
  35682. getCachedMaterial(): Nullable<Material>;
  35683. /**
  35684. * Gets the cached effect (ie. the latest rendered one)
  35685. * @returns the cached effect
  35686. */
  35687. getCachedEffect(): Nullable<Effect>;
  35688. /**
  35689. * Gets the cached visibility state (ie. the latest rendered one)
  35690. * @returns the cached visibility state
  35691. */
  35692. getCachedVisibility(): Nullable<number>;
  35693. /**
  35694. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  35695. * @param material defines the current material
  35696. * @param effect defines the current effect
  35697. * @param visibility defines the current visibility state
  35698. * @returns true if one parameter is not cached
  35699. */
  35700. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  35701. /**
  35702. * Gets the engine associated with the scene
  35703. * @returns an Engine
  35704. */
  35705. getEngine(): Engine;
  35706. /**
  35707. * Gets the total number of vertices rendered per frame
  35708. * @returns the total number of vertices rendered per frame
  35709. */
  35710. getTotalVertices(): number;
  35711. /**
  35712. * Gets the performance counter for total vertices
  35713. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35714. */
  35715. get totalVerticesPerfCounter(): PerfCounter;
  35716. /**
  35717. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  35718. * @returns the total number of active indices rendered per frame
  35719. */
  35720. getActiveIndices(): number;
  35721. /**
  35722. * Gets the performance counter for active indices
  35723. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35724. */
  35725. get totalActiveIndicesPerfCounter(): PerfCounter;
  35726. /**
  35727. * Gets the total number of active particles rendered per frame
  35728. * @returns the total number of active particles rendered per frame
  35729. */
  35730. getActiveParticles(): number;
  35731. /**
  35732. * Gets the performance counter for active particles
  35733. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35734. */
  35735. get activeParticlesPerfCounter(): PerfCounter;
  35736. /**
  35737. * Gets the total number of active bones rendered per frame
  35738. * @returns the total number of active bones rendered per frame
  35739. */
  35740. getActiveBones(): number;
  35741. /**
  35742. * Gets the performance counter for active bones
  35743. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35744. */
  35745. get activeBonesPerfCounter(): PerfCounter;
  35746. /**
  35747. * Gets the array of active meshes
  35748. * @returns an array of AbstractMesh
  35749. */
  35750. getActiveMeshes(): SmartArray<AbstractMesh>;
  35751. /**
  35752. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  35753. * @returns a number
  35754. */
  35755. getAnimationRatio(): number;
  35756. /**
  35757. * Gets an unique Id for the current render phase
  35758. * @returns a number
  35759. */
  35760. getRenderId(): number;
  35761. /**
  35762. * Gets an unique Id for the current frame
  35763. * @returns a number
  35764. */
  35765. getFrameId(): number;
  35766. /** Call this function if you want to manually increment the render Id*/
  35767. incrementRenderId(): void;
  35768. private _createUbo;
  35769. /**
  35770. * Use this method to simulate a pointer move on a mesh
  35771. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35772. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35773. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35774. * @returns the current scene
  35775. */
  35776. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  35777. /**
  35778. * Use this method to simulate a pointer down on a mesh
  35779. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35780. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35781. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35782. * @returns the current scene
  35783. */
  35784. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  35785. /**
  35786. * Use this method to simulate a pointer up on a mesh
  35787. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35788. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35789. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35790. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  35791. * @returns the current scene
  35792. */
  35793. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  35794. /**
  35795. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  35796. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  35797. * @returns true if the pointer was captured
  35798. */
  35799. isPointerCaptured(pointerId?: number): boolean;
  35800. /**
  35801. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  35802. * @param attachUp defines if you want to attach events to pointerup
  35803. * @param attachDown defines if you want to attach events to pointerdown
  35804. * @param attachMove defines if you want to attach events to pointermove
  35805. */
  35806. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  35807. /** Detaches all event handlers*/
  35808. detachControl(): void;
  35809. /**
  35810. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  35811. * Delay loaded resources are not taking in account
  35812. * @return true if all required resources are ready
  35813. */
  35814. isReady(): boolean;
  35815. /** Resets all cached information relative to material (including effect and visibility) */
  35816. resetCachedMaterial(): void;
  35817. /**
  35818. * Registers a function to be called before every frame render
  35819. * @param func defines the function to register
  35820. */
  35821. registerBeforeRender(func: () => void): void;
  35822. /**
  35823. * Unregisters a function called before every frame render
  35824. * @param func defines the function to unregister
  35825. */
  35826. unregisterBeforeRender(func: () => void): void;
  35827. /**
  35828. * Registers a function to be called after every frame render
  35829. * @param func defines the function to register
  35830. */
  35831. registerAfterRender(func: () => void): void;
  35832. /**
  35833. * Unregisters a function called after every frame render
  35834. * @param func defines the function to unregister
  35835. */
  35836. unregisterAfterRender(func: () => void): void;
  35837. private _executeOnceBeforeRender;
  35838. /**
  35839. * The provided function will run before render once and will be disposed afterwards.
  35840. * A timeout delay can be provided so that the function will be executed in N ms.
  35841. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  35842. * @param func The function to be executed.
  35843. * @param timeout optional delay in ms
  35844. */
  35845. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  35846. /** @hidden */
  35847. _addPendingData(data: any): void;
  35848. /** @hidden */
  35849. _removePendingData(data: any): void;
  35850. /**
  35851. * Returns the number of items waiting to be loaded
  35852. * @returns the number of items waiting to be loaded
  35853. */
  35854. getWaitingItemsCount(): number;
  35855. /**
  35856. * Returns a boolean indicating if the scene is still loading data
  35857. */
  35858. get isLoading(): boolean;
  35859. /**
  35860. * Registers a function to be executed when the scene is ready
  35861. * @param {Function} func - the function to be executed
  35862. */
  35863. executeWhenReady(func: () => void): void;
  35864. /**
  35865. * Returns a promise that resolves when the scene is ready
  35866. * @returns A promise that resolves when the scene is ready
  35867. */
  35868. whenReadyAsync(): Promise<void>;
  35869. /** @hidden */
  35870. _checkIsReady(): void;
  35871. /**
  35872. * Gets all animatable attached to the scene
  35873. */
  35874. get animatables(): Animatable[];
  35875. /**
  35876. * Resets the last animation time frame.
  35877. * Useful to override when animations start running when loading a scene for the first time.
  35878. */
  35879. resetLastAnimationTimeFrame(): void;
  35880. /**
  35881. * Gets the current view matrix
  35882. * @returns a Matrix
  35883. */
  35884. getViewMatrix(): Matrix;
  35885. /**
  35886. * Gets the current projection matrix
  35887. * @returns a Matrix
  35888. */
  35889. getProjectionMatrix(): Matrix;
  35890. /**
  35891. * Gets the current transform matrix
  35892. * @returns a Matrix made of View * Projection
  35893. */
  35894. getTransformMatrix(): Matrix;
  35895. /**
  35896. * Sets the current transform matrix
  35897. * @param viewL defines the View matrix to use
  35898. * @param projectionL defines the Projection matrix to use
  35899. * @param viewR defines the right View matrix to use (if provided)
  35900. * @param projectionR defines the right Projection matrix to use (if provided)
  35901. */
  35902. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  35903. /**
  35904. * Gets the uniform buffer used to store scene data
  35905. * @returns a UniformBuffer
  35906. */
  35907. getSceneUniformBuffer(): UniformBuffer;
  35908. /**
  35909. * Gets an unique (relatively to the current scene) Id
  35910. * @returns an unique number for the scene
  35911. */
  35912. getUniqueId(): number;
  35913. /**
  35914. * Add a mesh to the list of scene's meshes
  35915. * @param newMesh defines the mesh to add
  35916. * @param recursive if all child meshes should also be added to the scene
  35917. */
  35918. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  35919. /**
  35920. * Remove a mesh for the list of scene's meshes
  35921. * @param toRemove defines the mesh to remove
  35922. * @param recursive if all child meshes should also be removed from the scene
  35923. * @returns the index where the mesh was in the mesh list
  35924. */
  35925. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  35926. /**
  35927. * Add a transform node to the list of scene's transform nodes
  35928. * @param newTransformNode defines the transform node to add
  35929. */
  35930. addTransformNode(newTransformNode: TransformNode): void;
  35931. /**
  35932. * Remove a transform node for the list of scene's transform nodes
  35933. * @param toRemove defines the transform node to remove
  35934. * @returns the index where the transform node was in the transform node list
  35935. */
  35936. removeTransformNode(toRemove: TransformNode): number;
  35937. /**
  35938. * Remove a skeleton for the list of scene's skeletons
  35939. * @param toRemove defines the skeleton to remove
  35940. * @returns the index where the skeleton was in the skeleton list
  35941. */
  35942. removeSkeleton(toRemove: Skeleton): number;
  35943. /**
  35944. * Remove a morph target for the list of scene's morph targets
  35945. * @param toRemove defines the morph target to remove
  35946. * @returns the index where the morph target was in the morph target list
  35947. */
  35948. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  35949. /**
  35950. * Remove a light for the list of scene's lights
  35951. * @param toRemove defines the light to remove
  35952. * @returns the index where the light was in the light list
  35953. */
  35954. removeLight(toRemove: Light): number;
  35955. /**
  35956. * Remove a camera for the list of scene's cameras
  35957. * @param toRemove defines the camera to remove
  35958. * @returns the index where the camera was in the camera list
  35959. */
  35960. removeCamera(toRemove: Camera): number;
  35961. /**
  35962. * Remove a particle system for the list of scene's particle systems
  35963. * @param toRemove defines the particle system to remove
  35964. * @returns the index where the particle system was in the particle system list
  35965. */
  35966. removeParticleSystem(toRemove: IParticleSystem): number;
  35967. /**
  35968. * Remove a animation for the list of scene's animations
  35969. * @param toRemove defines the animation to remove
  35970. * @returns the index where the animation was in the animation list
  35971. */
  35972. removeAnimation(toRemove: Animation): number;
  35973. /**
  35974. * Will stop the animation of the given target
  35975. * @param target - the target
  35976. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  35977. * @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)
  35978. */
  35979. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  35980. /**
  35981. * Removes the given animation group from this scene.
  35982. * @param toRemove The animation group to remove
  35983. * @returns The index of the removed animation group
  35984. */
  35985. removeAnimationGroup(toRemove: AnimationGroup): number;
  35986. /**
  35987. * Removes the given multi-material from this scene.
  35988. * @param toRemove The multi-material to remove
  35989. * @returns The index of the removed multi-material
  35990. */
  35991. removeMultiMaterial(toRemove: MultiMaterial): number;
  35992. /**
  35993. * Removes the given material from this scene.
  35994. * @param toRemove The material to remove
  35995. * @returns The index of the removed material
  35996. */
  35997. removeMaterial(toRemove: Material): number;
  35998. /**
  35999. * Removes the given action manager from this scene.
  36000. * @param toRemove The action manager to remove
  36001. * @returns The index of the removed action manager
  36002. */
  36003. removeActionManager(toRemove: AbstractActionManager): number;
  36004. /**
  36005. * Removes the given texture from this scene.
  36006. * @param toRemove The texture to remove
  36007. * @returns The index of the removed texture
  36008. */
  36009. removeTexture(toRemove: BaseTexture): number;
  36010. /**
  36011. * Adds the given light to this scene
  36012. * @param newLight The light to add
  36013. */
  36014. addLight(newLight: Light): void;
  36015. /**
  36016. * Sorts the list list based on light priorities
  36017. */
  36018. sortLightsByPriority(): void;
  36019. /**
  36020. * Adds the given camera to this scene
  36021. * @param newCamera The camera to add
  36022. */
  36023. addCamera(newCamera: Camera): void;
  36024. /**
  36025. * Adds the given skeleton to this scene
  36026. * @param newSkeleton The skeleton to add
  36027. */
  36028. addSkeleton(newSkeleton: Skeleton): void;
  36029. /**
  36030. * Adds the given particle system to this scene
  36031. * @param newParticleSystem The particle system to add
  36032. */
  36033. addParticleSystem(newParticleSystem: IParticleSystem): void;
  36034. /**
  36035. * Adds the given animation to this scene
  36036. * @param newAnimation The animation to add
  36037. */
  36038. addAnimation(newAnimation: Animation): void;
  36039. /**
  36040. * Adds the given animation group to this scene.
  36041. * @param newAnimationGroup The animation group to add
  36042. */
  36043. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  36044. /**
  36045. * Adds the given multi-material to this scene
  36046. * @param newMultiMaterial The multi-material to add
  36047. */
  36048. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  36049. /**
  36050. * Adds the given material to this scene
  36051. * @param newMaterial The material to add
  36052. */
  36053. addMaterial(newMaterial: Material): void;
  36054. /**
  36055. * Adds the given morph target to this scene
  36056. * @param newMorphTargetManager The morph target to add
  36057. */
  36058. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  36059. /**
  36060. * Adds the given geometry to this scene
  36061. * @param newGeometry The geometry to add
  36062. */
  36063. addGeometry(newGeometry: Geometry): void;
  36064. /**
  36065. * Adds the given action manager to this scene
  36066. * @param newActionManager The action manager to add
  36067. */
  36068. addActionManager(newActionManager: AbstractActionManager): void;
  36069. /**
  36070. * Adds the given texture to this scene.
  36071. * @param newTexture The texture to add
  36072. */
  36073. addTexture(newTexture: BaseTexture): void;
  36074. /**
  36075. * Switch active camera
  36076. * @param newCamera defines the new active camera
  36077. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  36078. */
  36079. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  36080. /**
  36081. * sets the active camera of the scene using its ID
  36082. * @param id defines the camera's ID
  36083. * @return the new active camera or null if none found.
  36084. */
  36085. setActiveCameraByID(id: string): Nullable<Camera>;
  36086. /**
  36087. * sets the active camera of the scene using its name
  36088. * @param name defines the camera's name
  36089. * @returns the new active camera or null if none found.
  36090. */
  36091. setActiveCameraByName(name: string): Nullable<Camera>;
  36092. /**
  36093. * get an animation group using its name
  36094. * @param name defines the material's name
  36095. * @return the animation group or null if none found.
  36096. */
  36097. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  36098. /**
  36099. * Get a material using its unique id
  36100. * @param uniqueId defines the material's unique id
  36101. * @return the material or null if none found.
  36102. */
  36103. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  36104. /**
  36105. * get a material using its id
  36106. * @param id defines the material's ID
  36107. * @return the material or null if none found.
  36108. */
  36109. getMaterialByID(id: string): Nullable<Material>;
  36110. /**
  36111. * Gets a the last added material using a given id
  36112. * @param id defines the material's ID
  36113. * @return the last material with the given id or null if none found.
  36114. */
  36115. getLastMaterialByID(id: string): Nullable<Material>;
  36116. /**
  36117. * Gets a material using its name
  36118. * @param name defines the material's name
  36119. * @return the material or null if none found.
  36120. */
  36121. getMaterialByName(name: string): Nullable<Material>;
  36122. /**
  36123. * Get a texture using its unique id
  36124. * @param uniqueId defines the texture's unique id
  36125. * @return the texture or null if none found.
  36126. */
  36127. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  36128. /**
  36129. * Gets a camera using its id
  36130. * @param id defines the id to look for
  36131. * @returns the camera or null if not found
  36132. */
  36133. getCameraByID(id: string): Nullable<Camera>;
  36134. /**
  36135. * Gets a camera using its unique id
  36136. * @param uniqueId defines the unique id to look for
  36137. * @returns the camera or null if not found
  36138. */
  36139. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  36140. /**
  36141. * Gets a camera using its name
  36142. * @param name defines the camera's name
  36143. * @return the camera or null if none found.
  36144. */
  36145. getCameraByName(name: string): Nullable<Camera>;
  36146. /**
  36147. * Gets a bone using its id
  36148. * @param id defines the bone's id
  36149. * @return the bone or null if not found
  36150. */
  36151. getBoneByID(id: string): Nullable<Bone>;
  36152. /**
  36153. * Gets a bone using its id
  36154. * @param name defines the bone's name
  36155. * @return the bone or null if not found
  36156. */
  36157. getBoneByName(name: string): Nullable<Bone>;
  36158. /**
  36159. * Gets a light node using its name
  36160. * @param name defines the the light's name
  36161. * @return the light or null if none found.
  36162. */
  36163. getLightByName(name: string): Nullable<Light>;
  36164. /**
  36165. * Gets a light node using its id
  36166. * @param id defines the light's id
  36167. * @return the light or null if none found.
  36168. */
  36169. getLightByID(id: string): Nullable<Light>;
  36170. /**
  36171. * Gets a light node using its scene-generated unique ID
  36172. * @param uniqueId defines the light's unique id
  36173. * @return the light or null if none found.
  36174. */
  36175. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  36176. /**
  36177. * Gets a particle system by id
  36178. * @param id defines the particle system id
  36179. * @return the corresponding system or null if none found
  36180. */
  36181. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  36182. /**
  36183. * Gets a geometry using its ID
  36184. * @param id defines the geometry's id
  36185. * @return the geometry or null if none found.
  36186. */
  36187. getGeometryByID(id: string): Nullable<Geometry>;
  36188. private _getGeometryByUniqueID;
  36189. /**
  36190. * Add a new geometry to this scene
  36191. * @param geometry defines the geometry to be added to the scene.
  36192. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  36193. * @return a boolean defining if the geometry was added or not
  36194. */
  36195. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  36196. /**
  36197. * Removes an existing geometry
  36198. * @param geometry defines the geometry to be removed from the scene
  36199. * @return a boolean defining if the geometry was removed or not
  36200. */
  36201. removeGeometry(geometry: Geometry): boolean;
  36202. /**
  36203. * Gets the list of geometries attached to the scene
  36204. * @returns an array of Geometry
  36205. */
  36206. getGeometries(): Geometry[];
  36207. /**
  36208. * Gets the first added mesh found of a given ID
  36209. * @param id defines the id to search for
  36210. * @return the mesh found or null if not found at all
  36211. */
  36212. getMeshByID(id: string): Nullable<AbstractMesh>;
  36213. /**
  36214. * Gets a list of meshes using their id
  36215. * @param id defines the id to search for
  36216. * @returns a list of meshes
  36217. */
  36218. getMeshesByID(id: string): Array<AbstractMesh>;
  36219. /**
  36220. * Gets the first added transform node found of a given ID
  36221. * @param id defines the id to search for
  36222. * @return the found transform node or null if not found at all.
  36223. */
  36224. getTransformNodeByID(id: string): Nullable<TransformNode>;
  36225. /**
  36226. * Gets a transform node with its auto-generated unique id
  36227. * @param uniqueId efines the unique id to search for
  36228. * @return the found transform node or null if not found at all.
  36229. */
  36230. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  36231. /**
  36232. * Gets a list of transform nodes using their id
  36233. * @param id defines the id to search for
  36234. * @returns a list of transform nodes
  36235. */
  36236. getTransformNodesByID(id: string): Array<TransformNode>;
  36237. /**
  36238. * Gets a mesh with its auto-generated unique id
  36239. * @param uniqueId defines the unique id to search for
  36240. * @return the found mesh or null if not found at all.
  36241. */
  36242. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  36243. /**
  36244. * Gets a the last added mesh using a given id
  36245. * @param id defines the id to search for
  36246. * @return the found mesh or null if not found at all.
  36247. */
  36248. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  36249. /**
  36250. * Gets a the last added node (Mesh, Camera, Light) using a given id
  36251. * @param id defines the id to search for
  36252. * @return the found node or null if not found at all
  36253. */
  36254. getLastEntryByID(id: string): Nullable<Node>;
  36255. /**
  36256. * Gets a node (Mesh, Camera, Light) using a given id
  36257. * @param id defines the id to search for
  36258. * @return the found node or null if not found at all
  36259. */
  36260. getNodeByID(id: string): Nullable<Node>;
  36261. /**
  36262. * Gets a node (Mesh, Camera, Light) using a given name
  36263. * @param name defines the name to search for
  36264. * @return the found node or null if not found at all.
  36265. */
  36266. getNodeByName(name: string): Nullable<Node>;
  36267. /**
  36268. * Gets a mesh using a given name
  36269. * @param name defines the name to search for
  36270. * @return the found mesh or null if not found at all.
  36271. */
  36272. getMeshByName(name: string): Nullable<AbstractMesh>;
  36273. /**
  36274. * Gets a transform node using a given name
  36275. * @param name defines the name to search for
  36276. * @return the found transform node or null if not found at all.
  36277. */
  36278. getTransformNodeByName(name: string): Nullable<TransformNode>;
  36279. /**
  36280. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  36281. * @param id defines the id to search for
  36282. * @return the found skeleton or null if not found at all.
  36283. */
  36284. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  36285. /**
  36286. * Gets a skeleton using a given auto generated unique id
  36287. * @param uniqueId defines the unique id to search for
  36288. * @return the found skeleton or null if not found at all.
  36289. */
  36290. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  36291. /**
  36292. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  36293. * @param id defines the id to search for
  36294. * @return the found skeleton or null if not found at all.
  36295. */
  36296. getSkeletonById(id: string): Nullable<Skeleton>;
  36297. /**
  36298. * Gets a skeleton using a given name
  36299. * @param name defines the name to search for
  36300. * @return the found skeleton or null if not found at all.
  36301. */
  36302. getSkeletonByName(name: string): Nullable<Skeleton>;
  36303. /**
  36304. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  36305. * @param id defines the id to search for
  36306. * @return the found morph target manager or null if not found at all.
  36307. */
  36308. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  36309. /**
  36310. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  36311. * @param id defines the id to search for
  36312. * @return the found morph target or null if not found at all.
  36313. */
  36314. getMorphTargetById(id: string): Nullable<MorphTarget>;
  36315. /**
  36316. * Gets a boolean indicating if the given mesh is active
  36317. * @param mesh defines the mesh to look for
  36318. * @returns true if the mesh is in the active list
  36319. */
  36320. isActiveMesh(mesh: AbstractMesh): boolean;
  36321. /**
  36322. * Return a unique id as a string which can serve as an identifier for the scene
  36323. */
  36324. get uid(): string;
  36325. /**
  36326. * Add an externaly attached data from its key.
  36327. * This method call will fail and return false, if such key already exists.
  36328. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  36329. * @param key the unique key that identifies the data
  36330. * @param data the data object to associate to the key for this Engine instance
  36331. * @return true if no such key were already present and the data was added successfully, false otherwise
  36332. */
  36333. addExternalData<T>(key: string, data: T): boolean;
  36334. /**
  36335. * Get an externaly attached data from its key
  36336. * @param key the unique key that identifies the data
  36337. * @return the associated data, if present (can be null), or undefined if not present
  36338. */
  36339. getExternalData<T>(key: string): Nullable<T>;
  36340. /**
  36341. * Get an externaly attached data from its key, create it using a factory if it's not already present
  36342. * @param key the unique key that identifies the data
  36343. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  36344. * @return the associated data, can be null if the factory returned null.
  36345. */
  36346. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  36347. /**
  36348. * Remove an externaly attached data from the Engine instance
  36349. * @param key the unique key that identifies the data
  36350. * @return true if the data was successfully removed, false if it doesn't exist
  36351. */
  36352. removeExternalData(key: string): boolean;
  36353. private _evaluateSubMesh;
  36354. /**
  36355. * Clear the processed materials smart array preventing retention point in material dispose.
  36356. */
  36357. freeProcessedMaterials(): void;
  36358. private _preventFreeActiveMeshesAndRenderingGroups;
  36359. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  36360. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  36361. * when disposing several meshes in a row or a hierarchy of meshes.
  36362. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  36363. */
  36364. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  36365. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  36366. /**
  36367. * Clear the active meshes smart array preventing retention point in mesh dispose.
  36368. */
  36369. freeActiveMeshes(): void;
  36370. /**
  36371. * Clear the info related to rendering groups preventing retention points during dispose.
  36372. */
  36373. freeRenderingGroups(): void;
  36374. /** @hidden */
  36375. _isInIntermediateRendering(): boolean;
  36376. /**
  36377. * Lambda returning the list of potentially active meshes.
  36378. */
  36379. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  36380. /**
  36381. * Lambda returning the list of potentially active sub meshes.
  36382. */
  36383. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  36384. /**
  36385. * Lambda returning the list of potentially intersecting sub meshes.
  36386. */
  36387. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  36388. /**
  36389. * Lambda returning the list of potentially colliding sub meshes.
  36390. */
  36391. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  36392. private _activeMeshesFrozen;
  36393. private _skipEvaluateActiveMeshesCompletely;
  36394. /**
  36395. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  36396. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  36397. * @returns the current scene
  36398. */
  36399. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  36400. /**
  36401. * Use this function to restart evaluating active meshes on every frame
  36402. * @returns the current scene
  36403. */
  36404. unfreezeActiveMeshes(): Scene;
  36405. private _evaluateActiveMeshes;
  36406. private _activeMesh;
  36407. /**
  36408. * Update the transform matrix to update from the current active camera
  36409. * @param force defines a boolean used to force the update even if cache is up to date
  36410. */
  36411. updateTransformMatrix(force?: boolean): void;
  36412. private _bindFrameBuffer;
  36413. /** @hidden */
  36414. _allowPostProcessClearColor: boolean;
  36415. /** @hidden */
  36416. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  36417. private _processSubCameras;
  36418. private _checkIntersections;
  36419. /** @hidden */
  36420. _advancePhysicsEngineStep(step: number): void;
  36421. /**
  36422. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  36423. */
  36424. getDeterministicFrameTime: () => number;
  36425. /** @hidden */
  36426. _animate(): void;
  36427. /** Execute all animations (for a frame) */
  36428. animate(): void;
  36429. /**
  36430. * Render the scene
  36431. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  36432. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  36433. */
  36434. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  36435. /**
  36436. * Freeze all materials
  36437. * A frozen material will not be updatable but should be faster to render
  36438. */
  36439. freezeMaterials(): void;
  36440. /**
  36441. * Unfreeze all materials
  36442. * A frozen material will not be updatable but should be faster to render
  36443. */
  36444. unfreezeMaterials(): void;
  36445. /**
  36446. * Releases all held ressources
  36447. */
  36448. dispose(): void;
  36449. /**
  36450. * Gets if the scene is already disposed
  36451. */
  36452. get isDisposed(): boolean;
  36453. /**
  36454. * Call this function to reduce memory footprint of the scene.
  36455. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  36456. */
  36457. clearCachedVertexData(): void;
  36458. /**
  36459. * This function will remove the local cached buffer data from texture.
  36460. * It will save memory but will prevent the texture from being rebuilt
  36461. */
  36462. cleanCachedTextureBuffer(): void;
  36463. /**
  36464. * Get the world extend vectors with an optional filter
  36465. *
  36466. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  36467. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  36468. */
  36469. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  36470. min: Vector3;
  36471. max: Vector3;
  36472. };
  36473. /**
  36474. * Creates a ray that can be used to pick in the scene
  36475. * @param x defines the x coordinate of the origin (on-screen)
  36476. * @param y defines the y coordinate of the origin (on-screen)
  36477. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  36478. * @param camera defines the camera to use for the picking
  36479. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  36480. * @returns a Ray
  36481. */
  36482. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  36483. /**
  36484. * Creates a ray that can be used to pick in the scene
  36485. * @param x defines the x coordinate of the origin (on-screen)
  36486. * @param y defines the y coordinate of the origin (on-screen)
  36487. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  36488. * @param result defines the ray where to store the picking ray
  36489. * @param camera defines the camera to use for the picking
  36490. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  36491. * @returns the current scene
  36492. */
  36493. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  36494. /**
  36495. * Creates a ray that can be used to pick in the scene
  36496. * @param x defines the x coordinate of the origin (on-screen)
  36497. * @param y defines the y coordinate of the origin (on-screen)
  36498. * @param camera defines the camera to use for the picking
  36499. * @returns a Ray
  36500. */
  36501. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  36502. /**
  36503. * Creates a ray that can be used to pick in the scene
  36504. * @param x defines the x coordinate of the origin (on-screen)
  36505. * @param y defines the y coordinate of the origin (on-screen)
  36506. * @param result defines the ray where to store the picking ray
  36507. * @param camera defines the camera to use for the picking
  36508. * @returns the current scene
  36509. */
  36510. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  36511. /** Launch a ray to try to pick a mesh in the scene
  36512. * @param x position on screen
  36513. * @param y position on screen
  36514. * @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
  36515. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  36516. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  36517. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36518. * @returns a PickingInfo
  36519. */
  36520. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  36521. /** Use the given ray to pick a mesh in the scene
  36522. * @param ray The ray to use to pick meshes
  36523. * @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
  36524. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  36525. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36526. * @returns a PickingInfo
  36527. */
  36528. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  36529. /**
  36530. * Launch a ray to try to pick a mesh in the scene
  36531. * @param x X position on screen
  36532. * @param y Y position on screen
  36533. * @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
  36534. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  36535. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36536. * @returns an array of PickingInfo
  36537. */
  36538. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  36539. /**
  36540. * Launch a ray to try to pick a mesh in the scene
  36541. * @param ray Ray to use
  36542. * @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
  36543. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36544. * @returns an array of PickingInfo
  36545. */
  36546. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  36547. /**
  36548. * Force the value of meshUnderPointer
  36549. * @param mesh defines the mesh to use
  36550. */
  36551. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  36552. /**
  36553. * Gets the mesh under the pointer
  36554. * @returns a Mesh or null if no mesh is under the pointer
  36555. */
  36556. getPointerOverMesh(): Nullable<AbstractMesh>;
  36557. /** @hidden */
  36558. _rebuildGeometries(): void;
  36559. /** @hidden */
  36560. _rebuildTextures(): void;
  36561. private _getByTags;
  36562. /**
  36563. * Get a list of meshes by tags
  36564. * @param tagsQuery defines the tags query to use
  36565. * @param forEach defines a predicate used to filter results
  36566. * @returns an array of Mesh
  36567. */
  36568. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  36569. /**
  36570. * Get a list of cameras by tags
  36571. * @param tagsQuery defines the tags query to use
  36572. * @param forEach defines a predicate used to filter results
  36573. * @returns an array of Camera
  36574. */
  36575. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  36576. /**
  36577. * Get a list of lights by tags
  36578. * @param tagsQuery defines the tags query to use
  36579. * @param forEach defines a predicate used to filter results
  36580. * @returns an array of Light
  36581. */
  36582. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  36583. /**
  36584. * Get a list of materials by tags
  36585. * @param tagsQuery defines the tags query to use
  36586. * @param forEach defines a predicate used to filter results
  36587. * @returns an array of Material
  36588. */
  36589. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  36590. /**
  36591. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  36592. * This allowed control for front to back rendering or reversly depending of the special needs.
  36593. *
  36594. * @param renderingGroupId The rendering group id corresponding to its index
  36595. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  36596. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  36597. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  36598. */
  36599. 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;
  36600. /**
  36601. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  36602. *
  36603. * @param renderingGroupId The rendering group id corresponding to its index
  36604. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  36605. * @param depth Automatically clears depth between groups if true and autoClear is true.
  36606. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  36607. */
  36608. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  36609. /**
  36610. * Gets the current auto clear configuration for one rendering group of the rendering
  36611. * manager.
  36612. * @param index the rendering group index to get the information for
  36613. * @returns The auto clear setup for the requested rendering group
  36614. */
  36615. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  36616. private _blockMaterialDirtyMechanism;
  36617. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  36618. get blockMaterialDirtyMechanism(): boolean;
  36619. set blockMaterialDirtyMechanism(value: boolean);
  36620. /**
  36621. * Will flag all materials as dirty to trigger new shader compilation
  36622. * @param flag defines the flag used to specify which material part must be marked as dirty
  36623. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  36624. */
  36625. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  36626. /** @hidden */
  36627. _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;
  36628. /** @hidden */
  36629. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  36630. /** @hidden */
  36631. _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;
  36632. /** @hidden */
  36633. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  36634. /** @hidden */
  36635. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  36636. /** @hidden */
  36637. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  36638. }
  36639. }
  36640. declare module BABYLON {
  36641. /**
  36642. * Set of assets to keep when moving a scene into an asset container.
  36643. */
  36644. export class KeepAssets extends AbstractScene {
  36645. }
  36646. /**
  36647. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  36648. */
  36649. export class InstantiatedEntries {
  36650. /**
  36651. * List of new root nodes (eg. nodes with no parent)
  36652. */
  36653. rootNodes: TransformNode[];
  36654. /**
  36655. * List of new skeletons
  36656. */
  36657. skeletons: Skeleton[];
  36658. /**
  36659. * List of new animation groups
  36660. */
  36661. animationGroups: AnimationGroup[];
  36662. }
  36663. /**
  36664. * Container with a set of assets that can be added or removed from a scene.
  36665. */
  36666. export class AssetContainer extends AbstractScene {
  36667. /**
  36668. * The scene the AssetContainer belongs to.
  36669. */
  36670. scene: Scene;
  36671. /**
  36672. * Instantiates an AssetContainer.
  36673. * @param scene The scene the AssetContainer belongs to.
  36674. */
  36675. constructor(scene: Scene);
  36676. /**
  36677. * Instantiate or clone all meshes and add the new ones to the scene.
  36678. * Skeletons and animation groups will all be cloned
  36679. * @param nameFunction defines an optional function used to get new names for clones
  36680. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  36681. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  36682. */
  36683. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  36684. /**
  36685. * Adds all the assets from the container to the scene.
  36686. */
  36687. addAllToScene(): void;
  36688. /**
  36689. * Removes all the assets in the container from the scene
  36690. */
  36691. removeAllFromScene(): void;
  36692. /**
  36693. * Disposes all the assets in the container
  36694. */
  36695. dispose(): void;
  36696. private _moveAssets;
  36697. /**
  36698. * Removes all the assets contained in the scene and adds them to the container.
  36699. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  36700. */
  36701. moveAllFromScene(keepAssets?: KeepAssets): void;
  36702. /**
  36703. * 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.
  36704. * @returns the root mesh
  36705. */
  36706. createRootMesh(): Mesh;
  36707. /**
  36708. * Merge animations from this asset container into a scene
  36709. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  36710. * @param animatables set of animatables to retarget to a node from the scene
  36711. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  36712. */
  36713. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  36714. }
  36715. }
  36716. declare module BABYLON {
  36717. /**
  36718. * Defines how the parser contract is defined.
  36719. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  36720. */
  36721. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  36722. /**
  36723. * Defines how the individual parser contract is defined.
  36724. * These parser can parse an individual asset
  36725. */
  36726. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  36727. /**
  36728. * Base class of the scene acting as a container for the different elements composing a scene.
  36729. * This class is dynamically extended by the different components of the scene increasing
  36730. * flexibility and reducing coupling
  36731. */
  36732. export abstract class AbstractScene {
  36733. /**
  36734. * Stores the list of available parsers in the application.
  36735. */
  36736. private static _BabylonFileParsers;
  36737. /**
  36738. * Stores the list of available individual parsers in the application.
  36739. */
  36740. private static _IndividualBabylonFileParsers;
  36741. /**
  36742. * Adds a parser in the list of available ones
  36743. * @param name Defines the name of the parser
  36744. * @param parser Defines the parser to add
  36745. */
  36746. static AddParser(name: string, parser: BabylonFileParser): void;
  36747. /**
  36748. * Gets a general parser from the list of avaialble ones
  36749. * @param name Defines the name of the parser
  36750. * @returns the requested parser or null
  36751. */
  36752. static GetParser(name: string): Nullable<BabylonFileParser>;
  36753. /**
  36754. * Adds n individual parser in the list of available ones
  36755. * @param name Defines the name of the parser
  36756. * @param parser Defines the parser to add
  36757. */
  36758. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  36759. /**
  36760. * Gets an individual parser from the list of avaialble ones
  36761. * @param name Defines the name of the parser
  36762. * @returns the requested parser or null
  36763. */
  36764. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  36765. /**
  36766. * Parser json data and populate both a scene and its associated container object
  36767. * @param jsonData Defines the data to parse
  36768. * @param scene Defines the scene to parse the data for
  36769. * @param container Defines the container attached to the parsing sequence
  36770. * @param rootUrl Defines the root url of the data
  36771. */
  36772. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  36773. /**
  36774. * Gets the list of root nodes (ie. nodes with no parent)
  36775. */
  36776. rootNodes: Node[];
  36777. /** All of the cameras added to this scene
  36778. * @see http://doc.babylonjs.com/babylon101/cameras
  36779. */
  36780. cameras: Camera[];
  36781. /**
  36782. * All of the lights added to this scene
  36783. * @see http://doc.babylonjs.com/babylon101/lights
  36784. */
  36785. lights: Light[];
  36786. /**
  36787. * All of the (abstract) meshes added to this scene
  36788. */
  36789. meshes: AbstractMesh[];
  36790. /**
  36791. * The list of skeletons added to the scene
  36792. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  36793. */
  36794. skeletons: Skeleton[];
  36795. /**
  36796. * All of the particle systems added to this scene
  36797. * @see http://doc.babylonjs.com/babylon101/particles
  36798. */
  36799. particleSystems: IParticleSystem[];
  36800. /**
  36801. * Gets a list of Animations associated with the scene
  36802. */
  36803. animations: Animation[];
  36804. /**
  36805. * All of the animation groups added to this scene
  36806. * @see http://doc.babylonjs.com/how_to/group
  36807. */
  36808. animationGroups: AnimationGroup[];
  36809. /**
  36810. * All of the multi-materials added to this scene
  36811. * @see http://doc.babylonjs.com/how_to/multi_materials
  36812. */
  36813. multiMaterials: MultiMaterial[];
  36814. /**
  36815. * All of the materials added to this scene
  36816. * In the context of a Scene, it is not supposed to be modified manually.
  36817. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  36818. * Note also that the order of the Material within the array is not significant and might change.
  36819. * @see http://doc.babylonjs.com/babylon101/materials
  36820. */
  36821. materials: Material[];
  36822. /**
  36823. * The list of morph target managers added to the scene
  36824. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  36825. */
  36826. morphTargetManagers: MorphTargetManager[];
  36827. /**
  36828. * The list of geometries used in the scene.
  36829. */
  36830. geometries: Geometry[];
  36831. /**
  36832. * All of the tranform nodes added to this scene
  36833. * In the context of a Scene, it is not supposed to be modified manually.
  36834. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  36835. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  36836. * @see http://doc.babylonjs.com/how_to/transformnode
  36837. */
  36838. transformNodes: TransformNode[];
  36839. /**
  36840. * ActionManagers available on the scene.
  36841. */
  36842. actionManagers: AbstractActionManager[];
  36843. /**
  36844. * Textures to keep.
  36845. */
  36846. textures: BaseTexture[];
  36847. /**
  36848. * Environment texture for the scene
  36849. */
  36850. environmentTexture: Nullable<BaseTexture>;
  36851. /**
  36852. * @returns all meshes, lights, cameras, transformNodes and bones
  36853. */
  36854. getNodes(): Array<Node>;
  36855. }
  36856. }
  36857. declare module BABYLON {
  36858. /**
  36859. * Interface used to define options for Sound class
  36860. */
  36861. export interface ISoundOptions {
  36862. /**
  36863. * Does the sound autoplay once loaded.
  36864. */
  36865. autoplay?: boolean;
  36866. /**
  36867. * Does the sound loop after it finishes playing once.
  36868. */
  36869. loop?: boolean;
  36870. /**
  36871. * Sound's volume
  36872. */
  36873. volume?: number;
  36874. /**
  36875. * Is it a spatial sound?
  36876. */
  36877. spatialSound?: boolean;
  36878. /**
  36879. * Maximum distance to hear that sound
  36880. */
  36881. maxDistance?: number;
  36882. /**
  36883. * Uses user defined attenuation function
  36884. */
  36885. useCustomAttenuation?: boolean;
  36886. /**
  36887. * Define the roll off factor of spatial sounds.
  36888. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36889. */
  36890. rolloffFactor?: number;
  36891. /**
  36892. * Define the reference distance the sound should be heard perfectly.
  36893. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36894. */
  36895. refDistance?: number;
  36896. /**
  36897. * Define the distance attenuation model the sound will follow.
  36898. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36899. */
  36900. distanceModel?: string;
  36901. /**
  36902. * Defines the playback speed (1 by default)
  36903. */
  36904. playbackRate?: number;
  36905. /**
  36906. * Defines if the sound is from a streaming source
  36907. */
  36908. streaming?: boolean;
  36909. /**
  36910. * Defines an optional length (in seconds) inside the sound file
  36911. */
  36912. length?: number;
  36913. /**
  36914. * Defines an optional offset (in seconds) inside the sound file
  36915. */
  36916. offset?: number;
  36917. /**
  36918. * If true, URLs will not be required to state the audio file codec to use.
  36919. */
  36920. skipCodecCheck?: boolean;
  36921. }
  36922. /**
  36923. * Defines a sound that can be played in the application.
  36924. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  36925. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36926. */
  36927. export class Sound {
  36928. /**
  36929. * The name of the sound in the scene.
  36930. */
  36931. name: string;
  36932. /**
  36933. * Does the sound autoplay once loaded.
  36934. */
  36935. autoplay: boolean;
  36936. /**
  36937. * Does the sound loop after it finishes playing once.
  36938. */
  36939. loop: boolean;
  36940. /**
  36941. * Does the sound use a custom attenuation curve to simulate the falloff
  36942. * happening when the source gets further away from the camera.
  36943. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  36944. */
  36945. useCustomAttenuation: boolean;
  36946. /**
  36947. * The sound track id this sound belongs to.
  36948. */
  36949. soundTrackId: number;
  36950. /**
  36951. * Is this sound currently played.
  36952. */
  36953. isPlaying: boolean;
  36954. /**
  36955. * Is this sound currently paused.
  36956. */
  36957. isPaused: boolean;
  36958. /**
  36959. * Does this sound enables spatial sound.
  36960. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36961. */
  36962. spatialSound: boolean;
  36963. /**
  36964. * Define the reference distance the sound should be heard perfectly.
  36965. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36966. */
  36967. refDistance: number;
  36968. /**
  36969. * Define the roll off factor of spatial sounds.
  36970. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36971. */
  36972. rolloffFactor: number;
  36973. /**
  36974. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  36975. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36976. */
  36977. maxDistance: number;
  36978. /**
  36979. * Define the distance attenuation model the sound will follow.
  36980. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36981. */
  36982. distanceModel: string;
  36983. /**
  36984. * @hidden
  36985. * Back Compat
  36986. **/
  36987. onended: () => any;
  36988. /**
  36989. * Observable event when the current playing sound finishes.
  36990. */
  36991. onEndedObservable: Observable<Sound>;
  36992. private _panningModel;
  36993. private _playbackRate;
  36994. private _streaming;
  36995. private _startTime;
  36996. private _startOffset;
  36997. private _position;
  36998. /** @hidden */
  36999. _positionInEmitterSpace: boolean;
  37000. private _localDirection;
  37001. private _volume;
  37002. private _isReadyToPlay;
  37003. private _isDirectional;
  37004. private _readyToPlayCallback;
  37005. private _audioBuffer;
  37006. private _soundSource;
  37007. private _streamingSource;
  37008. private _soundPanner;
  37009. private _soundGain;
  37010. private _inputAudioNode;
  37011. private _outputAudioNode;
  37012. private _coneInnerAngle;
  37013. private _coneOuterAngle;
  37014. private _coneOuterGain;
  37015. private _scene;
  37016. private _connectedTransformNode;
  37017. private _customAttenuationFunction;
  37018. private _registerFunc;
  37019. private _isOutputConnected;
  37020. private _htmlAudioElement;
  37021. private _urlType;
  37022. private _length?;
  37023. private _offset?;
  37024. /** @hidden */
  37025. static _SceneComponentInitialization: (scene: Scene) => void;
  37026. /**
  37027. * Create a sound and attach it to a scene
  37028. * @param name Name of your sound
  37029. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  37030. * @param scene defines the scene the sound belongs to
  37031. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  37032. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  37033. */
  37034. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  37035. /**
  37036. * Release the sound and its associated resources
  37037. */
  37038. dispose(): void;
  37039. /**
  37040. * Gets if the sounds is ready to be played or not.
  37041. * @returns true if ready, otherwise false
  37042. */
  37043. isReady(): boolean;
  37044. private _soundLoaded;
  37045. /**
  37046. * Sets the data of the sound from an audiobuffer
  37047. * @param audioBuffer The audioBuffer containing the data
  37048. */
  37049. setAudioBuffer(audioBuffer: AudioBuffer): void;
  37050. /**
  37051. * Updates the current sounds options such as maxdistance, loop...
  37052. * @param options A JSON object containing values named as the object properties
  37053. */
  37054. updateOptions(options: ISoundOptions): void;
  37055. private _createSpatialParameters;
  37056. private _updateSpatialParameters;
  37057. /**
  37058. * Switch the panning model to HRTF:
  37059. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  37060. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37061. */
  37062. switchPanningModelToHRTF(): void;
  37063. /**
  37064. * Switch the panning model to Equal Power:
  37065. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  37066. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37067. */
  37068. switchPanningModelToEqualPower(): void;
  37069. private _switchPanningModel;
  37070. /**
  37071. * Connect this sound to a sound track audio node like gain...
  37072. * @param soundTrackAudioNode the sound track audio node to connect to
  37073. */
  37074. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  37075. /**
  37076. * Transform this sound into a directional source
  37077. * @param coneInnerAngle Size of the inner cone in degree
  37078. * @param coneOuterAngle Size of the outer cone in degree
  37079. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  37080. */
  37081. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  37082. /**
  37083. * Gets or sets the inner angle for the directional cone.
  37084. */
  37085. get directionalConeInnerAngle(): number;
  37086. /**
  37087. * Gets or sets the inner angle for the directional cone.
  37088. */
  37089. set directionalConeInnerAngle(value: number);
  37090. /**
  37091. * Gets or sets the outer angle for the directional cone.
  37092. */
  37093. get directionalConeOuterAngle(): number;
  37094. /**
  37095. * Gets or sets the outer angle for the directional cone.
  37096. */
  37097. set directionalConeOuterAngle(value: number);
  37098. /**
  37099. * Sets the position of the emitter if spatial sound is enabled
  37100. * @param newPosition Defines the new posisiton
  37101. */
  37102. setPosition(newPosition: Vector3): void;
  37103. /**
  37104. * Sets the local direction of the emitter if spatial sound is enabled
  37105. * @param newLocalDirection Defines the new local direction
  37106. */
  37107. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  37108. private _updateDirection;
  37109. /** @hidden */
  37110. updateDistanceFromListener(): void;
  37111. /**
  37112. * Sets a new custom attenuation function for the sound.
  37113. * @param callback Defines the function used for the attenuation
  37114. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  37115. */
  37116. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  37117. /**
  37118. * Play the sound
  37119. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  37120. * @param offset (optional) Start the sound at a specific time in seconds
  37121. * @param length (optional) Sound duration (in seconds)
  37122. */
  37123. play(time?: number, offset?: number, length?: number): void;
  37124. private _onended;
  37125. /**
  37126. * Stop the sound
  37127. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  37128. */
  37129. stop(time?: number): void;
  37130. /**
  37131. * Put the sound in pause
  37132. */
  37133. pause(): void;
  37134. /**
  37135. * Sets a dedicated volume for this sounds
  37136. * @param newVolume Define the new volume of the sound
  37137. * @param time Define time for gradual change to new volume
  37138. */
  37139. setVolume(newVolume: number, time?: number): void;
  37140. /**
  37141. * Set the sound play back rate
  37142. * @param newPlaybackRate Define the playback rate the sound should be played at
  37143. */
  37144. setPlaybackRate(newPlaybackRate: number): void;
  37145. /**
  37146. * Gets the volume of the sound.
  37147. * @returns the volume of the sound
  37148. */
  37149. getVolume(): number;
  37150. /**
  37151. * Attach the sound to a dedicated mesh
  37152. * @param transformNode The transform node to connect the sound with
  37153. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  37154. */
  37155. attachToMesh(transformNode: TransformNode): void;
  37156. /**
  37157. * Detach the sound from the previously attached mesh
  37158. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  37159. */
  37160. detachFromMesh(): void;
  37161. private _onRegisterAfterWorldMatrixUpdate;
  37162. /**
  37163. * Clone the current sound in the scene.
  37164. * @returns the new sound clone
  37165. */
  37166. clone(): Nullable<Sound>;
  37167. /**
  37168. * Gets the current underlying audio buffer containing the data
  37169. * @returns the audio buffer
  37170. */
  37171. getAudioBuffer(): Nullable<AudioBuffer>;
  37172. /**
  37173. * Serializes the Sound in a JSON representation
  37174. * @returns the JSON representation of the sound
  37175. */
  37176. serialize(): any;
  37177. /**
  37178. * Parse a JSON representation of a sound to innstantiate in a given scene
  37179. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  37180. * @param scene Define the scene the new parsed sound should be created in
  37181. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  37182. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  37183. * @returns the newly parsed sound
  37184. */
  37185. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  37186. }
  37187. }
  37188. declare module BABYLON {
  37189. /**
  37190. * This defines an action helpful to play a defined sound on a triggered action.
  37191. */
  37192. export class PlaySoundAction extends Action {
  37193. private _sound;
  37194. /**
  37195. * Instantiate the action
  37196. * @param triggerOptions defines the trigger options
  37197. * @param sound defines the sound to play
  37198. * @param condition defines the trigger related conditions
  37199. */
  37200. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  37201. /** @hidden */
  37202. _prepare(): void;
  37203. /**
  37204. * Execute the action and play the sound.
  37205. */
  37206. execute(): void;
  37207. /**
  37208. * Serializes the actions and its related information.
  37209. * @param parent defines the object to serialize in
  37210. * @returns the serialized object
  37211. */
  37212. serialize(parent: any): any;
  37213. }
  37214. /**
  37215. * This defines an action helpful to stop a defined sound on a triggered action.
  37216. */
  37217. export class StopSoundAction extends Action {
  37218. private _sound;
  37219. /**
  37220. * Instantiate the action
  37221. * @param triggerOptions defines the trigger options
  37222. * @param sound defines the sound to stop
  37223. * @param condition defines the trigger related conditions
  37224. */
  37225. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  37226. /** @hidden */
  37227. _prepare(): void;
  37228. /**
  37229. * Execute the action and stop the sound.
  37230. */
  37231. execute(): void;
  37232. /**
  37233. * Serializes the actions and its related information.
  37234. * @param parent defines the object to serialize in
  37235. * @returns the serialized object
  37236. */
  37237. serialize(parent: any): any;
  37238. }
  37239. }
  37240. declare module BABYLON {
  37241. /**
  37242. * This defines an action responsible to change the value of a property
  37243. * by interpolating between its current value and the newly set one once triggered.
  37244. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  37245. */
  37246. export class InterpolateValueAction extends Action {
  37247. /**
  37248. * Defines the path of the property where the value should be interpolated
  37249. */
  37250. propertyPath: string;
  37251. /**
  37252. * Defines the target value at the end of the interpolation.
  37253. */
  37254. value: any;
  37255. /**
  37256. * Defines the time it will take for the property to interpolate to the value.
  37257. */
  37258. duration: number;
  37259. /**
  37260. * Defines if the other scene animations should be stopped when the action has been triggered
  37261. */
  37262. stopOtherAnimations?: boolean;
  37263. /**
  37264. * Defines a callback raised once the interpolation animation has been done.
  37265. */
  37266. onInterpolationDone?: () => void;
  37267. /**
  37268. * Observable triggered once the interpolation animation has been done.
  37269. */
  37270. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  37271. private _target;
  37272. private _effectiveTarget;
  37273. private _property;
  37274. /**
  37275. * Instantiate the action
  37276. * @param triggerOptions defines the trigger options
  37277. * @param target defines the object containing the value to interpolate
  37278. * @param propertyPath defines the path to the property in the target object
  37279. * @param value defines the target value at the end of the interpolation
  37280. * @param duration deines the time it will take for the property to interpolate to the value.
  37281. * @param condition defines the trigger related conditions
  37282. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  37283. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  37284. */
  37285. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  37286. /** @hidden */
  37287. _prepare(): void;
  37288. /**
  37289. * Execute the action starts the value interpolation.
  37290. */
  37291. execute(): void;
  37292. /**
  37293. * Serializes the actions and its related information.
  37294. * @param parent defines the object to serialize in
  37295. * @returns the serialized object
  37296. */
  37297. serialize(parent: any): any;
  37298. }
  37299. }
  37300. declare module BABYLON {
  37301. /**
  37302. * Options allowed during the creation of a sound track.
  37303. */
  37304. export interface ISoundTrackOptions {
  37305. /**
  37306. * The volume the sound track should take during creation
  37307. */
  37308. volume?: number;
  37309. /**
  37310. * Define if the sound track is the main sound track of the scene
  37311. */
  37312. mainTrack?: boolean;
  37313. }
  37314. /**
  37315. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  37316. * It will be also used in a future release to apply effects on a specific track.
  37317. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  37318. */
  37319. export class SoundTrack {
  37320. /**
  37321. * The unique identifier of the sound track in the scene.
  37322. */
  37323. id: number;
  37324. /**
  37325. * The list of sounds included in the sound track.
  37326. */
  37327. soundCollection: Array<Sound>;
  37328. private _outputAudioNode;
  37329. private _scene;
  37330. private _connectedAnalyser;
  37331. private _options;
  37332. private _isInitialized;
  37333. /**
  37334. * Creates a new sound track.
  37335. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  37336. * @param scene Define the scene the sound track belongs to
  37337. * @param options
  37338. */
  37339. constructor(scene: Scene, options?: ISoundTrackOptions);
  37340. private _initializeSoundTrackAudioGraph;
  37341. /**
  37342. * Release the sound track and its associated resources
  37343. */
  37344. dispose(): void;
  37345. /**
  37346. * Adds a sound to this sound track
  37347. * @param sound define the cound to add
  37348. * @ignoreNaming
  37349. */
  37350. AddSound(sound: Sound): void;
  37351. /**
  37352. * Removes a sound to this sound track
  37353. * @param sound define the cound to remove
  37354. * @ignoreNaming
  37355. */
  37356. RemoveSound(sound: Sound): void;
  37357. /**
  37358. * Set a global volume for the full sound track.
  37359. * @param newVolume Define the new volume of the sound track
  37360. */
  37361. setVolume(newVolume: number): void;
  37362. /**
  37363. * Switch the panning model to HRTF:
  37364. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  37365. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37366. */
  37367. switchPanningModelToHRTF(): void;
  37368. /**
  37369. * Switch the panning model to Equal Power:
  37370. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  37371. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37372. */
  37373. switchPanningModelToEqualPower(): void;
  37374. /**
  37375. * Connect the sound track to an audio analyser allowing some amazing
  37376. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  37377. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  37378. * @param analyser The analyser to connect to the engine
  37379. */
  37380. connectToAnalyser(analyser: Analyser): void;
  37381. }
  37382. }
  37383. declare module BABYLON {
  37384. interface AbstractScene {
  37385. /**
  37386. * The list of sounds used in the scene.
  37387. */
  37388. sounds: Nullable<Array<Sound>>;
  37389. }
  37390. interface Scene {
  37391. /**
  37392. * @hidden
  37393. * Backing field
  37394. */
  37395. _mainSoundTrack: SoundTrack;
  37396. /**
  37397. * The main sound track played by the scene.
  37398. * It cotains your primary collection of sounds.
  37399. */
  37400. mainSoundTrack: SoundTrack;
  37401. /**
  37402. * The list of sound tracks added to the scene
  37403. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37404. */
  37405. soundTracks: Nullable<Array<SoundTrack>>;
  37406. /**
  37407. * Gets a sound using a given name
  37408. * @param name defines the name to search for
  37409. * @return the found sound or null if not found at all.
  37410. */
  37411. getSoundByName(name: string): Nullable<Sound>;
  37412. /**
  37413. * Gets or sets if audio support is enabled
  37414. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37415. */
  37416. audioEnabled: boolean;
  37417. /**
  37418. * Gets or sets if audio will be output to headphones
  37419. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37420. */
  37421. headphone: boolean;
  37422. /**
  37423. * Gets or sets custom audio listener position provider
  37424. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37425. */
  37426. audioListenerPositionProvider: Nullable<() => Vector3>;
  37427. /**
  37428. * Gets or sets a refresh rate when using 3D audio positioning
  37429. */
  37430. audioPositioningRefreshRate: number;
  37431. }
  37432. /**
  37433. * Defines the sound scene component responsible to manage any sounds
  37434. * in a given scene.
  37435. */
  37436. export class AudioSceneComponent implements ISceneSerializableComponent {
  37437. /**
  37438. * The component name helpfull to identify the component in the list of scene components.
  37439. */
  37440. readonly name: string;
  37441. /**
  37442. * The scene the component belongs to.
  37443. */
  37444. scene: Scene;
  37445. private _audioEnabled;
  37446. /**
  37447. * Gets whether audio is enabled or not.
  37448. * Please use related enable/disable method to switch state.
  37449. */
  37450. get audioEnabled(): boolean;
  37451. private _headphone;
  37452. /**
  37453. * Gets whether audio is outputing to headphone or not.
  37454. * Please use the according Switch methods to change output.
  37455. */
  37456. get headphone(): boolean;
  37457. /**
  37458. * Gets or sets a refresh rate when using 3D audio positioning
  37459. */
  37460. audioPositioningRefreshRate: number;
  37461. private _audioListenerPositionProvider;
  37462. /**
  37463. * Gets the current audio listener position provider
  37464. */
  37465. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  37466. /**
  37467. * Sets a custom listener position for all sounds in the scene
  37468. * By default, this is the position of the first active camera
  37469. */
  37470. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  37471. /**
  37472. * Creates a new instance of the component for the given scene
  37473. * @param scene Defines the scene to register the component in
  37474. */
  37475. constructor(scene: Scene);
  37476. /**
  37477. * Registers the component in a given scene
  37478. */
  37479. register(): void;
  37480. /**
  37481. * Rebuilds the elements related to this component in case of
  37482. * context lost for instance.
  37483. */
  37484. rebuild(): void;
  37485. /**
  37486. * Serializes the component data to the specified json object
  37487. * @param serializationObject The object to serialize to
  37488. */
  37489. serialize(serializationObject: any): void;
  37490. /**
  37491. * Adds all the elements from the container to the scene
  37492. * @param container the container holding the elements
  37493. */
  37494. addFromContainer(container: AbstractScene): void;
  37495. /**
  37496. * Removes all the elements in the container from the scene
  37497. * @param container contains the elements to remove
  37498. * @param dispose if the removed element should be disposed (default: false)
  37499. */
  37500. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  37501. /**
  37502. * Disposes the component and the associated ressources.
  37503. */
  37504. dispose(): void;
  37505. /**
  37506. * Disables audio in the associated scene.
  37507. */
  37508. disableAudio(): void;
  37509. /**
  37510. * Enables audio in the associated scene.
  37511. */
  37512. enableAudio(): void;
  37513. /**
  37514. * Switch audio to headphone output.
  37515. */
  37516. switchAudioModeForHeadphones(): void;
  37517. /**
  37518. * Switch audio to normal speakers.
  37519. */
  37520. switchAudioModeForNormalSpeakers(): void;
  37521. private _cachedCameraDirection;
  37522. private _cachedCameraPosition;
  37523. private _lastCheck;
  37524. private _afterRender;
  37525. }
  37526. }
  37527. declare module BABYLON {
  37528. /**
  37529. * Wraps one or more Sound objects and selects one with random weight for playback.
  37530. */
  37531. export class WeightedSound {
  37532. /** When true a Sound will be selected and played when the current playing Sound completes. */
  37533. loop: boolean;
  37534. private _coneInnerAngle;
  37535. private _coneOuterAngle;
  37536. private _volume;
  37537. /** A Sound is currently playing. */
  37538. isPlaying: boolean;
  37539. /** A Sound is currently paused. */
  37540. isPaused: boolean;
  37541. private _sounds;
  37542. private _weights;
  37543. private _currentIndex?;
  37544. /**
  37545. * Creates a new WeightedSound from the list of sounds given.
  37546. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  37547. * @param sounds Array of Sounds that will be selected from.
  37548. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  37549. */
  37550. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  37551. /**
  37552. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  37553. */
  37554. get directionalConeInnerAngle(): number;
  37555. /**
  37556. * The size of cone in degress for a directional sound in which there will be no attenuation.
  37557. */
  37558. set directionalConeInnerAngle(value: number);
  37559. /**
  37560. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  37561. * Listener angles between innerAngle and outerAngle will falloff linearly.
  37562. */
  37563. get directionalConeOuterAngle(): number;
  37564. /**
  37565. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  37566. * Listener angles between innerAngle and outerAngle will falloff linearly.
  37567. */
  37568. set directionalConeOuterAngle(value: number);
  37569. /**
  37570. * Playback volume.
  37571. */
  37572. get volume(): number;
  37573. /**
  37574. * Playback volume.
  37575. */
  37576. set volume(value: number);
  37577. private _onended;
  37578. /**
  37579. * Suspend playback
  37580. */
  37581. pause(): void;
  37582. /**
  37583. * Stop playback
  37584. */
  37585. stop(): void;
  37586. /**
  37587. * Start playback.
  37588. * @param startOffset Position the clip head at a specific time in seconds.
  37589. */
  37590. play(startOffset?: number): void;
  37591. }
  37592. }
  37593. declare module BABYLON {
  37594. /**
  37595. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  37596. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37597. */
  37598. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  37599. /**
  37600. * Gets the name of the behavior.
  37601. */
  37602. get name(): string;
  37603. /**
  37604. * The easing function used by animations
  37605. */
  37606. static EasingFunction: BackEase;
  37607. /**
  37608. * The easing mode used by animations
  37609. */
  37610. static EasingMode: number;
  37611. /**
  37612. * The duration of the animation, in milliseconds
  37613. */
  37614. transitionDuration: number;
  37615. /**
  37616. * Length of the distance animated by the transition when lower radius is reached
  37617. */
  37618. lowerRadiusTransitionRange: number;
  37619. /**
  37620. * Length of the distance animated by the transition when upper radius is reached
  37621. */
  37622. upperRadiusTransitionRange: number;
  37623. private _autoTransitionRange;
  37624. /**
  37625. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  37626. */
  37627. get autoTransitionRange(): boolean;
  37628. /**
  37629. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  37630. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  37631. */
  37632. set autoTransitionRange(value: boolean);
  37633. private _attachedCamera;
  37634. private _onAfterCheckInputsObserver;
  37635. private _onMeshTargetChangedObserver;
  37636. /**
  37637. * Initializes the behavior.
  37638. */
  37639. init(): void;
  37640. /**
  37641. * Attaches the behavior to its arc rotate camera.
  37642. * @param camera Defines the camera to attach the behavior to
  37643. */
  37644. attach(camera: ArcRotateCamera): void;
  37645. /**
  37646. * Detaches the behavior from its current arc rotate camera.
  37647. */
  37648. detach(): void;
  37649. private _radiusIsAnimating;
  37650. private _radiusBounceTransition;
  37651. private _animatables;
  37652. private _cachedWheelPrecision;
  37653. /**
  37654. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  37655. * @param radiusLimit The limit to check against.
  37656. * @return Bool to indicate if at limit.
  37657. */
  37658. private _isRadiusAtLimit;
  37659. /**
  37660. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  37661. * @param radiusDelta The delta by which to animate to. Can be negative.
  37662. */
  37663. private _applyBoundRadiusAnimation;
  37664. /**
  37665. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  37666. */
  37667. protected _clearAnimationLocks(): void;
  37668. /**
  37669. * Stops and removes all animations that have been applied to the camera
  37670. */
  37671. stopAllAnimations(): void;
  37672. }
  37673. }
  37674. declare module BABYLON {
  37675. /**
  37676. * 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.
  37677. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37678. */
  37679. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  37680. /**
  37681. * Gets the name of the behavior.
  37682. */
  37683. get name(): string;
  37684. private _mode;
  37685. private _radiusScale;
  37686. private _positionScale;
  37687. private _defaultElevation;
  37688. private _elevationReturnTime;
  37689. private _elevationReturnWaitTime;
  37690. private _zoomStopsAnimation;
  37691. private _framingTime;
  37692. /**
  37693. * The easing function used by animations
  37694. */
  37695. static EasingFunction: ExponentialEase;
  37696. /**
  37697. * The easing mode used by animations
  37698. */
  37699. static EasingMode: number;
  37700. /**
  37701. * Sets the current mode used by the behavior
  37702. */
  37703. set mode(mode: number);
  37704. /**
  37705. * Gets current mode used by the behavior.
  37706. */
  37707. get mode(): number;
  37708. /**
  37709. * Sets the scale applied to the radius (1 by default)
  37710. */
  37711. set radiusScale(radius: number);
  37712. /**
  37713. * Gets the scale applied to the radius
  37714. */
  37715. get radiusScale(): number;
  37716. /**
  37717. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  37718. */
  37719. set positionScale(scale: number);
  37720. /**
  37721. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  37722. */
  37723. get positionScale(): number;
  37724. /**
  37725. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  37726. * behaviour is triggered, in radians.
  37727. */
  37728. set defaultElevation(elevation: number);
  37729. /**
  37730. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  37731. * behaviour is triggered, in radians.
  37732. */
  37733. get defaultElevation(): number;
  37734. /**
  37735. * Sets the time (in milliseconds) taken to return to the default beta position.
  37736. * Negative value indicates camera should not return to default.
  37737. */
  37738. set elevationReturnTime(speed: number);
  37739. /**
  37740. * Gets the time (in milliseconds) taken to return to the default beta position.
  37741. * Negative value indicates camera should not return to default.
  37742. */
  37743. get elevationReturnTime(): number;
  37744. /**
  37745. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  37746. */
  37747. set elevationReturnWaitTime(time: number);
  37748. /**
  37749. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  37750. */
  37751. get elevationReturnWaitTime(): number;
  37752. /**
  37753. * Sets the flag that indicates if user zooming should stop animation.
  37754. */
  37755. set zoomStopsAnimation(flag: boolean);
  37756. /**
  37757. * Gets the flag that indicates if user zooming should stop animation.
  37758. */
  37759. get zoomStopsAnimation(): boolean;
  37760. /**
  37761. * Sets the transition time when framing the mesh, in milliseconds
  37762. */
  37763. set framingTime(time: number);
  37764. /**
  37765. * Gets the transition time when framing the mesh, in milliseconds
  37766. */
  37767. get framingTime(): number;
  37768. /**
  37769. * Define if the behavior should automatically change the configured
  37770. * camera limits and sensibilities.
  37771. */
  37772. autoCorrectCameraLimitsAndSensibility: boolean;
  37773. private _onPrePointerObservableObserver;
  37774. private _onAfterCheckInputsObserver;
  37775. private _onMeshTargetChangedObserver;
  37776. private _attachedCamera;
  37777. private _isPointerDown;
  37778. private _lastInteractionTime;
  37779. /**
  37780. * Initializes the behavior.
  37781. */
  37782. init(): void;
  37783. /**
  37784. * Attaches the behavior to its arc rotate camera.
  37785. * @param camera Defines the camera to attach the behavior to
  37786. */
  37787. attach(camera: ArcRotateCamera): void;
  37788. /**
  37789. * Detaches the behavior from its current arc rotate camera.
  37790. */
  37791. detach(): void;
  37792. private _animatables;
  37793. private _betaIsAnimating;
  37794. private _betaTransition;
  37795. private _radiusTransition;
  37796. private _vectorTransition;
  37797. /**
  37798. * Targets the given mesh and updates zoom level accordingly.
  37799. * @param mesh The mesh to target.
  37800. * @param radius Optional. If a cached radius position already exists, overrides default.
  37801. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37802. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37803. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37804. */
  37805. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37806. /**
  37807. * Targets the given mesh with its children and updates zoom level accordingly.
  37808. * @param mesh The mesh to target.
  37809. * @param radius Optional. If a cached radius position already exists, overrides default.
  37810. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37811. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37812. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37813. */
  37814. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37815. /**
  37816. * Targets the given meshes with their children and updates zoom level accordingly.
  37817. * @param meshes The mesh to target.
  37818. * @param radius Optional. If a cached radius position already exists, overrides default.
  37819. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37820. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37821. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37822. */
  37823. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37824. /**
  37825. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  37826. * @param minimumWorld Determines the smaller position of the bounding box extend
  37827. * @param maximumWorld Determines the bigger position of the bounding box extend
  37828. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37829. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37830. */
  37831. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37832. /**
  37833. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  37834. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  37835. * frustum width.
  37836. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  37837. * to fully enclose the mesh in the viewing frustum.
  37838. */
  37839. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  37840. /**
  37841. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  37842. * is automatically returned to its default position (expected to be above ground plane).
  37843. */
  37844. private _maintainCameraAboveGround;
  37845. /**
  37846. * Returns the frustum slope based on the canvas ratio and camera FOV
  37847. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  37848. */
  37849. private _getFrustumSlope;
  37850. /**
  37851. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  37852. */
  37853. private _clearAnimationLocks;
  37854. /**
  37855. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  37856. */
  37857. private _applyUserInteraction;
  37858. /**
  37859. * Stops and removes all animations that have been applied to the camera
  37860. */
  37861. stopAllAnimations(): void;
  37862. /**
  37863. * Gets a value indicating if the user is moving the camera
  37864. */
  37865. get isUserIsMoving(): boolean;
  37866. /**
  37867. * The camera can move all the way towards the mesh.
  37868. */
  37869. static IgnoreBoundsSizeMode: number;
  37870. /**
  37871. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  37872. */
  37873. static FitFrustumSidesMode: number;
  37874. }
  37875. }
  37876. declare module BABYLON {
  37877. /**
  37878. * Base class for Camera Pointer Inputs.
  37879. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  37880. * for example usage.
  37881. */
  37882. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  37883. /**
  37884. * Defines the camera the input is attached to.
  37885. */
  37886. abstract camera: Camera;
  37887. /**
  37888. * Whether keyboard modifier keys are pressed at time of last mouse event.
  37889. */
  37890. protected _altKey: boolean;
  37891. protected _ctrlKey: boolean;
  37892. protected _metaKey: boolean;
  37893. protected _shiftKey: boolean;
  37894. /**
  37895. * Which mouse buttons were pressed at time of last mouse event.
  37896. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  37897. */
  37898. protected _buttonsPressed: number;
  37899. /**
  37900. * Defines the buttons associated with the input to handle camera move.
  37901. */
  37902. buttons: number[];
  37903. /**
  37904. * Attach the input controls to a specific dom element to get the input from.
  37905. * @param element Defines the element the controls should be listened from
  37906. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37907. */
  37908. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37909. /**
  37910. * Detach the current controls from the specified dom element.
  37911. * @param element Defines the element to stop listening the inputs from
  37912. */
  37913. detachControl(element: Nullable<HTMLElement>): void;
  37914. /**
  37915. * Gets the class name of the current input.
  37916. * @returns the class name
  37917. */
  37918. getClassName(): string;
  37919. /**
  37920. * Get the friendly name associated with the input class.
  37921. * @returns the input friendly name
  37922. */
  37923. getSimpleName(): string;
  37924. /**
  37925. * Called on pointer POINTERDOUBLETAP event.
  37926. * Override this method to provide functionality on POINTERDOUBLETAP event.
  37927. */
  37928. protected onDoubleTap(type: string): void;
  37929. /**
  37930. * Called on pointer POINTERMOVE event if only a single touch is active.
  37931. * Override this method to provide functionality.
  37932. */
  37933. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37934. /**
  37935. * Called on pointer POINTERMOVE event if multiple touches are active.
  37936. * Override this method to provide functionality.
  37937. */
  37938. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37939. /**
  37940. * Called on JS contextmenu event.
  37941. * Override this method to provide functionality.
  37942. */
  37943. protected onContextMenu(evt: PointerEvent): void;
  37944. /**
  37945. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  37946. * press.
  37947. * Override this method to provide functionality.
  37948. */
  37949. protected onButtonDown(evt: PointerEvent): void;
  37950. /**
  37951. * Called each time a new POINTERUP event occurs. Ie, for each button
  37952. * release.
  37953. * Override this method to provide functionality.
  37954. */
  37955. protected onButtonUp(evt: PointerEvent): void;
  37956. /**
  37957. * Called when window becomes inactive.
  37958. * Override this method to provide functionality.
  37959. */
  37960. protected onLostFocus(): void;
  37961. private _pointerInput;
  37962. private _observer;
  37963. private _onLostFocus;
  37964. private pointA;
  37965. private pointB;
  37966. }
  37967. }
  37968. declare module BABYLON {
  37969. /**
  37970. * Manage the pointers inputs to control an arc rotate camera.
  37971. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37972. */
  37973. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  37974. /**
  37975. * Defines the camera the input is attached to.
  37976. */
  37977. camera: ArcRotateCamera;
  37978. /**
  37979. * Gets the class name of the current input.
  37980. * @returns the class name
  37981. */
  37982. getClassName(): string;
  37983. /**
  37984. * Defines the buttons associated with the input to handle camera move.
  37985. */
  37986. buttons: number[];
  37987. /**
  37988. * Defines the pointer angular sensibility along the X axis or how fast is
  37989. * the camera rotating.
  37990. */
  37991. angularSensibilityX: number;
  37992. /**
  37993. * Defines the pointer angular sensibility along the Y axis or how fast is
  37994. * the camera rotating.
  37995. */
  37996. angularSensibilityY: number;
  37997. /**
  37998. * Defines the pointer pinch precision or how fast is the camera zooming.
  37999. */
  38000. pinchPrecision: number;
  38001. /**
  38002. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  38003. * from 0.
  38004. * It defines the percentage of current camera.radius to use as delta when
  38005. * pinch zoom is used.
  38006. */
  38007. pinchDeltaPercentage: number;
  38008. /**
  38009. * Defines the pointer panning sensibility or how fast is the camera moving.
  38010. */
  38011. panningSensibility: number;
  38012. /**
  38013. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  38014. */
  38015. multiTouchPanning: boolean;
  38016. /**
  38017. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  38018. * zoom (pinch) through multitouch.
  38019. */
  38020. multiTouchPanAndZoom: boolean;
  38021. /**
  38022. * Revers pinch action direction.
  38023. */
  38024. pinchInwards: boolean;
  38025. private _isPanClick;
  38026. private _twoFingerActivityCount;
  38027. private _isPinching;
  38028. /**
  38029. * Called on pointer POINTERMOVE event if only a single touch is active.
  38030. */
  38031. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38032. /**
  38033. * Called on pointer POINTERDOUBLETAP event.
  38034. */
  38035. protected onDoubleTap(type: string): void;
  38036. /**
  38037. * Called on pointer POINTERMOVE event if multiple touches are active.
  38038. */
  38039. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38040. /**
  38041. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  38042. * press.
  38043. */
  38044. protected onButtonDown(evt: PointerEvent): void;
  38045. /**
  38046. * Called each time a new POINTERUP event occurs. Ie, for each button
  38047. * release.
  38048. */
  38049. protected onButtonUp(evt: PointerEvent): void;
  38050. /**
  38051. * Called when window becomes inactive.
  38052. */
  38053. protected onLostFocus(): void;
  38054. }
  38055. }
  38056. declare module BABYLON {
  38057. /**
  38058. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  38059. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38060. */
  38061. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  38062. /**
  38063. * Defines the camera the input is attached to.
  38064. */
  38065. camera: ArcRotateCamera;
  38066. /**
  38067. * Defines the list of key codes associated with the up action (increase alpha)
  38068. */
  38069. keysUp: number[];
  38070. /**
  38071. * Defines the list of key codes associated with the down action (decrease alpha)
  38072. */
  38073. keysDown: number[];
  38074. /**
  38075. * Defines the list of key codes associated with the left action (increase beta)
  38076. */
  38077. keysLeft: number[];
  38078. /**
  38079. * Defines the list of key codes associated with the right action (decrease beta)
  38080. */
  38081. keysRight: number[];
  38082. /**
  38083. * Defines the list of key codes associated with the reset action.
  38084. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  38085. */
  38086. keysReset: number[];
  38087. /**
  38088. * Defines the panning sensibility of the inputs.
  38089. * (How fast is the camera paning)
  38090. */
  38091. panningSensibility: number;
  38092. /**
  38093. * Defines the zooming sensibility of the inputs.
  38094. * (How fast is the camera zooming)
  38095. */
  38096. zoomingSensibility: number;
  38097. /**
  38098. * Defines wether maintaining the alt key down switch the movement mode from
  38099. * orientation to zoom.
  38100. */
  38101. useAltToZoom: boolean;
  38102. /**
  38103. * Rotation speed of the camera
  38104. */
  38105. angularSpeed: number;
  38106. private _keys;
  38107. private _ctrlPressed;
  38108. private _altPressed;
  38109. private _onCanvasBlurObserver;
  38110. private _onKeyboardObserver;
  38111. private _engine;
  38112. private _scene;
  38113. /**
  38114. * Attach the input controls to a specific dom element to get the input from.
  38115. * @param element Defines the element the controls should be listened from
  38116. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38117. */
  38118. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38119. /**
  38120. * Detach the current controls from the specified dom element.
  38121. * @param element Defines the element to stop listening the inputs from
  38122. */
  38123. detachControl(element: Nullable<HTMLElement>): void;
  38124. /**
  38125. * Update the current camera state depending on the inputs that have been used this frame.
  38126. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38127. */
  38128. checkInputs(): void;
  38129. /**
  38130. * Gets the class name of the current intput.
  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. }
  38141. declare module BABYLON {
  38142. /**
  38143. * Manage the mouse wheel inputs to control an arc rotate camera.
  38144. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38145. */
  38146. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  38147. /**
  38148. * Defines the camera the input is attached to.
  38149. */
  38150. camera: ArcRotateCamera;
  38151. /**
  38152. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  38153. */
  38154. wheelPrecision: number;
  38155. /**
  38156. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  38157. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  38158. */
  38159. wheelDeltaPercentage: number;
  38160. private _wheel;
  38161. private _observer;
  38162. private computeDeltaFromMouseWheelLegacyEvent;
  38163. /**
  38164. * Attach the input controls to a specific dom element to get the input from.
  38165. * @param element Defines the element the controls should be listened from
  38166. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38167. */
  38168. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38169. /**
  38170. * Detach the current controls from the specified dom element.
  38171. * @param element Defines the element to stop listening the inputs from
  38172. */
  38173. detachControl(element: Nullable<HTMLElement>): void;
  38174. /**
  38175. * Gets the class name of the current intput.
  38176. * @returns the class name
  38177. */
  38178. getClassName(): string;
  38179. /**
  38180. * Get the friendly name associated with the input class.
  38181. * @returns the input friendly name
  38182. */
  38183. getSimpleName(): string;
  38184. }
  38185. }
  38186. declare module BABYLON {
  38187. /**
  38188. * Default Inputs manager for the ArcRotateCamera.
  38189. * It groups all the default supported inputs for ease of use.
  38190. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38191. */
  38192. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  38193. /**
  38194. * Instantiates a new ArcRotateCameraInputsManager.
  38195. * @param camera Defines the camera the inputs belong to
  38196. */
  38197. constructor(camera: ArcRotateCamera);
  38198. /**
  38199. * Add mouse wheel input support to the input manager.
  38200. * @returns the current input manager
  38201. */
  38202. addMouseWheel(): ArcRotateCameraInputsManager;
  38203. /**
  38204. * Add pointers input support to the input manager.
  38205. * @returns the current input manager
  38206. */
  38207. addPointers(): ArcRotateCameraInputsManager;
  38208. /**
  38209. * Add keyboard input support to the input manager.
  38210. * @returns the current input manager
  38211. */
  38212. addKeyboard(): ArcRotateCameraInputsManager;
  38213. }
  38214. }
  38215. declare module BABYLON {
  38216. /**
  38217. * This represents an orbital type of camera.
  38218. *
  38219. * 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.
  38220. * 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.
  38221. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  38222. */
  38223. export class ArcRotateCamera extends TargetCamera {
  38224. /**
  38225. * Defines the rotation angle of the camera along the longitudinal axis.
  38226. */
  38227. alpha: number;
  38228. /**
  38229. * Defines the rotation angle of the camera along the latitudinal axis.
  38230. */
  38231. beta: number;
  38232. /**
  38233. * Defines the radius of the camera from it s target point.
  38234. */
  38235. radius: number;
  38236. protected _target: Vector3;
  38237. protected _targetHost: Nullable<AbstractMesh>;
  38238. /**
  38239. * Defines the target point of the camera.
  38240. * The camera looks towards it form the radius distance.
  38241. */
  38242. get target(): Vector3;
  38243. set target(value: Vector3);
  38244. /**
  38245. * Define the current local position of the camera in the scene
  38246. */
  38247. get position(): Vector3;
  38248. set position(newPosition: Vector3);
  38249. protected _upVector: Vector3;
  38250. protected _upToYMatrix: Matrix;
  38251. protected _YToUpMatrix: Matrix;
  38252. /**
  38253. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  38254. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  38255. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  38256. */
  38257. set upVector(vec: Vector3);
  38258. get upVector(): Vector3;
  38259. /**
  38260. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  38261. */
  38262. setMatUp(): void;
  38263. /**
  38264. * Current inertia value on the longitudinal axis.
  38265. * The bigger this number the longer it will take for the camera to stop.
  38266. */
  38267. inertialAlphaOffset: number;
  38268. /**
  38269. * Current inertia value on the latitudinal axis.
  38270. * The bigger this number the longer it will take for the camera to stop.
  38271. */
  38272. inertialBetaOffset: number;
  38273. /**
  38274. * Current inertia value on the radius axis.
  38275. * The bigger this number the longer it will take for the camera to stop.
  38276. */
  38277. inertialRadiusOffset: number;
  38278. /**
  38279. * Minimum allowed angle on the longitudinal axis.
  38280. * This can help limiting how the Camera is able to move in the scene.
  38281. */
  38282. lowerAlphaLimit: Nullable<number>;
  38283. /**
  38284. * Maximum allowed angle on the longitudinal axis.
  38285. * This can help limiting how the Camera is able to move in the scene.
  38286. */
  38287. upperAlphaLimit: Nullable<number>;
  38288. /**
  38289. * Minimum allowed angle on the latitudinal axis.
  38290. * This can help limiting how the Camera is able to move in the scene.
  38291. */
  38292. lowerBetaLimit: number;
  38293. /**
  38294. * Maximum allowed angle on the latitudinal axis.
  38295. * This can help limiting how the Camera is able to move in the scene.
  38296. */
  38297. upperBetaLimit: number;
  38298. /**
  38299. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  38300. * This can help limiting how the Camera is able to move in the scene.
  38301. */
  38302. lowerRadiusLimit: Nullable<number>;
  38303. /**
  38304. * Maximum allowed distance of the camera to the target (The camera can not get further).
  38305. * This can help limiting how the Camera is able to move in the scene.
  38306. */
  38307. upperRadiusLimit: Nullable<number>;
  38308. /**
  38309. * Defines the current inertia value used during panning of the camera along the X axis.
  38310. */
  38311. inertialPanningX: number;
  38312. /**
  38313. * Defines the current inertia value used during panning of the camera along the Y axis.
  38314. */
  38315. inertialPanningY: number;
  38316. /**
  38317. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  38318. * Basically if your fingers moves away from more than this distance you will be considered
  38319. * in pinch mode.
  38320. */
  38321. pinchToPanMaxDistance: number;
  38322. /**
  38323. * Defines the maximum distance the camera can pan.
  38324. * This could help keeping the cammera always in your scene.
  38325. */
  38326. panningDistanceLimit: Nullable<number>;
  38327. /**
  38328. * Defines the target of the camera before paning.
  38329. */
  38330. panningOriginTarget: Vector3;
  38331. /**
  38332. * Defines the value of the inertia used during panning.
  38333. * 0 would mean stop inertia and one would mean no decelleration at all.
  38334. */
  38335. panningInertia: number;
  38336. /**
  38337. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  38338. */
  38339. get angularSensibilityX(): number;
  38340. set angularSensibilityX(value: number);
  38341. /**
  38342. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  38343. */
  38344. get angularSensibilityY(): number;
  38345. set angularSensibilityY(value: number);
  38346. /**
  38347. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  38348. */
  38349. get pinchPrecision(): number;
  38350. set pinchPrecision(value: number);
  38351. /**
  38352. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  38353. * It will be used instead of pinchDeltaPrecision if different from 0.
  38354. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  38355. */
  38356. get pinchDeltaPercentage(): number;
  38357. set pinchDeltaPercentage(value: number);
  38358. /**
  38359. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  38360. */
  38361. get panningSensibility(): number;
  38362. set panningSensibility(value: number);
  38363. /**
  38364. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  38365. */
  38366. get keysUp(): number[];
  38367. set keysUp(value: number[]);
  38368. /**
  38369. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  38370. */
  38371. get keysDown(): number[];
  38372. set keysDown(value: number[]);
  38373. /**
  38374. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  38375. */
  38376. get keysLeft(): number[];
  38377. set keysLeft(value: number[]);
  38378. /**
  38379. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  38380. */
  38381. get keysRight(): number[];
  38382. set keysRight(value: number[]);
  38383. /**
  38384. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  38385. */
  38386. get wheelPrecision(): number;
  38387. set wheelPrecision(value: number);
  38388. /**
  38389. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  38390. * It will be used instead of pinchDeltaPrecision if different from 0.
  38391. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  38392. */
  38393. get wheelDeltaPercentage(): number;
  38394. set wheelDeltaPercentage(value: number);
  38395. /**
  38396. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  38397. */
  38398. zoomOnFactor: number;
  38399. /**
  38400. * Defines a screen offset for the camera position.
  38401. */
  38402. targetScreenOffset: Vector2;
  38403. /**
  38404. * Allows the camera to be completely reversed.
  38405. * If false the camera can not arrive upside down.
  38406. */
  38407. allowUpsideDown: boolean;
  38408. /**
  38409. * Define if double tap/click is used to restore the previously saved state of the camera.
  38410. */
  38411. useInputToRestoreState: boolean;
  38412. /** @hidden */
  38413. _viewMatrix: Matrix;
  38414. /** @hidden */
  38415. _useCtrlForPanning: boolean;
  38416. /** @hidden */
  38417. _panningMouseButton: number;
  38418. /**
  38419. * Defines the input associated to the camera.
  38420. */
  38421. inputs: ArcRotateCameraInputsManager;
  38422. /** @hidden */
  38423. _reset: () => void;
  38424. /**
  38425. * Defines the allowed panning axis.
  38426. */
  38427. panningAxis: Vector3;
  38428. protected _localDirection: Vector3;
  38429. protected _transformedDirection: Vector3;
  38430. private _bouncingBehavior;
  38431. /**
  38432. * Gets the bouncing behavior of the camera if it has been enabled.
  38433. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38434. */
  38435. get bouncingBehavior(): Nullable<BouncingBehavior>;
  38436. /**
  38437. * Defines if the bouncing behavior of the camera is enabled on the camera.
  38438. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38439. */
  38440. get useBouncingBehavior(): boolean;
  38441. set useBouncingBehavior(value: boolean);
  38442. private _framingBehavior;
  38443. /**
  38444. * Gets the framing behavior of the camera if it has been enabled.
  38445. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38446. */
  38447. get framingBehavior(): Nullable<FramingBehavior>;
  38448. /**
  38449. * Defines if the framing behavior of the camera is enabled on the camera.
  38450. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38451. */
  38452. get useFramingBehavior(): boolean;
  38453. set useFramingBehavior(value: boolean);
  38454. private _autoRotationBehavior;
  38455. /**
  38456. * Gets the auto rotation behavior of the camera if it has been enabled.
  38457. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38458. */
  38459. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  38460. /**
  38461. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  38462. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38463. */
  38464. get useAutoRotationBehavior(): boolean;
  38465. set useAutoRotationBehavior(value: boolean);
  38466. /**
  38467. * Observable triggered when the mesh target has been changed on the camera.
  38468. */
  38469. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  38470. /**
  38471. * Event raised when the camera is colliding with a mesh.
  38472. */
  38473. onCollide: (collidedMesh: AbstractMesh) => void;
  38474. /**
  38475. * Defines whether the camera should check collision with the objects oh the scene.
  38476. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  38477. */
  38478. checkCollisions: boolean;
  38479. /**
  38480. * Defines the collision radius of the camera.
  38481. * This simulates a sphere around the camera.
  38482. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  38483. */
  38484. collisionRadius: Vector3;
  38485. protected _collider: Collider;
  38486. protected _previousPosition: Vector3;
  38487. protected _collisionVelocity: Vector3;
  38488. protected _newPosition: Vector3;
  38489. protected _previousAlpha: number;
  38490. protected _previousBeta: number;
  38491. protected _previousRadius: number;
  38492. protected _collisionTriggered: boolean;
  38493. protected _targetBoundingCenter: Nullable<Vector3>;
  38494. private _computationVector;
  38495. /**
  38496. * Instantiates a new ArcRotateCamera in a given scene
  38497. * @param name Defines the name of the camera
  38498. * @param alpha Defines the camera rotation along the logitudinal axis
  38499. * @param beta Defines the camera rotation along the latitudinal axis
  38500. * @param radius Defines the camera distance from its target
  38501. * @param target Defines the camera target
  38502. * @param scene Defines the scene the camera belongs to
  38503. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  38504. */
  38505. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38506. /** @hidden */
  38507. _initCache(): void;
  38508. /** @hidden */
  38509. _updateCache(ignoreParentClass?: boolean): void;
  38510. protected _getTargetPosition(): Vector3;
  38511. private _storedAlpha;
  38512. private _storedBeta;
  38513. private _storedRadius;
  38514. private _storedTarget;
  38515. private _storedTargetScreenOffset;
  38516. /**
  38517. * Stores the current state of the camera (alpha, beta, radius and target)
  38518. * @returns the camera itself
  38519. */
  38520. storeState(): Camera;
  38521. /**
  38522. * @hidden
  38523. * Restored camera state. You must call storeState() first
  38524. */
  38525. _restoreStateValues(): boolean;
  38526. /** @hidden */
  38527. _isSynchronizedViewMatrix(): boolean;
  38528. /**
  38529. * Attached controls to the current camera.
  38530. * @param element Defines the element the controls should be listened from
  38531. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38532. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  38533. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  38534. */
  38535. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  38536. /**
  38537. * Detach the current controls from the camera.
  38538. * The camera will stop reacting to inputs.
  38539. * @param element Defines the element to stop listening the inputs from
  38540. */
  38541. detachControl(element: HTMLElement): void;
  38542. /** @hidden */
  38543. _checkInputs(): void;
  38544. protected _checkLimits(): void;
  38545. /**
  38546. * Rebuilds angles (alpha, beta) and radius from the give position and target
  38547. */
  38548. rebuildAnglesAndRadius(): void;
  38549. /**
  38550. * Use a position to define the current camera related information like alpha, beta and radius
  38551. * @param position Defines the position to set the camera at
  38552. */
  38553. setPosition(position: Vector3): void;
  38554. /**
  38555. * Defines the target the camera should look at.
  38556. * This will automatically adapt alpha beta and radius to fit within the new target.
  38557. * @param target Defines the new target as a Vector or a mesh
  38558. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  38559. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  38560. */
  38561. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  38562. /** @hidden */
  38563. _getViewMatrix(): Matrix;
  38564. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  38565. /**
  38566. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  38567. * @param meshes Defines the mesh to zoom on
  38568. * @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)
  38569. */
  38570. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  38571. /**
  38572. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  38573. * The target will be changed but the radius
  38574. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  38575. * @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)
  38576. */
  38577. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  38578. min: Vector3;
  38579. max: Vector3;
  38580. distance: number;
  38581. }, doNotUpdateMaxZ?: boolean): void;
  38582. /**
  38583. * @override
  38584. * Override Camera.createRigCamera
  38585. */
  38586. createRigCamera(name: string, cameraIndex: number): Camera;
  38587. /**
  38588. * @hidden
  38589. * @override
  38590. * Override Camera._updateRigCameras
  38591. */
  38592. _updateRigCameras(): void;
  38593. /**
  38594. * Destroy the camera and release the current resources hold by it.
  38595. */
  38596. dispose(): void;
  38597. /**
  38598. * Gets the current object class name.
  38599. * @return the class name
  38600. */
  38601. getClassName(): string;
  38602. }
  38603. }
  38604. declare module BABYLON {
  38605. /**
  38606. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  38607. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38608. */
  38609. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  38610. /**
  38611. * Gets the name of the behavior.
  38612. */
  38613. get name(): string;
  38614. private _zoomStopsAnimation;
  38615. private _idleRotationSpeed;
  38616. private _idleRotationWaitTime;
  38617. private _idleRotationSpinupTime;
  38618. /**
  38619. * Sets the flag that indicates if user zooming should stop animation.
  38620. */
  38621. set zoomStopsAnimation(flag: boolean);
  38622. /**
  38623. * Gets the flag that indicates if user zooming should stop animation.
  38624. */
  38625. get zoomStopsAnimation(): boolean;
  38626. /**
  38627. * Sets the default speed at which the camera rotates around the model.
  38628. */
  38629. set idleRotationSpeed(speed: number);
  38630. /**
  38631. * Gets the default speed at which the camera rotates around the model.
  38632. */
  38633. get idleRotationSpeed(): number;
  38634. /**
  38635. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  38636. */
  38637. set idleRotationWaitTime(time: number);
  38638. /**
  38639. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  38640. */
  38641. get idleRotationWaitTime(): number;
  38642. /**
  38643. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  38644. */
  38645. set idleRotationSpinupTime(time: number);
  38646. /**
  38647. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  38648. */
  38649. get idleRotationSpinupTime(): number;
  38650. /**
  38651. * Gets a value indicating if the camera is currently rotating because of this behavior
  38652. */
  38653. get rotationInProgress(): boolean;
  38654. private _onPrePointerObservableObserver;
  38655. private _onAfterCheckInputsObserver;
  38656. private _attachedCamera;
  38657. private _isPointerDown;
  38658. private _lastFrameTime;
  38659. private _lastInteractionTime;
  38660. private _cameraRotationSpeed;
  38661. /**
  38662. * Initializes the behavior.
  38663. */
  38664. init(): void;
  38665. /**
  38666. * Attaches the behavior to its arc rotate camera.
  38667. * @param camera Defines the camera to attach the behavior to
  38668. */
  38669. attach(camera: ArcRotateCamera): void;
  38670. /**
  38671. * Detaches the behavior from its current arc rotate camera.
  38672. */
  38673. detach(): void;
  38674. /**
  38675. * Returns true if user is scrolling.
  38676. * @return true if user is scrolling.
  38677. */
  38678. private _userIsZooming;
  38679. private _lastFrameRadius;
  38680. private _shouldAnimationStopForInteraction;
  38681. /**
  38682. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  38683. */
  38684. private _applyUserInteraction;
  38685. private _userIsMoving;
  38686. }
  38687. }
  38688. declare module BABYLON {
  38689. /**
  38690. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  38691. */
  38692. export class AttachToBoxBehavior implements Behavior<Mesh> {
  38693. private ui;
  38694. /**
  38695. * The name of the behavior
  38696. */
  38697. name: string;
  38698. /**
  38699. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  38700. */
  38701. distanceAwayFromFace: number;
  38702. /**
  38703. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  38704. */
  38705. distanceAwayFromBottomOfFace: number;
  38706. private _faceVectors;
  38707. private _target;
  38708. private _scene;
  38709. private _onRenderObserver;
  38710. private _tmpMatrix;
  38711. private _tmpVector;
  38712. /**
  38713. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  38714. * @param ui The transform node that should be attched to the mesh
  38715. */
  38716. constructor(ui: TransformNode);
  38717. /**
  38718. * Initializes the behavior
  38719. */
  38720. init(): void;
  38721. private _closestFace;
  38722. private _zeroVector;
  38723. private _lookAtTmpMatrix;
  38724. private _lookAtToRef;
  38725. /**
  38726. * Attaches the AttachToBoxBehavior to the passed in mesh
  38727. * @param target The mesh that the specified node will be attached to
  38728. */
  38729. attach(target: Mesh): void;
  38730. /**
  38731. * Detaches the behavior from the mesh
  38732. */
  38733. detach(): void;
  38734. }
  38735. }
  38736. declare module BABYLON {
  38737. /**
  38738. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  38739. */
  38740. export class FadeInOutBehavior implements Behavior<Mesh> {
  38741. /**
  38742. * Time in milliseconds to delay before fading in (Default: 0)
  38743. */
  38744. delay: number;
  38745. /**
  38746. * Time in milliseconds for the mesh to fade in (Default: 300)
  38747. */
  38748. fadeInTime: number;
  38749. private _millisecondsPerFrame;
  38750. private _hovered;
  38751. private _hoverValue;
  38752. private _ownerNode;
  38753. /**
  38754. * Instatiates the FadeInOutBehavior
  38755. */
  38756. constructor();
  38757. /**
  38758. * The name of the behavior
  38759. */
  38760. get name(): string;
  38761. /**
  38762. * Initializes the behavior
  38763. */
  38764. init(): void;
  38765. /**
  38766. * Attaches the fade behavior on the passed in mesh
  38767. * @param ownerNode The mesh that will be faded in/out once attached
  38768. */
  38769. attach(ownerNode: Mesh): void;
  38770. /**
  38771. * Detaches the behavior from the mesh
  38772. */
  38773. detach(): void;
  38774. /**
  38775. * Triggers the mesh to begin fading in or out
  38776. * @param value if the object should fade in or out (true to fade in)
  38777. */
  38778. fadeIn(value: boolean): void;
  38779. private _update;
  38780. private _setAllVisibility;
  38781. }
  38782. }
  38783. declare module BABYLON {
  38784. /**
  38785. * Class containing a set of static utilities functions for managing Pivots
  38786. * @hidden
  38787. */
  38788. export class PivotTools {
  38789. private static _PivotCached;
  38790. private static _OldPivotPoint;
  38791. private static _PivotTranslation;
  38792. private static _PivotTmpVector;
  38793. /** @hidden */
  38794. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  38795. /** @hidden */
  38796. static _RestorePivotPoint(mesh: AbstractMesh): void;
  38797. }
  38798. }
  38799. declare module BABYLON {
  38800. /**
  38801. * Class containing static functions to help procedurally build meshes
  38802. */
  38803. export class PlaneBuilder {
  38804. /**
  38805. * Creates a plane mesh
  38806. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  38807. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  38808. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  38809. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  38810. * * 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
  38811. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  38812. * @param name defines the name of the mesh
  38813. * @param options defines the options used to create the mesh
  38814. * @param scene defines the hosting scene
  38815. * @returns the plane mesh
  38816. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  38817. */
  38818. static CreatePlane(name: string, options: {
  38819. size?: number;
  38820. width?: number;
  38821. height?: number;
  38822. sideOrientation?: number;
  38823. frontUVs?: Vector4;
  38824. backUVs?: Vector4;
  38825. updatable?: boolean;
  38826. sourcePlane?: Plane;
  38827. }, scene?: Nullable<Scene>): Mesh;
  38828. }
  38829. }
  38830. declare module BABYLON {
  38831. /**
  38832. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  38833. */
  38834. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  38835. private static _AnyMouseID;
  38836. /**
  38837. * Abstract mesh the behavior is set on
  38838. */
  38839. attachedNode: AbstractMesh;
  38840. private _dragPlane;
  38841. private _scene;
  38842. private _pointerObserver;
  38843. private _beforeRenderObserver;
  38844. private static _planeScene;
  38845. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  38846. /**
  38847. * 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)
  38848. */
  38849. maxDragAngle: number;
  38850. /**
  38851. * @hidden
  38852. */
  38853. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  38854. /**
  38855. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  38856. */
  38857. currentDraggingPointerID: number;
  38858. /**
  38859. * The last position where the pointer hit the drag plane in world space
  38860. */
  38861. lastDragPosition: Vector3;
  38862. /**
  38863. * If the behavior is currently in a dragging state
  38864. */
  38865. dragging: boolean;
  38866. /**
  38867. * 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)
  38868. */
  38869. dragDeltaRatio: number;
  38870. /**
  38871. * If the drag plane orientation should be updated during the dragging (Default: true)
  38872. */
  38873. updateDragPlane: boolean;
  38874. private _debugMode;
  38875. private _moving;
  38876. /**
  38877. * Fires each time the attached mesh is dragged with the pointer
  38878. * * delta between last drag position and current drag position in world space
  38879. * * dragDistance along the drag axis
  38880. * * dragPlaneNormal normal of the current drag plane used during the drag
  38881. * * dragPlanePoint in world space where the drag intersects the drag plane
  38882. */
  38883. onDragObservable: Observable<{
  38884. delta: Vector3;
  38885. dragPlanePoint: Vector3;
  38886. dragPlaneNormal: Vector3;
  38887. dragDistance: number;
  38888. pointerId: number;
  38889. }>;
  38890. /**
  38891. * Fires each time a drag begins (eg. mouse down on mesh)
  38892. */
  38893. onDragStartObservable: Observable<{
  38894. dragPlanePoint: Vector3;
  38895. pointerId: number;
  38896. }>;
  38897. /**
  38898. * Fires each time a drag ends (eg. mouse release after drag)
  38899. */
  38900. onDragEndObservable: Observable<{
  38901. dragPlanePoint: Vector3;
  38902. pointerId: number;
  38903. }>;
  38904. /**
  38905. * If the attached mesh should be moved when dragged
  38906. */
  38907. moveAttached: boolean;
  38908. /**
  38909. * If the drag behavior will react to drag events (Default: true)
  38910. */
  38911. enabled: boolean;
  38912. /**
  38913. * If pointer events should start and release the drag (Default: true)
  38914. */
  38915. startAndReleaseDragOnPointerEvents: boolean;
  38916. /**
  38917. * If camera controls should be detached during the drag
  38918. */
  38919. detachCameraControls: boolean;
  38920. /**
  38921. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  38922. */
  38923. useObjectOrienationForDragging: boolean;
  38924. private _options;
  38925. /**
  38926. * Gets the options used by the behavior
  38927. */
  38928. get options(): {
  38929. dragAxis?: Vector3;
  38930. dragPlaneNormal?: Vector3;
  38931. };
  38932. /**
  38933. * Sets the options used by the behavior
  38934. */
  38935. set options(options: {
  38936. dragAxis?: Vector3;
  38937. dragPlaneNormal?: Vector3;
  38938. });
  38939. /**
  38940. * Creates a pointer drag behavior that can be attached to a mesh
  38941. * @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)
  38942. */
  38943. constructor(options?: {
  38944. dragAxis?: Vector3;
  38945. dragPlaneNormal?: Vector3;
  38946. });
  38947. /**
  38948. * Predicate to determine if it is valid to move the object to a new position when it is moved
  38949. */
  38950. validateDrag: (targetPosition: Vector3) => boolean;
  38951. /**
  38952. * The name of the behavior
  38953. */
  38954. get name(): string;
  38955. /**
  38956. * Initializes the behavior
  38957. */
  38958. init(): void;
  38959. private _tmpVector;
  38960. private _alternatePickedPoint;
  38961. private _worldDragAxis;
  38962. private _targetPosition;
  38963. private _attachedElement;
  38964. /**
  38965. * Attaches the drag behavior the passed in mesh
  38966. * @param ownerNode The mesh that will be dragged around once attached
  38967. * @param predicate Predicate to use for pick filtering
  38968. */
  38969. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  38970. /**
  38971. * Force relase the drag action by code.
  38972. */
  38973. releaseDrag(): void;
  38974. private _startDragRay;
  38975. private _lastPointerRay;
  38976. /**
  38977. * Simulates the start of a pointer drag event on the behavior
  38978. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  38979. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  38980. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  38981. */
  38982. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  38983. private _startDrag;
  38984. private _dragDelta;
  38985. private _moveDrag;
  38986. private _pickWithRayOnDragPlane;
  38987. private _pointA;
  38988. private _pointB;
  38989. private _pointC;
  38990. private _lineA;
  38991. private _lineB;
  38992. private _localAxis;
  38993. private _lookAt;
  38994. private _updateDragPlanePosition;
  38995. /**
  38996. * Detaches the behavior from the mesh
  38997. */
  38998. detach(): void;
  38999. }
  39000. }
  39001. declare module BABYLON {
  39002. /**
  39003. * A behavior that when attached to a mesh will allow the mesh to be scaled
  39004. */
  39005. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  39006. private _dragBehaviorA;
  39007. private _dragBehaviorB;
  39008. private _startDistance;
  39009. private _initialScale;
  39010. private _targetScale;
  39011. private _ownerNode;
  39012. private _sceneRenderObserver;
  39013. /**
  39014. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  39015. */
  39016. constructor();
  39017. /**
  39018. * The name of the behavior
  39019. */
  39020. get name(): string;
  39021. /**
  39022. * Initializes the behavior
  39023. */
  39024. init(): void;
  39025. private _getCurrentDistance;
  39026. /**
  39027. * Attaches the scale behavior the passed in mesh
  39028. * @param ownerNode The mesh that will be scaled around once attached
  39029. */
  39030. attach(ownerNode: Mesh): void;
  39031. /**
  39032. * Detaches the behavior from the mesh
  39033. */
  39034. detach(): void;
  39035. }
  39036. }
  39037. declare module BABYLON {
  39038. /**
  39039. * 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
  39040. */
  39041. export class SixDofDragBehavior implements Behavior<Mesh> {
  39042. private static _virtualScene;
  39043. private _ownerNode;
  39044. private _sceneRenderObserver;
  39045. private _scene;
  39046. private _targetPosition;
  39047. private _virtualOriginMesh;
  39048. private _virtualDragMesh;
  39049. private _pointerObserver;
  39050. private _moving;
  39051. private _startingOrientation;
  39052. /**
  39053. * 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)
  39054. */
  39055. private zDragFactor;
  39056. /**
  39057. * If the object should rotate to face the drag origin
  39058. */
  39059. rotateDraggedObject: boolean;
  39060. /**
  39061. * If the behavior is currently in a dragging state
  39062. */
  39063. dragging: boolean;
  39064. /**
  39065. * 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)
  39066. */
  39067. dragDeltaRatio: number;
  39068. /**
  39069. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  39070. */
  39071. currentDraggingPointerID: number;
  39072. /**
  39073. * If camera controls should be detached during the drag
  39074. */
  39075. detachCameraControls: boolean;
  39076. /**
  39077. * Fires each time a drag starts
  39078. */
  39079. onDragStartObservable: Observable<{}>;
  39080. /**
  39081. * Fires each time a drag ends (eg. mouse release after drag)
  39082. */
  39083. onDragEndObservable: Observable<{}>;
  39084. /**
  39085. * 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
  39086. */
  39087. constructor();
  39088. /**
  39089. * The name of the behavior
  39090. */
  39091. get name(): string;
  39092. /**
  39093. * Initializes the behavior
  39094. */
  39095. init(): void;
  39096. /**
  39097. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  39098. */
  39099. private get _pointerCamera();
  39100. /**
  39101. * Attaches the scale behavior the passed in mesh
  39102. * @param ownerNode The mesh that will be scaled around once attached
  39103. */
  39104. attach(ownerNode: Mesh): void;
  39105. /**
  39106. * Detaches the behavior from the mesh
  39107. */
  39108. detach(): void;
  39109. }
  39110. }
  39111. declare module BABYLON {
  39112. /**
  39113. * Class used to apply inverse kinematics to bones
  39114. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  39115. */
  39116. export class BoneIKController {
  39117. private static _tmpVecs;
  39118. private static _tmpQuat;
  39119. private static _tmpMats;
  39120. /**
  39121. * Gets or sets the target mesh
  39122. */
  39123. targetMesh: AbstractMesh;
  39124. /** Gets or sets the mesh used as pole */
  39125. poleTargetMesh: AbstractMesh;
  39126. /**
  39127. * Gets or sets the bone used as pole
  39128. */
  39129. poleTargetBone: Nullable<Bone>;
  39130. /**
  39131. * Gets or sets the target position
  39132. */
  39133. targetPosition: Vector3;
  39134. /**
  39135. * Gets or sets the pole target position
  39136. */
  39137. poleTargetPosition: Vector3;
  39138. /**
  39139. * Gets or sets the pole target local offset
  39140. */
  39141. poleTargetLocalOffset: Vector3;
  39142. /**
  39143. * Gets or sets the pole angle
  39144. */
  39145. poleAngle: number;
  39146. /**
  39147. * Gets or sets the mesh associated with the controller
  39148. */
  39149. mesh: AbstractMesh;
  39150. /**
  39151. * 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)
  39152. */
  39153. slerpAmount: number;
  39154. private _bone1Quat;
  39155. private _bone1Mat;
  39156. private _bone2Ang;
  39157. private _bone1;
  39158. private _bone2;
  39159. private _bone1Length;
  39160. private _bone2Length;
  39161. private _maxAngle;
  39162. private _maxReach;
  39163. private _rightHandedSystem;
  39164. private _bendAxis;
  39165. private _slerping;
  39166. private _adjustRoll;
  39167. /**
  39168. * Gets or sets maximum allowed angle
  39169. */
  39170. get maxAngle(): number;
  39171. set maxAngle(value: number);
  39172. /**
  39173. * Creates a new BoneIKController
  39174. * @param mesh defines the mesh to control
  39175. * @param bone defines the bone to control
  39176. * @param options defines options to set up the controller
  39177. */
  39178. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  39179. targetMesh?: AbstractMesh;
  39180. poleTargetMesh?: AbstractMesh;
  39181. poleTargetBone?: Bone;
  39182. poleTargetLocalOffset?: Vector3;
  39183. poleAngle?: number;
  39184. bendAxis?: Vector3;
  39185. maxAngle?: number;
  39186. slerpAmount?: number;
  39187. });
  39188. private _setMaxAngle;
  39189. /**
  39190. * Force the controller to update the bones
  39191. */
  39192. update(): void;
  39193. }
  39194. }
  39195. declare module BABYLON {
  39196. /**
  39197. * Class used to make a bone look toward a point in space
  39198. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  39199. */
  39200. export class BoneLookController {
  39201. private static _tmpVecs;
  39202. private static _tmpQuat;
  39203. private static _tmpMats;
  39204. /**
  39205. * The target Vector3 that the bone will look at
  39206. */
  39207. target: Vector3;
  39208. /**
  39209. * The mesh that the bone is attached to
  39210. */
  39211. mesh: AbstractMesh;
  39212. /**
  39213. * The bone that will be looking to the target
  39214. */
  39215. bone: Bone;
  39216. /**
  39217. * The up axis of the coordinate system that is used when the bone is rotated
  39218. */
  39219. upAxis: Vector3;
  39220. /**
  39221. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  39222. */
  39223. upAxisSpace: Space;
  39224. /**
  39225. * Used to make an adjustment to the yaw of the bone
  39226. */
  39227. adjustYaw: number;
  39228. /**
  39229. * Used to make an adjustment to the pitch of the bone
  39230. */
  39231. adjustPitch: number;
  39232. /**
  39233. * Used to make an adjustment to the roll of the bone
  39234. */
  39235. adjustRoll: number;
  39236. /**
  39237. * 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)
  39238. */
  39239. slerpAmount: number;
  39240. private _minYaw;
  39241. private _maxYaw;
  39242. private _minPitch;
  39243. private _maxPitch;
  39244. private _minYawSin;
  39245. private _minYawCos;
  39246. private _maxYawSin;
  39247. private _maxYawCos;
  39248. private _midYawConstraint;
  39249. private _minPitchTan;
  39250. private _maxPitchTan;
  39251. private _boneQuat;
  39252. private _slerping;
  39253. private _transformYawPitch;
  39254. private _transformYawPitchInv;
  39255. private _firstFrameSkipped;
  39256. private _yawRange;
  39257. private _fowardAxis;
  39258. /**
  39259. * Gets or sets the minimum yaw angle that the bone can look to
  39260. */
  39261. get minYaw(): number;
  39262. set minYaw(value: number);
  39263. /**
  39264. * Gets or sets the maximum yaw angle that the bone can look to
  39265. */
  39266. get maxYaw(): number;
  39267. set maxYaw(value: number);
  39268. /**
  39269. * Gets or sets the minimum pitch angle that the bone can look to
  39270. */
  39271. get minPitch(): number;
  39272. set minPitch(value: number);
  39273. /**
  39274. * Gets or sets the maximum pitch angle that the bone can look to
  39275. */
  39276. get maxPitch(): number;
  39277. set maxPitch(value: number);
  39278. /**
  39279. * Create a BoneLookController
  39280. * @param mesh the mesh that the bone belongs to
  39281. * @param bone the bone that will be looking to the target
  39282. * @param target the target Vector3 to look at
  39283. * @param options optional settings:
  39284. * * maxYaw: the maximum angle the bone will yaw to
  39285. * * minYaw: the minimum angle the bone will yaw to
  39286. * * maxPitch: the maximum angle the bone will pitch to
  39287. * * minPitch: the minimum angle the bone will yaw to
  39288. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  39289. * * upAxis: the up axis of the coordinate system
  39290. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  39291. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  39292. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  39293. * * adjustYaw: used to make an adjustment to the yaw of the bone
  39294. * * adjustPitch: used to make an adjustment to the pitch of the bone
  39295. * * adjustRoll: used to make an adjustment to the roll of the bone
  39296. **/
  39297. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  39298. maxYaw?: number;
  39299. minYaw?: number;
  39300. maxPitch?: number;
  39301. minPitch?: number;
  39302. slerpAmount?: number;
  39303. upAxis?: Vector3;
  39304. upAxisSpace?: Space;
  39305. yawAxis?: Vector3;
  39306. pitchAxis?: Vector3;
  39307. adjustYaw?: number;
  39308. adjustPitch?: number;
  39309. adjustRoll?: number;
  39310. });
  39311. /**
  39312. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  39313. */
  39314. update(): void;
  39315. private _getAngleDiff;
  39316. private _getAngleBetween;
  39317. private _isAngleBetween;
  39318. }
  39319. }
  39320. declare module BABYLON {
  39321. /**
  39322. * Manage the gamepad inputs to control an arc rotate camera.
  39323. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39324. */
  39325. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  39326. /**
  39327. * Defines the camera the input is attached to.
  39328. */
  39329. camera: ArcRotateCamera;
  39330. /**
  39331. * Defines the gamepad the input is gathering event from.
  39332. */
  39333. gamepad: Nullable<Gamepad>;
  39334. /**
  39335. * Defines the gamepad rotation sensiblity.
  39336. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39337. */
  39338. gamepadRotationSensibility: number;
  39339. /**
  39340. * Defines the gamepad move sensiblity.
  39341. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39342. */
  39343. gamepadMoveSensibility: number;
  39344. private _yAxisScale;
  39345. /**
  39346. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  39347. */
  39348. get invertYAxis(): boolean;
  39349. set invertYAxis(value: boolean);
  39350. private _onGamepadConnectedObserver;
  39351. private _onGamepadDisconnectedObserver;
  39352. /**
  39353. * Attach the input controls to a specific dom element to get the input from.
  39354. * @param element Defines the element the controls should be listened from
  39355. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39356. */
  39357. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39358. /**
  39359. * Detach the current controls from the specified dom element.
  39360. * @param element Defines the element to stop listening the inputs from
  39361. */
  39362. detachControl(element: Nullable<HTMLElement>): void;
  39363. /**
  39364. * Update the current camera state depending on the inputs that have been used this frame.
  39365. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39366. */
  39367. checkInputs(): void;
  39368. /**
  39369. * Gets the class name of the current intput.
  39370. * @returns the class name
  39371. */
  39372. getClassName(): string;
  39373. /**
  39374. * Get the friendly name associated with the input class.
  39375. * @returns the input friendly name
  39376. */
  39377. getSimpleName(): string;
  39378. }
  39379. }
  39380. declare module BABYLON {
  39381. interface ArcRotateCameraInputsManager {
  39382. /**
  39383. * Add orientation input support to the input manager.
  39384. * @returns the current input manager
  39385. */
  39386. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  39387. }
  39388. /**
  39389. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  39390. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39391. */
  39392. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  39393. /**
  39394. * Defines the camera the input is attached to.
  39395. */
  39396. camera: ArcRotateCamera;
  39397. /**
  39398. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  39399. */
  39400. alphaCorrection: number;
  39401. /**
  39402. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  39403. */
  39404. gammaCorrection: number;
  39405. private _alpha;
  39406. private _gamma;
  39407. private _dirty;
  39408. private _deviceOrientationHandler;
  39409. /**
  39410. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  39411. */
  39412. constructor();
  39413. /**
  39414. * Attach the input controls to a specific dom element to get the input from.
  39415. * @param element Defines the element the controls should be listened from
  39416. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39417. */
  39418. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39419. /** @hidden */
  39420. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  39421. /**
  39422. * Update the current camera state depending on the inputs that have been used this frame.
  39423. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39424. */
  39425. checkInputs(): void;
  39426. /**
  39427. * Detach the current controls from the specified dom element.
  39428. * @param element Defines the element to stop listening the inputs from
  39429. */
  39430. detachControl(element: Nullable<HTMLElement>): void;
  39431. /**
  39432. * Gets the class name of the current intput.
  39433. * @returns the class name
  39434. */
  39435. getClassName(): string;
  39436. /**
  39437. * Get the friendly name associated with the input class.
  39438. * @returns the input friendly name
  39439. */
  39440. getSimpleName(): string;
  39441. }
  39442. }
  39443. declare module BABYLON {
  39444. /**
  39445. * Listen to mouse events to control the camera.
  39446. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39447. */
  39448. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  39449. /**
  39450. * Defines the camera the input is attached to.
  39451. */
  39452. camera: FlyCamera;
  39453. /**
  39454. * Defines if touch is enabled. (Default is true.)
  39455. */
  39456. touchEnabled: boolean;
  39457. /**
  39458. * Defines the buttons associated with the input to handle camera rotation.
  39459. */
  39460. buttons: number[];
  39461. /**
  39462. * Assign buttons for Yaw control.
  39463. */
  39464. buttonsYaw: number[];
  39465. /**
  39466. * Assign buttons for Pitch control.
  39467. */
  39468. buttonsPitch: number[];
  39469. /**
  39470. * Assign buttons for Roll control.
  39471. */
  39472. buttonsRoll: number[];
  39473. /**
  39474. * Detect if any button is being pressed while mouse is moved.
  39475. * -1 = Mouse locked.
  39476. * 0 = Left button.
  39477. * 1 = Middle Button.
  39478. * 2 = Right Button.
  39479. */
  39480. activeButton: number;
  39481. /**
  39482. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  39483. * Higher values reduce its sensitivity.
  39484. */
  39485. angularSensibility: number;
  39486. private _mousemoveCallback;
  39487. private _observer;
  39488. private _rollObserver;
  39489. private previousPosition;
  39490. private noPreventDefault;
  39491. private element;
  39492. /**
  39493. * Listen to mouse events to control the camera.
  39494. * @param touchEnabled Define if touch is enabled. (Default is true.)
  39495. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39496. */
  39497. constructor(touchEnabled?: boolean);
  39498. /**
  39499. * Attach the mouse control to the HTML DOM element.
  39500. * @param element Defines the element that listens to the input events.
  39501. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  39502. */
  39503. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39504. /**
  39505. * Detach the current controls from the specified dom element.
  39506. * @param element Defines the element to stop listening the inputs from
  39507. */
  39508. detachControl(element: Nullable<HTMLElement>): void;
  39509. /**
  39510. * Gets the class name of the current input.
  39511. * @returns the class name.
  39512. */
  39513. getClassName(): string;
  39514. /**
  39515. * Get the friendly name associated with the input class.
  39516. * @returns the input's friendly name.
  39517. */
  39518. getSimpleName(): string;
  39519. private _pointerInput;
  39520. private _onMouseMove;
  39521. /**
  39522. * Rotate camera by mouse offset.
  39523. */
  39524. private rotateCamera;
  39525. }
  39526. }
  39527. declare module BABYLON {
  39528. /**
  39529. * Default Inputs manager for the FlyCamera.
  39530. * It groups all the default supported inputs for ease of use.
  39531. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39532. */
  39533. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  39534. /**
  39535. * Instantiates a new FlyCameraInputsManager.
  39536. * @param camera Defines the camera the inputs belong to.
  39537. */
  39538. constructor(camera: FlyCamera);
  39539. /**
  39540. * Add keyboard input support to the input manager.
  39541. * @returns the new FlyCameraKeyboardMoveInput().
  39542. */
  39543. addKeyboard(): FlyCameraInputsManager;
  39544. /**
  39545. * Add mouse input support to the input manager.
  39546. * @param touchEnabled Enable touch screen support.
  39547. * @returns the new FlyCameraMouseInput().
  39548. */
  39549. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  39550. }
  39551. }
  39552. declare module BABYLON {
  39553. /**
  39554. * This is a flying camera, designed for 3D movement and rotation in all directions,
  39555. * such as in a 3D Space Shooter or a Flight Simulator.
  39556. */
  39557. export class FlyCamera extends TargetCamera {
  39558. /**
  39559. * Define the collision ellipsoid of the camera.
  39560. * This is helpful for simulating a camera body, like a player's body.
  39561. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  39562. */
  39563. ellipsoid: Vector3;
  39564. /**
  39565. * Define an offset for the position of the ellipsoid around the camera.
  39566. * This can be helpful if the camera is attached away from the player's body center,
  39567. * such as at its head.
  39568. */
  39569. ellipsoidOffset: Vector3;
  39570. /**
  39571. * Enable or disable collisions of the camera with the rest of the scene objects.
  39572. */
  39573. checkCollisions: boolean;
  39574. /**
  39575. * Enable or disable gravity on the camera.
  39576. */
  39577. applyGravity: boolean;
  39578. /**
  39579. * Define the current direction the camera is moving to.
  39580. */
  39581. cameraDirection: Vector3;
  39582. /**
  39583. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  39584. * This overrides and empties cameraRotation.
  39585. */
  39586. rotationQuaternion: Quaternion;
  39587. /**
  39588. * Track Roll to maintain the wanted Rolling when looking around.
  39589. */
  39590. _trackRoll: number;
  39591. /**
  39592. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  39593. */
  39594. rollCorrect: number;
  39595. /**
  39596. * Mimic a banked turn, Rolling the camera when Yawing.
  39597. * It's recommended to use rollCorrect = 10 for faster banking correction.
  39598. */
  39599. bankedTurn: boolean;
  39600. /**
  39601. * Limit in radians for how much Roll banking will add. (Default: 90°)
  39602. */
  39603. bankedTurnLimit: number;
  39604. /**
  39605. * Value of 0 disables the banked Roll.
  39606. * Value of 1 is equal to the Yaw angle in radians.
  39607. */
  39608. bankedTurnMultiplier: number;
  39609. /**
  39610. * The inputs manager loads all the input sources, such as keyboard and mouse.
  39611. */
  39612. inputs: FlyCameraInputsManager;
  39613. /**
  39614. * Gets the input sensibility for mouse input.
  39615. * Higher values reduce sensitivity.
  39616. */
  39617. get angularSensibility(): number;
  39618. /**
  39619. * Sets the input sensibility for a mouse input.
  39620. * Higher values reduce sensitivity.
  39621. */
  39622. set angularSensibility(value: number);
  39623. /**
  39624. * Get the keys for camera movement forward.
  39625. */
  39626. get keysForward(): number[];
  39627. /**
  39628. * Set the keys for camera movement forward.
  39629. */
  39630. set keysForward(value: number[]);
  39631. /**
  39632. * Get the keys for camera movement backward.
  39633. */
  39634. get keysBackward(): number[];
  39635. set keysBackward(value: number[]);
  39636. /**
  39637. * Get the keys for camera movement up.
  39638. */
  39639. get keysUp(): number[];
  39640. /**
  39641. * Set the keys for camera movement up.
  39642. */
  39643. set keysUp(value: number[]);
  39644. /**
  39645. * Get the keys for camera movement down.
  39646. */
  39647. get keysDown(): number[];
  39648. /**
  39649. * Set the keys for camera movement down.
  39650. */
  39651. set keysDown(value: number[]);
  39652. /**
  39653. * Get the keys for camera movement left.
  39654. */
  39655. get keysLeft(): number[];
  39656. /**
  39657. * Set the keys for camera movement left.
  39658. */
  39659. set keysLeft(value: number[]);
  39660. /**
  39661. * Set the keys for camera movement right.
  39662. */
  39663. get keysRight(): number[];
  39664. /**
  39665. * Set the keys for camera movement right.
  39666. */
  39667. set keysRight(value: number[]);
  39668. /**
  39669. * Event raised when the camera collides with a mesh in the scene.
  39670. */
  39671. onCollide: (collidedMesh: AbstractMesh) => void;
  39672. private _collider;
  39673. private _needMoveForGravity;
  39674. private _oldPosition;
  39675. private _diffPosition;
  39676. private _newPosition;
  39677. /** @hidden */
  39678. _localDirection: Vector3;
  39679. /** @hidden */
  39680. _transformedDirection: Vector3;
  39681. /**
  39682. * Instantiates a FlyCamera.
  39683. * This is a flying camera, designed for 3D movement and rotation in all directions,
  39684. * such as in a 3D Space Shooter or a Flight Simulator.
  39685. * @param name Define the name of the camera in the scene.
  39686. * @param position Define the starting position of the camera in the scene.
  39687. * @param scene Define the scene the camera belongs to.
  39688. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  39689. */
  39690. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  39691. /**
  39692. * Attach a control to the HTML DOM element.
  39693. * @param element Defines the element that listens to the input events.
  39694. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  39695. */
  39696. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39697. /**
  39698. * Detach a control from the HTML DOM element.
  39699. * The camera will stop reacting to that input.
  39700. * @param element Defines the element that listens to the input events.
  39701. */
  39702. detachControl(element: HTMLElement): void;
  39703. private _collisionMask;
  39704. /**
  39705. * Get the mask that the camera ignores in collision events.
  39706. */
  39707. get collisionMask(): number;
  39708. /**
  39709. * Set the mask that the camera ignores in collision events.
  39710. */
  39711. set collisionMask(mask: number);
  39712. /** @hidden */
  39713. _collideWithWorld(displacement: Vector3): void;
  39714. /** @hidden */
  39715. private _onCollisionPositionChange;
  39716. /** @hidden */
  39717. _checkInputs(): void;
  39718. /** @hidden */
  39719. _decideIfNeedsToMove(): boolean;
  39720. /** @hidden */
  39721. _updatePosition(): void;
  39722. /**
  39723. * Restore the Roll to its target value at the rate specified.
  39724. * @param rate - Higher means slower restoring.
  39725. * @hidden
  39726. */
  39727. restoreRoll(rate: number): void;
  39728. /**
  39729. * Destroy the camera and release the current resources held by it.
  39730. */
  39731. dispose(): void;
  39732. /**
  39733. * Get the current object class name.
  39734. * @returns the class name.
  39735. */
  39736. getClassName(): string;
  39737. }
  39738. }
  39739. declare module BABYLON {
  39740. /**
  39741. * Listen to keyboard events to control the camera.
  39742. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39743. */
  39744. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  39745. /**
  39746. * Defines the camera the input is attached to.
  39747. */
  39748. camera: FlyCamera;
  39749. /**
  39750. * The list of keyboard keys used to control the forward move of the camera.
  39751. */
  39752. keysForward: number[];
  39753. /**
  39754. * The list of keyboard keys used to control the backward move of the camera.
  39755. */
  39756. keysBackward: number[];
  39757. /**
  39758. * The list of keyboard keys used to control the forward move of the camera.
  39759. */
  39760. keysUp: number[];
  39761. /**
  39762. * The list of keyboard keys used to control the backward move of the camera.
  39763. */
  39764. keysDown: number[];
  39765. /**
  39766. * The list of keyboard keys used to control the right strafe move of the camera.
  39767. */
  39768. keysRight: number[];
  39769. /**
  39770. * The list of keyboard keys used to control the left strafe move of the camera.
  39771. */
  39772. keysLeft: number[];
  39773. private _keys;
  39774. private _onCanvasBlurObserver;
  39775. private _onKeyboardObserver;
  39776. private _engine;
  39777. private _scene;
  39778. /**
  39779. * Attach the input controls to a specific dom element to get the input from.
  39780. * @param element Defines the element the controls should be listened from
  39781. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39782. */
  39783. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39784. /**
  39785. * Detach the current controls from the specified dom element.
  39786. * @param element Defines the element to stop listening the inputs from
  39787. */
  39788. detachControl(element: Nullable<HTMLElement>): void;
  39789. /**
  39790. * Gets the class name of the current intput.
  39791. * @returns the class name
  39792. */
  39793. getClassName(): string;
  39794. /** @hidden */
  39795. _onLostFocus(e: FocusEvent): void;
  39796. /**
  39797. * Get the friendly name associated with the input class.
  39798. * @returns the input friendly name
  39799. */
  39800. getSimpleName(): string;
  39801. /**
  39802. * Update the current camera state depending on the inputs that have been used this frame.
  39803. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39804. */
  39805. checkInputs(): void;
  39806. }
  39807. }
  39808. declare module BABYLON {
  39809. /**
  39810. * Manage the mouse wheel inputs to control a follow camera.
  39811. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39812. */
  39813. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  39814. /**
  39815. * Defines the camera the input is attached to.
  39816. */
  39817. camera: FollowCamera;
  39818. /**
  39819. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  39820. */
  39821. axisControlRadius: boolean;
  39822. /**
  39823. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  39824. */
  39825. axisControlHeight: boolean;
  39826. /**
  39827. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  39828. */
  39829. axisControlRotation: boolean;
  39830. /**
  39831. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  39832. * relation to mouseWheel events.
  39833. */
  39834. wheelPrecision: number;
  39835. /**
  39836. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  39837. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  39838. */
  39839. wheelDeltaPercentage: number;
  39840. private _wheel;
  39841. private _observer;
  39842. /**
  39843. * Attach the input controls to a specific dom element to get the input from.
  39844. * @param element Defines the element the controls should be listened from
  39845. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39846. */
  39847. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39848. /**
  39849. * Detach the current controls from the specified dom element.
  39850. * @param element Defines the element to stop listening the inputs from
  39851. */
  39852. detachControl(element: Nullable<HTMLElement>): void;
  39853. /**
  39854. * Gets the class name of the current intput.
  39855. * @returns the class name
  39856. */
  39857. getClassName(): string;
  39858. /**
  39859. * Get the friendly name associated with the input class.
  39860. * @returns the input friendly name
  39861. */
  39862. getSimpleName(): string;
  39863. }
  39864. }
  39865. declare module BABYLON {
  39866. /**
  39867. * Manage the pointers inputs to control an follow camera.
  39868. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39869. */
  39870. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  39871. /**
  39872. * Defines the camera the input is attached to.
  39873. */
  39874. camera: FollowCamera;
  39875. /**
  39876. * Gets the class name of the current input.
  39877. * @returns the class name
  39878. */
  39879. getClassName(): string;
  39880. /**
  39881. * Defines the pointer angular sensibility along the X axis or how fast is
  39882. * the camera rotating.
  39883. * A negative number will reverse the axis direction.
  39884. */
  39885. angularSensibilityX: number;
  39886. /**
  39887. * Defines the pointer angular sensibility along the Y axis or how fast is
  39888. * the camera rotating.
  39889. * A negative number will reverse the axis direction.
  39890. */
  39891. angularSensibilityY: number;
  39892. /**
  39893. * Defines the pointer pinch precision or how fast is the camera zooming.
  39894. * A negative number will reverse the axis direction.
  39895. */
  39896. pinchPrecision: number;
  39897. /**
  39898. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  39899. * from 0.
  39900. * It defines the percentage of current camera.radius to use as delta when
  39901. * pinch zoom is used.
  39902. */
  39903. pinchDeltaPercentage: number;
  39904. /**
  39905. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  39906. */
  39907. axisXControlRadius: boolean;
  39908. /**
  39909. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  39910. */
  39911. axisXControlHeight: boolean;
  39912. /**
  39913. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  39914. */
  39915. axisXControlRotation: boolean;
  39916. /**
  39917. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  39918. */
  39919. axisYControlRadius: boolean;
  39920. /**
  39921. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  39922. */
  39923. axisYControlHeight: boolean;
  39924. /**
  39925. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  39926. */
  39927. axisYControlRotation: boolean;
  39928. /**
  39929. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  39930. */
  39931. axisPinchControlRadius: boolean;
  39932. /**
  39933. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  39934. */
  39935. axisPinchControlHeight: boolean;
  39936. /**
  39937. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  39938. */
  39939. axisPinchControlRotation: boolean;
  39940. /**
  39941. * Log error messages if basic misconfiguration has occurred.
  39942. */
  39943. warningEnable: boolean;
  39944. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39945. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39946. private _warningCounter;
  39947. private _warning;
  39948. }
  39949. }
  39950. declare module BABYLON {
  39951. /**
  39952. * Default Inputs manager for the FollowCamera.
  39953. * It groups all the default supported inputs for ease of use.
  39954. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39955. */
  39956. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  39957. /**
  39958. * Instantiates a new FollowCameraInputsManager.
  39959. * @param camera Defines the camera the inputs belong to
  39960. */
  39961. constructor(camera: FollowCamera);
  39962. /**
  39963. * Add keyboard input support to the input manager.
  39964. * @returns the current input manager
  39965. */
  39966. addKeyboard(): FollowCameraInputsManager;
  39967. /**
  39968. * Add mouse wheel input support to the input manager.
  39969. * @returns the current input manager
  39970. */
  39971. addMouseWheel(): FollowCameraInputsManager;
  39972. /**
  39973. * Add pointers input support to the input manager.
  39974. * @returns the current input manager
  39975. */
  39976. addPointers(): FollowCameraInputsManager;
  39977. /**
  39978. * Add orientation input support to the input manager.
  39979. * @returns the current input manager
  39980. */
  39981. addVRDeviceOrientation(): FollowCameraInputsManager;
  39982. }
  39983. }
  39984. declare module BABYLON {
  39985. /**
  39986. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  39987. * an arc rotate version arcFollowCamera are available.
  39988. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39989. */
  39990. export class FollowCamera extends TargetCamera {
  39991. /**
  39992. * Distance the follow camera should follow an object at
  39993. */
  39994. radius: number;
  39995. /**
  39996. * Minimum allowed distance of the camera to the axis of rotation
  39997. * (The camera can not get closer).
  39998. * This can help limiting how the Camera is able to move in the scene.
  39999. */
  40000. lowerRadiusLimit: Nullable<number>;
  40001. /**
  40002. * Maximum allowed distance of the camera to the axis of rotation
  40003. * (The camera can not get further).
  40004. * This can help limiting how the Camera is able to move in the scene.
  40005. */
  40006. upperRadiusLimit: Nullable<number>;
  40007. /**
  40008. * Define a rotation offset between the camera and the object it follows
  40009. */
  40010. rotationOffset: number;
  40011. /**
  40012. * Minimum allowed angle to camera position relative to target object.
  40013. * This can help limiting how the Camera is able to move in the scene.
  40014. */
  40015. lowerRotationOffsetLimit: Nullable<number>;
  40016. /**
  40017. * Maximum allowed angle to camera position relative to target object.
  40018. * This can help limiting how the Camera is able to move in the scene.
  40019. */
  40020. upperRotationOffsetLimit: Nullable<number>;
  40021. /**
  40022. * Define a height offset between the camera and the object it follows.
  40023. * It can help following an object from the top (like a car chaing a plane)
  40024. */
  40025. heightOffset: number;
  40026. /**
  40027. * Minimum allowed height of camera position relative to target object.
  40028. * This can help limiting how the Camera is able to move in the scene.
  40029. */
  40030. lowerHeightOffsetLimit: Nullable<number>;
  40031. /**
  40032. * Maximum allowed height of camera position relative to target object.
  40033. * This can help limiting how the Camera is able to move in the scene.
  40034. */
  40035. upperHeightOffsetLimit: Nullable<number>;
  40036. /**
  40037. * Define how fast the camera can accelerate to follow it s target.
  40038. */
  40039. cameraAcceleration: number;
  40040. /**
  40041. * Define the speed limit of the camera following an object.
  40042. */
  40043. maxCameraSpeed: number;
  40044. /**
  40045. * Define the target of the camera.
  40046. */
  40047. lockedTarget: Nullable<AbstractMesh>;
  40048. /**
  40049. * Defines the input associated with the camera.
  40050. */
  40051. inputs: FollowCameraInputsManager;
  40052. /**
  40053. * Instantiates the follow camera.
  40054. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40055. * @param name Define the name of the camera in the scene
  40056. * @param position Define the position of the camera
  40057. * @param scene Define the scene the camera belong to
  40058. * @param lockedTarget Define the target of the camera
  40059. */
  40060. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  40061. private _follow;
  40062. /**
  40063. * Attached controls to the current camera.
  40064. * @param element Defines the element the controls should be listened from
  40065. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40066. */
  40067. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40068. /**
  40069. * Detach the current controls from the camera.
  40070. * The camera will stop reacting to inputs.
  40071. * @param element Defines the element to stop listening the inputs from
  40072. */
  40073. detachControl(element: HTMLElement): void;
  40074. /** @hidden */
  40075. _checkInputs(): void;
  40076. private _checkLimits;
  40077. /**
  40078. * Gets the camera class name.
  40079. * @returns the class name
  40080. */
  40081. getClassName(): string;
  40082. }
  40083. /**
  40084. * Arc Rotate version of the follow camera.
  40085. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  40086. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40087. */
  40088. export class ArcFollowCamera extends TargetCamera {
  40089. /** The longitudinal angle of the camera */
  40090. alpha: number;
  40091. /** The latitudinal angle of the camera */
  40092. beta: number;
  40093. /** The radius of the camera from its target */
  40094. radius: number;
  40095. /** Define the camera target (the messh it should follow) */
  40096. target: Nullable<AbstractMesh>;
  40097. private _cartesianCoordinates;
  40098. /**
  40099. * Instantiates a new ArcFollowCamera
  40100. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40101. * @param name Define the name of the camera
  40102. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  40103. * @param beta Define the rotation angle of the camera around the elevation axis
  40104. * @param radius Define the radius of the camera from its target point
  40105. * @param target Define the target of the camera
  40106. * @param scene Define the scene the camera belongs to
  40107. */
  40108. constructor(name: string,
  40109. /** The longitudinal angle of the camera */
  40110. alpha: number,
  40111. /** The latitudinal angle of the camera */
  40112. beta: number,
  40113. /** The radius of the camera from its target */
  40114. radius: number,
  40115. /** Define the camera target (the messh it should follow) */
  40116. target: Nullable<AbstractMesh>, scene: Scene);
  40117. private _follow;
  40118. /** @hidden */
  40119. _checkInputs(): void;
  40120. /**
  40121. * Returns the class name of the object.
  40122. * It is mostly used internally for serialization purposes.
  40123. */
  40124. getClassName(): string;
  40125. }
  40126. }
  40127. declare module BABYLON {
  40128. /**
  40129. * Manage the keyboard inputs to control the movement of a follow camera.
  40130. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40131. */
  40132. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  40133. /**
  40134. * Defines the camera the input is attached to.
  40135. */
  40136. camera: FollowCamera;
  40137. /**
  40138. * Defines the list of key codes associated with the up action (increase heightOffset)
  40139. */
  40140. keysHeightOffsetIncr: number[];
  40141. /**
  40142. * Defines the list of key codes associated with the down action (decrease heightOffset)
  40143. */
  40144. keysHeightOffsetDecr: number[];
  40145. /**
  40146. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  40147. */
  40148. keysHeightOffsetModifierAlt: boolean;
  40149. /**
  40150. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  40151. */
  40152. keysHeightOffsetModifierCtrl: boolean;
  40153. /**
  40154. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  40155. */
  40156. keysHeightOffsetModifierShift: boolean;
  40157. /**
  40158. * Defines the list of key codes associated with the left action (increase rotationOffset)
  40159. */
  40160. keysRotationOffsetIncr: number[];
  40161. /**
  40162. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  40163. */
  40164. keysRotationOffsetDecr: number[];
  40165. /**
  40166. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  40167. */
  40168. keysRotationOffsetModifierAlt: boolean;
  40169. /**
  40170. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  40171. */
  40172. keysRotationOffsetModifierCtrl: boolean;
  40173. /**
  40174. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  40175. */
  40176. keysRotationOffsetModifierShift: boolean;
  40177. /**
  40178. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  40179. */
  40180. keysRadiusIncr: number[];
  40181. /**
  40182. * Defines the list of key codes associated with the zoom-out action (increase radius)
  40183. */
  40184. keysRadiusDecr: number[];
  40185. /**
  40186. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  40187. */
  40188. keysRadiusModifierAlt: boolean;
  40189. /**
  40190. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  40191. */
  40192. keysRadiusModifierCtrl: boolean;
  40193. /**
  40194. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  40195. */
  40196. keysRadiusModifierShift: boolean;
  40197. /**
  40198. * Defines the rate of change of heightOffset.
  40199. */
  40200. heightSensibility: number;
  40201. /**
  40202. * Defines the rate of change of rotationOffset.
  40203. */
  40204. rotationSensibility: number;
  40205. /**
  40206. * Defines the rate of change of radius.
  40207. */
  40208. radiusSensibility: number;
  40209. private _keys;
  40210. private _ctrlPressed;
  40211. private _altPressed;
  40212. private _shiftPressed;
  40213. private _onCanvasBlurObserver;
  40214. private _onKeyboardObserver;
  40215. private _engine;
  40216. private _scene;
  40217. /**
  40218. * Attach the input controls to a specific dom element to get the input from.
  40219. * @param element Defines the element the controls should be listened from
  40220. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40221. */
  40222. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40223. /**
  40224. * Detach the current controls from the specified dom element.
  40225. * @param element Defines the element to stop listening the inputs from
  40226. */
  40227. detachControl(element: Nullable<HTMLElement>): void;
  40228. /**
  40229. * Update the current camera state depending on the inputs that have been used this frame.
  40230. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40231. */
  40232. checkInputs(): void;
  40233. /**
  40234. * Gets the class name of the current input.
  40235. * @returns the class name
  40236. */
  40237. getClassName(): string;
  40238. /**
  40239. * Get the friendly name associated with the input class.
  40240. * @returns the input friendly name
  40241. */
  40242. getSimpleName(): string;
  40243. /**
  40244. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40245. * allow modification of the heightOffset value.
  40246. */
  40247. private _modifierHeightOffset;
  40248. /**
  40249. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40250. * allow modification of the rotationOffset value.
  40251. */
  40252. private _modifierRotationOffset;
  40253. /**
  40254. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40255. * allow modification of the radius value.
  40256. */
  40257. private _modifierRadius;
  40258. }
  40259. }
  40260. declare module BABYLON {
  40261. interface FreeCameraInputsManager {
  40262. /**
  40263. * @hidden
  40264. */
  40265. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  40266. /**
  40267. * Add orientation input support to the input manager.
  40268. * @returns the current input manager
  40269. */
  40270. addDeviceOrientation(): FreeCameraInputsManager;
  40271. }
  40272. /**
  40273. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  40274. * Screen rotation is taken into account.
  40275. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40276. */
  40277. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  40278. private _camera;
  40279. private _screenOrientationAngle;
  40280. private _constantTranform;
  40281. private _screenQuaternion;
  40282. private _alpha;
  40283. private _beta;
  40284. private _gamma;
  40285. /**
  40286. * Can be used to detect if a device orientation sensor is available on a device
  40287. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  40288. * @returns a promise that will resolve on orientation change
  40289. */
  40290. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  40291. /**
  40292. * @hidden
  40293. */
  40294. _onDeviceOrientationChangedObservable: Observable<void>;
  40295. /**
  40296. * Instantiates a new input
  40297. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40298. */
  40299. constructor();
  40300. /**
  40301. * Define the camera controlled by the input.
  40302. */
  40303. get camera(): FreeCamera;
  40304. set camera(camera: FreeCamera);
  40305. /**
  40306. * Attach the input controls to a specific dom element to get the input from.
  40307. * @param element Defines the element the controls should be listened from
  40308. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40309. */
  40310. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40311. private _orientationChanged;
  40312. private _deviceOrientation;
  40313. /**
  40314. * Detach the current controls from the specified dom element.
  40315. * @param element Defines the element to stop listening the inputs from
  40316. */
  40317. detachControl(element: Nullable<HTMLElement>): void;
  40318. /**
  40319. * Update the current camera state depending on the inputs that have been used this frame.
  40320. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40321. */
  40322. checkInputs(): void;
  40323. /**
  40324. * Gets the class name of the current intput.
  40325. * @returns the class name
  40326. */
  40327. getClassName(): string;
  40328. /**
  40329. * Get the friendly name associated with the input class.
  40330. * @returns the input friendly name
  40331. */
  40332. getSimpleName(): string;
  40333. }
  40334. }
  40335. declare module BABYLON {
  40336. /**
  40337. * Manage the gamepad inputs to control a free camera.
  40338. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40339. */
  40340. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  40341. /**
  40342. * Define the camera the input is attached to.
  40343. */
  40344. camera: FreeCamera;
  40345. /**
  40346. * Define the Gamepad controlling the input
  40347. */
  40348. gamepad: Nullable<Gamepad>;
  40349. /**
  40350. * Defines the gamepad rotation sensiblity.
  40351. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40352. */
  40353. gamepadAngularSensibility: number;
  40354. /**
  40355. * Defines the gamepad move sensiblity.
  40356. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40357. */
  40358. gamepadMoveSensibility: number;
  40359. private _yAxisScale;
  40360. /**
  40361. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  40362. */
  40363. get invertYAxis(): boolean;
  40364. set invertYAxis(value: boolean);
  40365. private _onGamepadConnectedObserver;
  40366. private _onGamepadDisconnectedObserver;
  40367. private _cameraTransform;
  40368. private _deltaTransform;
  40369. private _vector3;
  40370. private _vector2;
  40371. /**
  40372. * Attach the input controls to a specific dom element to get the input from.
  40373. * @param element Defines the element the controls should be listened from
  40374. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40375. */
  40376. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40377. /**
  40378. * Detach the current controls from the specified dom element.
  40379. * @param element Defines the element to stop listening the inputs from
  40380. */
  40381. detachControl(element: Nullable<HTMLElement>): void;
  40382. /**
  40383. * Update the current camera state depending on the inputs that have been used this frame.
  40384. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40385. */
  40386. checkInputs(): void;
  40387. /**
  40388. * Gets the class name of the current intput.
  40389. * @returns the class name
  40390. */
  40391. getClassName(): string;
  40392. /**
  40393. * Get the friendly name associated with the input class.
  40394. * @returns the input friendly name
  40395. */
  40396. getSimpleName(): string;
  40397. }
  40398. }
  40399. declare module BABYLON {
  40400. /**
  40401. * Defines the potential axis of a Joystick
  40402. */
  40403. export enum JoystickAxis {
  40404. /** X axis */
  40405. X = 0,
  40406. /** Y axis */
  40407. Y = 1,
  40408. /** Z axis */
  40409. Z = 2
  40410. }
  40411. /**
  40412. * Class used to define virtual joystick (used in touch mode)
  40413. */
  40414. export class VirtualJoystick {
  40415. /**
  40416. * Gets or sets a boolean indicating that left and right values must be inverted
  40417. */
  40418. reverseLeftRight: boolean;
  40419. /**
  40420. * Gets or sets a boolean indicating that up and down values must be inverted
  40421. */
  40422. reverseUpDown: boolean;
  40423. /**
  40424. * Gets the offset value for the position (ie. the change of the position value)
  40425. */
  40426. deltaPosition: Vector3;
  40427. /**
  40428. * Gets a boolean indicating if the virtual joystick was pressed
  40429. */
  40430. pressed: boolean;
  40431. /**
  40432. * Canvas the virtual joystick will render onto, default z-index of this is 5
  40433. */
  40434. static Canvas: Nullable<HTMLCanvasElement>;
  40435. private static _globalJoystickIndex;
  40436. private static vjCanvasContext;
  40437. private static vjCanvasWidth;
  40438. private static vjCanvasHeight;
  40439. private static halfWidth;
  40440. private _action;
  40441. private _axisTargetedByLeftAndRight;
  40442. private _axisTargetedByUpAndDown;
  40443. private _joystickSensibility;
  40444. private _inversedSensibility;
  40445. private _joystickPointerID;
  40446. private _joystickColor;
  40447. private _joystickPointerPos;
  40448. private _joystickPreviousPointerPos;
  40449. private _joystickPointerStartPos;
  40450. private _deltaJoystickVector;
  40451. private _leftJoystick;
  40452. private _touches;
  40453. private _onPointerDownHandlerRef;
  40454. private _onPointerMoveHandlerRef;
  40455. private _onPointerUpHandlerRef;
  40456. private _onResize;
  40457. /**
  40458. * Creates a new virtual joystick
  40459. * @param leftJoystick defines that the joystick is for left hand (false by default)
  40460. */
  40461. constructor(leftJoystick?: boolean);
  40462. /**
  40463. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  40464. * @param newJoystickSensibility defines the new sensibility
  40465. */
  40466. setJoystickSensibility(newJoystickSensibility: number): void;
  40467. private _onPointerDown;
  40468. private _onPointerMove;
  40469. private _onPointerUp;
  40470. /**
  40471. * Change the color of the virtual joystick
  40472. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  40473. */
  40474. setJoystickColor(newColor: string): void;
  40475. /**
  40476. * Defines a callback to call when the joystick is touched
  40477. * @param action defines the callback
  40478. */
  40479. setActionOnTouch(action: () => any): void;
  40480. /**
  40481. * Defines which axis you'd like to control for left & right
  40482. * @param axis defines the axis to use
  40483. */
  40484. setAxisForLeftRight(axis: JoystickAxis): void;
  40485. /**
  40486. * Defines which axis you'd like to control for up & down
  40487. * @param axis defines the axis to use
  40488. */
  40489. setAxisForUpDown(axis: JoystickAxis): void;
  40490. private _drawVirtualJoystick;
  40491. /**
  40492. * Release internal HTML canvas
  40493. */
  40494. releaseCanvas(): void;
  40495. }
  40496. }
  40497. declare module BABYLON {
  40498. interface FreeCameraInputsManager {
  40499. /**
  40500. * Add virtual joystick input support to the input manager.
  40501. * @returns the current input manager
  40502. */
  40503. addVirtualJoystick(): FreeCameraInputsManager;
  40504. }
  40505. /**
  40506. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  40507. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40508. */
  40509. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  40510. /**
  40511. * Defines the camera the input is attached to.
  40512. */
  40513. camera: FreeCamera;
  40514. private _leftjoystick;
  40515. private _rightjoystick;
  40516. /**
  40517. * Gets the left stick of the virtual joystick.
  40518. * @returns The virtual Joystick
  40519. */
  40520. getLeftJoystick(): VirtualJoystick;
  40521. /**
  40522. * Gets the right stick of the virtual joystick.
  40523. * @returns The virtual Joystick
  40524. */
  40525. getRightJoystick(): VirtualJoystick;
  40526. /**
  40527. * Update the current camera state depending on the inputs that have been used this frame.
  40528. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40529. */
  40530. checkInputs(): void;
  40531. /**
  40532. * Attach the input controls to a specific dom element to get the input from.
  40533. * @param element Defines the element the controls should be listened from
  40534. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40535. */
  40536. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40537. /**
  40538. * Detach the current controls from the specified dom element.
  40539. * @param element Defines the element to stop listening the inputs from
  40540. */
  40541. detachControl(element: Nullable<HTMLElement>): void;
  40542. /**
  40543. * Gets the class name of the current intput.
  40544. * @returns the class name
  40545. */
  40546. getClassName(): string;
  40547. /**
  40548. * Get the friendly name associated with the input class.
  40549. * @returns the input friendly name
  40550. */
  40551. getSimpleName(): string;
  40552. }
  40553. }
  40554. declare module BABYLON {
  40555. /**
  40556. * This represents a FPS type of camera controlled by touch.
  40557. * This is like a universal camera minus the Gamepad controls.
  40558. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40559. */
  40560. export class TouchCamera extends FreeCamera {
  40561. /**
  40562. * Defines the touch sensibility for rotation.
  40563. * The higher the faster.
  40564. */
  40565. get touchAngularSensibility(): number;
  40566. set touchAngularSensibility(value: number);
  40567. /**
  40568. * Defines the touch sensibility for move.
  40569. * The higher the faster.
  40570. */
  40571. get touchMoveSensibility(): number;
  40572. set touchMoveSensibility(value: number);
  40573. /**
  40574. * Instantiates a new touch camera.
  40575. * This represents a FPS type of camera controlled by touch.
  40576. * This is like a universal camera minus the Gamepad controls.
  40577. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40578. * @param name Define the name of the camera in the scene
  40579. * @param position Define the start position of the camera in the scene
  40580. * @param scene Define the scene the camera belongs to
  40581. */
  40582. constructor(name: string, position: Vector3, scene: Scene);
  40583. /**
  40584. * Gets the current object class name.
  40585. * @return the class name
  40586. */
  40587. getClassName(): string;
  40588. /** @hidden */
  40589. _setupInputs(): void;
  40590. }
  40591. }
  40592. declare module BABYLON {
  40593. /**
  40594. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  40595. * being tilted forward or back and left or right.
  40596. */
  40597. export class DeviceOrientationCamera extends FreeCamera {
  40598. private _initialQuaternion;
  40599. private _quaternionCache;
  40600. private _tmpDragQuaternion;
  40601. private _disablePointerInputWhenUsingDeviceOrientation;
  40602. /**
  40603. * Creates a new device orientation camera
  40604. * @param name The name of the camera
  40605. * @param position The start position camera
  40606. * @param scene The scene the camera belongs to
  40607. */
  40608. constructor(name: string, position: Vector3, scene: Scene);
  40609. /**
  40610. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  40611. */
  40612. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  40613. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  40614. private _dragFactor;
  40615. /**
  40616. * Enabled turning on the y axis when the orientation sensor is active
  40617. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  40618. */
  40619. enableHorizontalDragging(dragFactor?: number): void;
  40620. /**
  40621. * Gets the current instance class name ("DeviceOrientationCamera").
  40622. * This helps avoiding instanceof at run time.
  40623. * @returns the class name
  40624. */
  40625. getClassName(): string;
  40626. /**
  40627. * @hidden
  40628. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  40629. */
  40630. _checkInputs(): void;
  40631. /**
  40632. * Reset the camera to its default orientation on the specified axis only.
  40633. * @param axis The axis to reset
  40634. */
  40635. resetToCurrentRotation(axis?: Axis): void;
  40636. }
  40637. }
  40638. declare module BABYLON {
  40639. /**
  40640. * Defines supported buttons for XBox360 compatible gamepads
  40641. */
  40642. export enum Xbox360Button {
  40643. /** A */
  40644. A = 0,
  40645. /** B */
  40646. B = 1,
  40647. /** X */
  40648. X = 2,
  40649. /** Y */
  40650. Y = 3,
  40651. /** Start */
  40652. Start = 4,
  40653. /** Back */
  40654. Back = 5,
  40655. /** Left button */
  40656. LB = 6,
  40657. /** Right button */
  40658. RB = 7,
  40659. /** Left stick */
  40660. LeftStick = 8,
  40661. /** Right stick */
  40662. RightStick = 9
  40663. }
  40664. /** Defines values for XBox360 DPad */
  40665. export enum Xbox360Dpad {
  40666. /** Up */
  40667. Up = 0,
  40668. /** Down */
  40669. Down = 1,
  40670. /** Left */
  40671. Left = 2,
  40672. /** Right */
  40673. Right = 3
  40674. }
  40675. /**
  40676. * Defines a XBox360 gamepad
  40677. */
  40678. export class Xbox360Pad extends Gamepad {
  40679. private _leftTrigger;
  40680. private _rightTrigger;
  40681. private _onlefttriggerchanged;
  40682. private _onrighttriggerchanged;
  40683. private _onbuttondown;
  40684. private _onbuttonup;
  40685. private _ondpaddown;
  40686. private _ondpadup;
  40687. /** Observable raised when a button is pressed */
  40688. onButtonDownObservable: Observable<Xbox360Button>;
  40689. /** Observable raised when a button is released */
  40690. onButtonUpObservable: Observable<Xbox360Button>;
  40691. /** Observable raised when a pad is pressed */
  40692. onPadDownObservable: Observable<Xbox360Dpad>;
  40693. /** Observable raised when a pad is released */
  40694. onPadUpObservable: Observable<Xbox360Dpad>;
  40695. private _buttonA;
  40696. private _buttonB;
  40697. private _buttonX;
  40698. private _buttonY;
  40699. private _buttonBack;
  40700. private _buttonStart;
  40701. private _buttonLB;
  40702. private _buttonRB;
  40703. private _buttonLeftStick;
  40704. private _buttonRightStick;
  40705. private _dPadUp;
  40706. private _dPadDown;
  40707. private _dPadLeft;
  40708. private _dPadRight;
  40709. private _isXboxOnePad;
  40710. /**
  40711. * Creates a new XBox360 gamepad object
  40712. * @param id defines the id of this gamepad
  40713. * @param index defines its index
  40714. * @param gamepad defines the internal HTML gamepad object
  40715. * @param xboxOne defines if it is a XBox One gamepad
  40716. */
  40717. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  40718. /**
  40719. * Defines the callback to call when left trigger is pressed
  40720. * @param callback defines the callback to use
  40721. */
  40722. onlefttriggerchanged(callback: (value: number) => void): void;
  40723. /**
  40724. * Defines the callback to call when right trigger is pressed
  40725. * @param callback defines the callback to use
  40726. */
  40727. onrighttriggerchanged(callback: (value: number) => void): void;
  40728. /**
  40729. * Gets the left trigger value
  40730. */
  40731. get leftTrigger(): number;
  40732. /**
  40733. * Sets the left trigger value
  40734. */
  40735. set leftTrigger(newValue: number);
  40736. /**
  40737. * Gets the right trigger value
  40738. */
  40739. get rightTrigger(): number;
  40740. /**
  40741. * Sets the right trigger value
  40742. */
  40743. set rightTrigger(newValue: number);
  40744. /**
  40745. * Defines the callback to call when a button is pressed
  40746. * @param callback defines the callback to use
  40747. */
  40748. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  40749. /**
  40750. * Defines the callback to call when a button is released
  40751. * @param callback defines the callback to use
  40752. */
  40753. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  40754. /**
  40755. * Defines the callback to call when a pad is pressed
  40756. * @param callback defines the callback to use
  40757. */
  40758. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  40759. /**
  40760. * Defines the callback to call when a pad is released
  40761. * @param callback defines the callback to use
  40762. */
  40763. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  40764. private _setButtonValue;
  40765. private _setDPadValue;
  40766. /**
  40767. * Gets the value of the `A` button
  40768. */
  40769. get buttonA(): number;
  40770. /**
  40771. * Sets the value of the `A` button
  40772. */
  40773. set buttonA(value: number);
  40774. /**
  40775. * Gets the value of the `B` button
  40776. */
  40777. get buttonB(): number;
  40778. /**
  40779. * Sets the value of the `B` button
  40780. */
  40781. set buttonB(value: number);
  40782. /**
  40783. * Gets the value of the `X` button
  40784. */
  40785. get buttonX(): number;
  40786. /**
  40787. * Sets the value of the `X` button
  40788. */
  40789. set buttonX(value: number);
  40790. /**
  40791. * Gets the value of the `Y` button
  40792. */
  40793. get buttonY(): number;
  40794. /**
  40795. * Sets the value of the `Y` button
  40796. */
  40797. set buttonY(value: number);
  40798. /**
  40799. * Gets the value of the `Start` button
  40800. */
  40801. get buttonStart(): number;
  40802. /**
  40803. * Sets the value of the `Start` button
  40804. */
  40805. set buttonStart(value: number);
  40806. /**
  40807. * Gets the value of the `Back` button
  40808. */
  40809. get buttonBack(): number;
  40810. /**
  40811. * Sets the value of the `Back` button
  40812. */
  40813. set buttonBack(value: number);
  40814. /**
  40815. * Gets the value of the `Left` button
  40816. */
  40817. get buttonLB(): number;
  40818. /**
  40819. * Sets the value of the `Left` button
  40820. */
  40821. set buttonLB(value: number);
  40822. /**
  40823. * Gets the value of the `Right` button
  40824. */
  40825. get buttonRB(): number;
  40826. /**
  40827. * Sets the value of the `Right` button
  40828. */
  40829. set buttonRB(value: number);
  40830. /**
  40831. * Gets the value of the Left joystick
  40832. */
  40833. get buttonLeftStick(): number;
  40834. /**
  40835. * Sets the value of the Left joystick
  40836. */
  40837. set buttonLeftStick(value: number);
  40838. /**
  40839. * Gets the value of the Right joystick
  40840. */
  40841. get buttonRightStick(): number;
  40842. /**
  40843. * Sets the value of the Right joystick
  40844. */
  40845. set buttonRightStick(value: number);
  40846. /**
  40847. * Gets the value of D-pad up
  40848. */
  40849. get dPadUp(): number;
  40850. /**
  40851. * Sets the value of D-pad up
  40852. */
  40853. set dPadUp(value: number);
  40854. /**
  40855. * Gets the value of D-pad down
  40856. */
  40857. get dPadDown(): number;
  40858. /**
  40859. * Sets the value of D-pad down
  40860. */
  40861. set dPadDown(value: number);
  40862. /**
  40863. * Gets the value of D-pad left
  40864. */
  40865. get dPadLeft(): number;
  40866. /**
  40867. * Sets the value of D-pad left
  40868. */
  40869. set dPadLeft(value: number);
  40870. /**
  40871. * Gets the value of D-pad right
  40872. */
  40873. get dPadRight(): number;
  40874. /**
  40875. * Sets the value of D-pad right
  40876. */
  40877. set dPadRight(value: number);
  40878. /**
  40879. * Force the gamepad to synchronize with device values
  40880. */
  40881. update(): void;
  40882. /**
  40883. * Disposes the gamepad
  40884. */
  40885. dispose(): void;
  40886. }
  40887. }
  40888. declare module BABYLON {
  40889. /**
  40890. * Defines supported buttons for DualShock compatible gamepads
  40891. */
  40892. export enum DualShockButton {
  40893. /** Cross */
  40894. Cross = 0,
  40895. /** Circle */
  40896. Circle = 1,
  40897. /** Square */
  40898. Square = 2,
  40899. /** Triangle */
  40900. Triangle = 3,
  40901. /** Options */
  40902. Options = 4,
  40903. /** Share */
  40904. Share = 5,
  40905. /** L1 */
  40906. L1 = 6,
  40907. /** R1 */
  40908. R1 = 7,
  40909. /** Left stick */
  40910. LeftStick = 8,
  40911. /** Right stick */
  40912. RightStick = 9
  40913. }
  40914. /** Defines values for DualShock DPad */
  40915. export enum DualShockDpad {
  40916. /** Up */
  40917. Up = 0,
  40918. /** Down */
  40919. Down = 1,
  40920. /** Left */
  40921. Left = 2,
  40922. /** Right */
  40923. Right = 3
  40924. }
  40925. /**
  40926. * Defines a DualShock gamepad
  40927. */
  40928. export class DualShockPad extends Gamepad {
  40929. private _leftTrigger;
  40930. private _rightTrigger;
  40931. private _onlefttriggerchanged;
  40932. private _onrighttriggerchanged;
  40933. private _onbuttondown;
  40934. private _onbuttonup;
  40935. private _ondpaddown;
  40936. private _ondpadup;
  40937. /** Observable raised when a button is pressed */
  40938. onButtonDownObservable: Observable<DualShockButton>;
  40939. /** Observable raised when a button is released */
  40940. onButtonUpObservable: Observable<DualShockButton>;
  40941. /** Observable raised when a pad is pressed */
  40942. onPadDownObservable: Observable<DualShockDpad>;
  40943. /** Observable raised when a pad is released */
  40944. onPadUpObservable: Observable<DualShockDpad>;
  40945. private _buttonCross;
  40946. private _buttonCircle;
  40947. private _buttonSquare;
  40948. private _buttonTriangle;
  40949. private _buttonShare;
  40950. private _buttonOptions;
  40951. private _buttonL1;
  40952. private _buttonR1;
  40953. private _buttonLeftStick;
  40954. private _buttonRightStick;
  40955. private _dPadUp;
  40956. private _dPadDown;
  40957. private _dPadLeft;
  40958. private _dPadRight;
  40959. /**
  40960. * Creates a new DualShock gamepad object
  40961. * @param id defines the id of this gamepad
  40962. * @param index defines its index
  40963. * @param gamepad defines the internal HTML gamepad object
  40964. */
  40965. constructor(id: string, index: number, gamepad: any);
  40966. /**
  40967. * Defines the callback to call when left trigger is pressed
  40968. * @param callback defines the callback to use
  40969. */
  40970. onlefttriggerchanged(callback: (value: number) => void): void;
  40971. /**
  40972. * Defines the callback to call when right trigger is pressed
  40973. * @param callback defines the callback to use
  40974. */
  40975. onrighttriggerchanged(callback: (value: number) => void): void;
  40976. /**
  40977. * Gets the left trigger value
  40978. */
  40979. get leftTrigger(): number;
  40980. /**
  40981. * Sets the left trigger value
  40982. */
  40983. set leftTrigger(newValue: number);
  40984. /**
  40985. * Gets the right trigger value
  40986. */
  40987. get rightTrigger(): number;
  40988. /**
  40989. * Sets the right trigger value
  40990. */
  40991. set rightTrigger(newValue: number);
  40992. /**
  40993. * Defines the callback to call when a button is pressed
  40994. * @param callback defines the callback to use
  40995. */
  40996. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  40997. /**
  40998. * Defines the callback to call when a button is released
  40999. * @param callback defines the callback to use
  41000. */
  41001. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  41002. /**
  41003. * Defines the callback to call when a pad is pressed
  41004. * @param callback defines the callback to use
  41005. */
  41006. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  41007. /**
  41008. * Defines the callback to call when a pad is released
  41009. * @param callback defines the callback to use
  41010. */
  41011. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  41012. private _setButtonValue;
  41013. private _setDPadValue;
  41014. /**
  41015. * Gets the value of the `Cross` button
  41016. */
  41017. get buttonCross(): number;
  41018. /**
  41019. * Sets the value of the `Cross` button
  41020. */
  41021. set buttonCross(value: number);
  41022. /**
  41023. * Gets the value of the `Circle` button
  41024. */
  41025. get buttonCircle(): number;
  41026. /**
  41027. * Sets the value of the `Circle` button
  41028. */
  41029. set buttonCircle(value: number);
  41030. /**
  41031. * Gets the value of the `Square` button
  41032. */
  41033. get buttonSquare(): number;
  41034. /**
  41035. * Sets the value of the `Square` button
  41036. */
  41037. set buttonSquare(value: number);
  41038. /**
  41039. * Gets the value of the `Triangle` button
  41040. */
  41041. get buttonTriangle(): number;
  41042. /**
  41043. * Sets the value of the `Triangle` button
  41044. */
  41045. set buttonTriangle(value: number);
  41046. /**
  41047. * Gets the value of the `Options` button
  41048. */
  41049. get buttonOptions(): number;
  41050. /**
  41051. * Sets the value of the `Options` button
  41052. */
  41053. set buttonOptions(value: number);
  41054. /**
  41055. * Gets the value of the `Share` button
  41056. */
  41057. get buttonShare(): number;
  41058. /**
  41059. * Sets the value of the `Share` button
  41060. */
  41061. set buttonShare(value: number);
  41062. /**
  41063. * Gets the value of the `L1` button
  41064. */
  41065. get buttonL1(): number;
  41066. /**
  41067. * Sets the value of the `L1` button
  41068. */
  41069. set buttonL1(value: number);
  41070. /**
  41071. * Gets the value of the `R1` button
  41072. */
  41073. get buttonR1(): number;
  41074. /**
  41075. * Sets the value of the `R1` button
  41076. */
  41077. set buttonR1(value: number);
  41078. /**
  41079. * Gets the value of the Left joystick
  41080. */
  41081. get buttonLeftStick(): number;
  41082. /**
  41083. * Sets the value of the Left joystick
  41084. */
  41085. set buttonLeftStick(value: number);
  41086. /**
  41087. * Gets the value of the Right joystick
  41088. */
  41089. get buttonRightStick(): number;
  41090. /**
  41091. * Sets the value of the Right joystick
  41092. */
  41093. set buttonRightStick(value: number);
  41094. /**
  41095. * Gets the value of D-pad up
  41096. */
  41097. get dPadUp(): number;
  41098. /**
  41099. * Sets the value of D-pad up
  41100. */
  41101. set dPadUp(value: number);
  41102. /**
  41103. * Gets the value of D-pad down
  41104. */
  41105. get dPadDown(): number;
  41106. /**
  41107. * Sets the value of D-pad down
  41108. */
  41109. set dPadDown(value: number);
  41110. /**
  41111. * Gets the value of D-pad left
  41112. */
  41113. get dPadLeft(): number;
  41114. /**
  41115. * Sets the value of D-pad left
  41116. */
  41117. set dPadLeft(value: number);
  41118. /**
  41119. * Gets the value of D-pad right
  41120. */
  41121. get dPadRight(): number;
  41122. /**
  41123. * Sets the value of D-pad right
  41124. */
  41125. set dPadRight(value: number);
  41126. /**
  41127. * Force the gamepad to synchronize with device values
  41128. */
  41129. update(): void;
  41130. /**
  41131. * Disposes the gamepad
  41132. */
  41133. dispose(): void;
  41134. }
  41135. }
  41136. declare module BABYLON {
  41137. /**
  41138. * Manager for handling gamepads
  41139. */
  41140. export class GamepadManager {
  41141. private _scene?;
  41142. private _babylonGamepads;
  41143. private _oneGamepadConnected;
  41144. /** @hidden */
  41145. _isMonitoring: boolean;
  41146. private _gamepadEventSupported;
  41147. private _gamepadSupport?;
  41148. /**
  41149. * observable to be triggered when the gamepad controller has been connected
  41150. */
  41151. onGamepadConnectedObservable: Observable<Gamepad>;
  41152. /**
  41153. * observable to be triggered when the gamepad controller has been disconnected
  41154. */
  41155. onGamepadDisconnectedObservable: Observable<Gamepad>;
  41156. private _onGamepadConnectedEvent;
  41157. private _onGamepadDisconnectedEvent;
  41158. /**
  41159. * Initializes the gamepad manager
  41160. * @param _scene BabylonJS scene
  41161. */
  41162. constructor(_scene?: Scene | undefined);
  41163. /**
  41164. * The gamepads in the game pad manager
  41165. */
  41166. get gamepads(): Gamepad[];
  41167. /**
  41168. * Get the gamepad controllers based on type
  41169. * @param type The type of gamepad controller
  41170. * @returns Nullable gamepad
  41171. */
  41172. getGamepadByType(type?: number): Nullable<Gamepad>;
  41173. /**
  41174. * Disposes the gamepad manager
  41175. */
  41176. dispose(): void;
  41177. private _addNewGamepad;
  41178. private _startMonitoringGamepads;
  41179. private _stopMonitoringGamepads;
  41180. /** @hidden */
  41181. _checkGamepadsStatus(): void;
  41182. private _updateGamepadObjects;
  41183. }
  41184. }
  41185. declare module BABYLON {
  41186. interface Scene {
  41187. /** @hidden */
  41188. _gamepadManager: Nullable<GamepadManager>;
  41189. /**
  41190. * Gets the gamepad manager associated with the scene
  41191. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  41192. */
  41193. gamepadManager: GamepadManager;
  41194. }
  41195. /**
  41196. * Interface representing a free camera inputs manager
  41197. */
  41198. interface FreeCameraInputsManager {
  41199. /**
  41200. * Adds gamepad input support to the FreeCameraInputsManager.
  41201. * @returns the FreeCameraInputsManager
  41202. */
  41203. addGamepad(): FreeCameraInputsManager;
  41204. }
  41205. /**
  41206. * Interface representing an arc rotate camera inputs manager
  41207. */
  41208. interface ArcRotateCameraInputsManager {
  41209. /**
  41210. * Adds gamepad input support to the ArcRotateCamera InputManager.
  41211. * @returns the camera inputs manager
  41212. */
  41213. addGamepad(): ArcRotateCameraInputsManager;
  41214. }
  41215. /**
  41216. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  41217. */
  41218. export class GamepadSystemSceneComponent implements ISceneComponent {
  41219. /**
  41220. * The component name helpfull to identify the component in the list of scene components.
  41221. */
  41222. readonly name: string;
  41223. /**
  41224. * The scene the component belongs to.
  41225. */
  41226. scene: Scene;
  41227. /**
  41228. * Creates a new instance of the component for the given scene
  41229. * @param scene Defines the scene to register the component in
  41230. */
  41231. constructor(scene: Scene);
  41232. /**
  41233. * Registers the component in a given scene
  41234. */
  41235. register(): void;
  41236. /**
  41237. * Rebuilds the elements related to this component in case of
  41238. * context lost for instance.
  41239. */
  41240. rebuild(): void;
  41241. /**
  41242. * Disposes the component and the associated ressources
  41243. */
  41244. dispose(): void;
  41245. private _beforeCameraUpdate;
  41246. }
  41247. }
  41248. declare module BABYLON {
  41249. /**
  41250. * 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,
  41251. * which still works and will still be found in many Playgrounds.
  41252. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41253. */
  41254. export class UniversalCamera extends TouchCamera {
  41255. /**
  41256. * Defines the gamepad rotation sensiblity.
  41257. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41258. */
  41259. get gamepadAngularSensibility(): number;
  41260. set gamepadAngularSensibility(value: number);
  41261. /**
  41262. * Defines the gamepad move sensiblity.
  41263. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41264. */
  41265. get gamepadMoveSensibility(): number;
  41266. set gamepadMoveSensibility(value: number);
  41267. /**
  41268. * 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,
  41269. * which still works and will still be found in many Playgrounds.
  41270. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41271. * @param name Define the name of the camera in the scene
  41272. * @param position Define the start position of the camera in the scene
  41273. * @param scene Define the scene the camera belongs to
  41274. */
  41275. constructor(name: string, position: Vector3, scene: Scene);
  41276. /**
  41277. * Gets the current object class name.
  41278. * @return the class name
  41279. */
  41280. getClassName(): string;
  41281. }
  41282. }
  41283. declare module BABYLON {
  41284. /**
  41285. * This represents a FPS type of camera. This is only here for back compat purpose.
  41286. * Please use the UniversalCamera instead as both are identical.
  41287. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41288. */
  41289. export class GamepadCamera extends UniversalCamera {
  41290. /**
  41291. * Instantiates a new Gamepad Camera
  41292. * This represents a FPS type of camera. This is only here for back compat purpose.
  41293. * Please use the UniversalCamera instead as both are identical.
  41294. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41295. * @param name Define the name of the camera in the scene
  41296. * @param position Define the start position of the camera in the scene
  41297. * @param scene Define the scene the camera belongs to
  41298. */
  41299. constructor(name: string, position: Vector3, scene: Scene);
  41300. /**
  41301. * Gets the current object class name.
  41302. * @return the class name
  41303. */
  41304. getClassName(): string;
  41305. }
  41306. }
  41307. declare module BABYLON {
  41308. /** @hidden */
  41309. export var passPixelShader: {
  41310. name: string;
  41311. shader: string;
  41312. };
  41313. }
  41314. declare module BABYLON {
  41315. /** @hidden */
  41316. export var passCubePixelShader: {
  41317. name: string;
  41318. shader: string;
  41319. };
  41320. }
  41321. declare module BABYLON {
  41322. /**
  41323. * PassPostProcess which produces an output the same as it's input
  41324. */
  41325. export class PassPostProcess extends PostProcess {
  41326. /**
  41327. * Creates the PassPostProcess
  41328. * @param name The name of the effect.
  41329. * @param options The required width/height ratio to downsize to before computing the render pass.
  41330. * @param camera The camera to apply the render pass to.
  41331. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41332. * @param engine The engine which the post process will be applied. (default: current engine)
  41333. * @param reusable If the post process can be reused on the same frame. (default: false)
  41334. * @param textureType The type of texture to be used when performing the post processing.
  41335. * @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)
  41336. */
  41337. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  41338. }
  41339. /**
  41340. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  41341. */
  41342. export class PassCubePostProcess extends PostProcess {
  41343. private _face;
  41344. /**
  41345. * Gets or sets the cube face to display.
  41346. * * 0 is +X
  41347. * * 1 is -X
  41348. * * 2 is +Y
  41349. * * 3 is -Y
  41350. * * 4 is +Z
  41351. * * 5 is -Z
  41352. */
  41353. get face(): number;
  41354. set face(value: number);
  41355. /**
  41356. * Creates the PassCubePostProcess
  41357. * @param name The name of the effect.
  41358. * @param options The required width/height ratio to downsize to before computing the render pass.
  41359. * @param camera The camera to apply the render pass to.
  41360. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41361. * @param engine The engine which the post process will be applied. (default: current engine)
  41362. * @param reusable If the post process can be reused on the same frame. (default: false)
  41363. * @param textureType The type of texture to be used when performing the post processing.
  41364. * @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)
  41365. */
  41366. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  41367. }
  41368. }
  41369. declare module BABYLON {
  41370. /** @hidden */
  41371. export var anaglyphPixelShader: {
  41372. name: string;
  41373. shader: string;
  41374. };
  41375. }
  41376. declare module BABYLON {
  41377. /**
  41378. * Postprocess used to generate anaglyphic rendering
  41379. */
  41380. export class AnaglyphPostProcess extends PostProcess {
  41381. private _passedProcess;
  41382. /**
  41383. * Creates a new AnaglyphPostProcess
  41384. * @param name defines postprocess name
  41385. * @param options defines creation options or target ratio scale
  41386. * @param rigCameras defines cameras using this postprocess
  41387. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  41388. * @param engine defines hosting engine
  41389. * @param reusable defines if the postprocess will be reused multiple times per frame
  41390. */
  41391. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  41392. }
  41393. }
  41394. declare module BABYLON {
  41395. /**
  41396. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  41397. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41398. */
  41399. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  41400. /**
  41401. * Creates a new AnaglyphArcRotateCamera
  41402. * @param name defines camera name
  41403. * @param alpha defines alpha angle (in radians)
  41404. * @param beta defines beta angle (in radians)
  41405. * @param radius defines radius
  41406. * @param target defines camera target
  41407. * @param interaxialDistance defines distance between each color axis
  41408. * @param scene defines the hosting scene
  41409. */
  41410. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  41411. /**
  41412. * Gets camera class name
  41413. * @returns AnaglyphArcRotateCamera
  41414. */
  41415. getClassName(): string;
  41416. }
  41417. }
  41418. declare module BABYLON {
  41419. /**
  41420. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  41421. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41422. */
  41423. export class AnaglyphFreeCamera extends FreeCamera {
  41424. /**
  41425. * Creates a new AnaglyphFreeCamera
  41426. * @param name defines camera name
  41427. * @param position defines initial position
  41428. * @param interaxialDistance defines distance between each color axis
  41429. * @param scene defines the hosting scene
  41430. */
  41431. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41432. /**
  41433. * Gets camera class name
  41434. * @returns AnaglyphFreeCamera
  41435. */
  41436. getClassName(): string;
  41437. }
  41438. }
  41439. declare module BABYLON {
  41440. /**
  41441. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  41442. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41443. */
  41444. export class AnaglyphGamepadCamera extends GamepadCamera {
  41445. /**
  41446. * Creates a new AnaglyphGamepadCamera
  41447. * @param name defines camera name
  41448. * @param position defines initial position
  41449. * @param interaxialDistance defines distance between each color axis
  41450. * @param scene defines the hosting scene
  41451. */
  41452. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41453. /**
  41454. * Gets camera class name
  41455. * @returns AnaglyphGamepadCamera
  41456. */
  41457. getClassName(): string;
  41458. }
  41459. }
  41460. declare module BABYLON {
  41461. /**
  41462. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  41463. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41464. */
  41465. export class AnaglyphUniversalCamera extends UniversalCamera {
  41466. /**
  41467. * Creates a new AnaglyphUniversalCamera
  41468. * @param name defines camera name
  41469. * @param position defines initial position
  41470. * @param interaxialDistance defines distance between each color axis
  41471. * @param scene defines the hosting scene
  41472. */
  41473. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41474. /**
  41475. * Gets camera class name
  41476. * @returns AnaglyphUniversalCamera
  41477. */
  41478. getClassName(): string;
  41479. }
  41480. }
  41481. declare module BABYLON {
  41482. /** @hidden */
  41483. export var stereoscopicInterlacePixelShader: {
  41484. name: string;
  41485. shader: string;
  41486. };
  41487. }
  41488. declare module BABYLON {
  41489. /**
  41490. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  41491. */
  41492. export class StereoscopicInterlacePostProcess extends PostProcess {
  41493. private _stepSize;
  41494. private _passedProcess;
  41495. /**
  41496. * Initializes a StereoscopicInterlacePostProcess
  41497. * @param name The name of the effect.
  41498. * @param rigCameras The rig cameras to be appled to the post process
  41499. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  41500. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41501. * @param engine The engine which the post process will be applied. (default: current engine)
  41502. * @param reusable If the post process can be reused on the same frame. (default: false)
  41503. */
  41504. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  41505. }
  41506. }
  41507. declare module BABYLON {
  41508. /**
  41509. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  41510. * @see http://doc.babylonjs.com/features/cameras
  41511. */
  41512. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  41513. /**
  41514. * Creates a new StereoscopicArcRotateCamera
  41515. * @param name defines camera name
  41516. * @param alpha defines alpha angle (in radians)
  41517. * @param beta defines beta angle (in radians)
  41518. * @param radius defines radius
  41519. * @param target defines camera target
  41520. * @param interaxialDistance defines distance between each color axis
  41521. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41522. * @param scene defines the hosting scene
  41523. */
  41524. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41525. /**
  41526. * Gets camera class name
  41527. * @returns StereoscopicArcRotateCamera
  41528. */
  41529. getClassName(): string;
  41530. }
  41531. }
  41532. declare module BABYLON {
  41533. /**
  41534. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  41535. * @see http://doc.babylonjs.com/features/cameras
  41536. */
  41537. export class StereoscopicFreeCamera extends FreeCamera {
  41538. /**
  41539. * Creates a new StereoscopicFreeCamera
  41540. * @param name defines camera name
  41541. * @param position defines initial position
  41542. * @param interaxialDistance defines distance between each color axis
  41543. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41544. * @param scene defines the hosting scene
  41545. */
  41546. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41547. /**
  41548. * Gets camera class name
  41549. * @returns StereoscopicFreeCamera
  41550. */
  41551. getClassName(): string;
  41552. }
  41553. }
  41554. declare module BABYLON {
  41555. /**
  41556. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  41557. * @see http://doc.babylonjs.com/features/cameras
  41558. */
  41559. export class StereoscopicGamepadCamera extends GamepadCamera {
  41560. /**
  41561. * Creates a new StereoscopicGamepadCamera
  41562. * @param name defines camera name
  41563. * @param position defines initial position
  41564. * @param interaxialDistance defines distance between each color axis
  41565. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41566. * @param scene defines the hosting scene
  41567. */
  41568. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41569. /**
  41570. * Gets camera class name
  41571. * @returns StereoscopicGamepadCamera
  41572. */
  41573. getClassName(): string;
  41574. }
  41575. }
  41576. declare module BABYLON {
  41577. /**
  41578. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  41579. * @see http://doc.babylonjs.com/features/cameras
  41580. */
  41581. export class StereoscopicUniversalCamera extends UniversalCamera {
  41582. /**
  41583. * Creates a new StereoscopicUniversalCamera
  41584. * @param name defines camera name
  41585. * @param position defines initial position
  41586. * @param interaxialDistance defines distance between each color axis
  41587. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41588. * @param scene defines the hosting scene
  41589. */
  41590. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41591. /**
  41592. * Gets camera class name
  41593. * @returns StereoscopicUniversalCamera
  41594. */
  41595. getClassName(): string;
  41596. }
  41597. }
  41598. declare module BABYLON {
  41599. /**
  41600. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  41601. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  41602. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  41603. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  41604. */
  41605. export class VirtualJoysticksCamera extends FreeCamera {
  41606. /**
  41607. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  41608. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  41609. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  41610. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  41611. * @param name Define the name of the camera in the scene
  41612. * @param position Define the start position of the camera in the scene
  41613. * @param scene Define the scene the camera belongs to
  41614. */
  41615. constructor(name: string, position: Vector3, scene: Scene);
  41616. /**
  41617. * Gets the current object class name.
  41618. * @return the class name
  41619. */
  41620. getClassName(): string;
  41621. }
  41622. }
  41623. declare module BABYLON {
  41624. /**
  41625. * This represents all the required metrics to create a VR camera.
  41626. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  41627. */
  41628. export class VRCameraMetrics {
  41629. /**
  41630. * Define the horizontal resolution off the screen.
  41631. */
  41632. hResolution: number;
  41633. /**
  41634. * Define the vertical resolution off the screen.
  41635. */
  41636. vResolution: number;
  41637. /**
  41638. * Define the horizontal screen size.
  41639. */
  41640. hScreenSize: number;
  41641. /**
  41642. * Define the vertical screen size.
  41643. */
  41644. vScreenSize: number;
  41645. /**
  41646. * Define the vertical screen center position.
  41647. */
  41648. vScreenCenter: number;
  41649. /**
  41650. * Define the distance of the eyes to the screen.
  41651. */
  41652. eyeToScreenDistance: number;
  41653. /**
  41654. * Define the distance between both lenses
  41655. */
  41656. lensSeparationDistance: number;
  41657. /**
  41658. * Define the distance between both viewer's eyes.
  41659. */
  41660. interpupillaryDistance: number;
  41661. /**
  41662. * Define the distortion factor of the VR postprocess.
  41663. * Please, touch with care.
  41664. */
  41665. distortionK: number[];
  41666. /**
  41667. * Define the chromatic aberration correction factors for the VR post process.
  41668. */
  41669. chromaAbCorrection: number[];
  41670. /**
  41671. * Define the scale factor of the post process.
  41672. * The smaller the better but the slower.
  41673. */
  41674. postProcessScaleFactor: number;
  41675. /**
  41676. * Define an offset for the lens center.
  41677. */
  41678. lensCenterOffset: number;
  41679. /**
  41680. * Define if the current vr camera should compensate the distortion of the lense or not.
  41681. */
  41682. compensateDistortion: boolean;
  41683. /**
  41684. * Defines if multiview should be enabled when rendering (Default: false)
  41685. */
  41686. multiviewEnabled: boolean;
  41687. /**
  41688. * Gets the rendering aspect ratio based on the provided resolutions.
  41689. */
  41690. get aspectRatio(): number;
  41691. /**
  41692. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  41693. */
  41694. get aspectRatioFov(): number;
  41695. /**
  41696. * @hidden
  41697. */
  41698. get leftHMatrix(): Matrix;
  41699. /**
  41700. * @hidden
  41701. */
  41702. get rightHMatrix(): Matrix;
  41703. /**
  41704. * @hidden
  41705. */
  41706. get leftPreViewMatrix(): Matrix;
  41707. /**
  41708. * @hidden
  41709. */
  41710. get rightPreViewMatrix(): Matrix;
  41711. /**
  41712. * Get the default VRMetrics based on the most generic setup.
  41713. * @returns the default vr metrics
  41714. */
  41715. static GetDefault(): VRCameraMetrics;
  41716. }
  41717. }
  41718. declare module BABYLON {
  41719. /** @hidden */
  41720. export var vrDistortionCorrectionPixelShader: {
  41721. name: string;
  41722. shader: string;
  41723. };
  41724. }
  41725. declare module BABYLON {
  41726. /**
  41727. * VRDistortionCorrectionPostProcess used for mobile VR
  41728. */
  41729. export class VRDistortionCorrectionPostProcess extends PostProcess {
  41730. private _isRightEye;
  41731. private _distortionFactors;
  41732. private _postProcessScaleFactor;
  41733. private _lensCenterOffset;
  41734. private _scaleIn;
  41735. private _scaleFactor;
  41736. private _lensCenter;
  41737. /**
  41738. * Initializes the VRDistortionCorrectionPostProcess
  41739. * @param name The name of the effect.
  41740. * @param camera The camera to apply the render pass to.
  41741. * @param isRightEye If this is for the right eye distortion
  41742. * @param vrMetrics All the required metrics for the VR camera
  41743. */
  41744. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  41745. }
  41746. }
  41747. declare module BABYLON {
  41748. /**
  41749. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  41750. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41751. */
  41752. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  41753. /**
  41754. * Creates a new VRDeviceOrientationArcRotateCamera
  41755. * @param name defines camera name
  41756. * @param alpha defines the camera rotation along the logitudinal axis
  41757. * @param beta defines the camera rotation along the latitudinal axis
  41758. * @param radius defines the camera distance from its target
  41759. * @param target defines the camera target
  41760. * @param scene defines the scene the camera belongs to
  41761. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41762. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41763. */
  41764. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41765. /**
  41766. * Gets camera class name
  41767. * @returns VRDeviceOrientationArcRotateCamera
  41768. */
  41769. getClassName(): string;
  41770. }
  41771. }
  41772. declare module BABYLON {
  41773. /**
  41774. * Camera used to simulate VR rendering (based on FreeCamera)
  41775. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41776. */
  41777. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  41778. /**
  41779. * Creates a new VRDeviceOrientationFreeCamera
  41780. * @param name defines camera name
  41781. * @param position defines the start position of the camera
  41782. * @param scene defines the scene the camera belongs to
  41783. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41784. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41785. */
  41786. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41787. /**
  41788. * Gets camera class name
  41789. * @returns VRDeviceOrientationFreeCamera
  41790. */
  41791. getClassName(): string;
  41792. }
  41793. }
  41794. declare module BABYLON {
  41795. /**
  41796. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  41797. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41798. */
  41799. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  41800. /**
  41801. * Creates a new VRDeviceOrientationGamepadCamera
  41802. * @param name defines camera name
  41803. * @param position defines the start position of the camera
  41804. * @param scene defines the scene the camera belongs to
  41805. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41806. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41807. */
  41808. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41809. /**
  41810. * Gets camera class name
  41811. * @returns VRDeviceOrientationGamepadCamera
  41812. */
  41813. getClassName(): string;
  41814. }
  41815. }
  41816. declare module BABYLON {
  41817. /** @hidden */
  41818. export var imageProcessingPixelShader: {
  41819. name: string;
  41820. shader: string;
  41821. };
  41822. }
  41823. declare module BABYLON {
  41824. /**
  41825. * ImageProcessingPostProcess
  41826. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  41827. */
  41828. export class ImageProcessingPostProcess extends PostProcess {
  41829. /**
  41830. * Default configuration related to image processing available in the PBR Material.
  41831. */
  41832. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41833. /**
  41834. * Gets the image processing configuration used either in this material.
  41835. */
  41836. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  41837. /**
  41838. * Sets the Default image processing configuration used either in the this material.
  41839. *
  41840. * If sets to null, the scene one is in use.
  41841. */
  41842. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  41843. /**
  41844. * Keep track of the image processing observer to allow dispose and replace.
  41845. */
  41846. private _imageProcessingObserver;
  41847. /**
  41848. * Attaches a new image processing configuration to the PBR Material.
  41849. * @param configuration
  41850. */
  41851. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  41852. /**
  41853. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41854. */
  41855. get colorCurves(): Nullable<ColorCurves>;
  41856. /**
  41857. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41858. */
  41859. set colorCurves(value: Nullable<ColorCurves>);
  41860. /**
  41861. * Gets wether the color curves effect is enabled.
  41862. */
  41863. get colorCurvesEnabled(): boolean;
  41864. /**
  41865. * Sets wether the color curves effect is enabled.
  41866. */
  41867. set colorCurvesEnabled(value: boolean);
  41868. /**
  41869. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41870. */
  41871. get colorGradingTexture(): Nullable<BaseTexture>;
  41872. /**
  41873. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41874. */
  41875. set colorGradingTexture(value: Nullable<BaseTexture>);
  41876. /**
  41877. * Gets wether the color grading effect is enabled.
  41878. */
  41879. get colorGradingEnabled(): boolean;
  41880. /**
  41881. * Gets wether the color grading effect is enabled.
  41882. */
  41883. set colorGradingEnabled(value: boolean);
  41884. /**
  41885. * Gets exposure used in the effect.
  41886. */
  41887. get exposure(): number;
  41888. /**
  41889. * Sets exposure used in the effect.
  41890. */
  41891. set exposure(value: number);
  41892. /**
  41893. * Gets wether tonemapping is enabled or not.
  41894. */
  41895. get toneMappingEnabled(): boolean;
  41896. /**
  41897. * Sets wether tonemapping is enabled or not
  41898. */
  41899. set toneMappingEnabled(value: boolean);
  41900. /**
  41901. * Gets the type of tone mapping effect.
  41902. */
  41903. get toneMappingType(): number;
  41904. /**
  41905. * Sets the type of tone mapping effect.
  41906. */
  41907. set toneMappingType(value: number);
  41908. /**
  41909. * Gets contrast used in the effect.
  41910. */
  41911. get contrast(): number;
  41912. /**
  41913. * Sets contrast used in the effect.
  41914. */
  41915. set contrast(value: number);
  41916. /**
  41917. * Gets Vignette stretch size.
  41918. */
  41919. get vignetteStretch(): number;
  41920. /**
  41921. * Sets Vignette stretch size.
  41922. */
  41923. set vignetteStretch(value: number);
  41924. /**
  41925. * Gets Vignette centre X Offset.
  41926. */
  41927. get vignetteCentreX(): number;
  41928. /**
  41929. * Sets Vignette centre X Offset.
  41930. */
  41931. set vignetteCentreX(value: number);
  41932. /**
  41933. * Gets Vignette centre Y Offset.
  41934. */
  41935. get vignetteCentreY(): number;
  41936. /**
  41937. * Sets Vignette centre Y Offset.
  41938. */
  41939. set vignetteCentreY(value: number);
  41940. /**
  41941. * Gets Vignette weight or intensity of the vignette effect.
  41942. */
  41943. get vignetteWeight(): number;
  41944. /**
  41945. * Sets Vignette weight or intensity of the vignette effect.
  41946. */
  41947. set vignetteWeight(value: number);
  41948. /**
  41949. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  41950. * if vignetteEnabled is set to true.
  41951. */
  41952. get vignetteColor(): Color4;
  41953. /**
  41954. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  41955. * if vignetteEnabled is set to true.
  41956. */
  41957. set vignetteColor(value: Color4);
  41958. /**
  41959. * Gets Camera field of view used by the Vignette effect.
  41960. */
  41961. get vignetteCameraFov(): number;
  41962. /**
  41963. * Sets Camera field of view used by the Vignette effect.
  41964. */
  41965. set vignetteCameraFov(value: number);
  41966. /**
  41967. * Gets the vignette blend mode allowing different kind of effect.
  41968. */
  41969. get vignetteBlendMode(): number;
  41970. /**
  41971. * Sets the vignette blend mode allowing different kind of effect.
  41972. */
  41973. set vignetteBlendMode(value: number);
  41974. /**
  41975. * Gets wether the vignette effect is enabled.
  41976. */
  41977. get vignetteEnabled(): boolean;
  41978. /**
  41979. * Sets wether the vignette effect is enabled.
  41980. */
  41981. set vignetteEnabled(value: boolean);
  41982. private _fromLinearSpace;
  41983. /**
  41984. * Gets wether the input of the processing is in Gamma or Linear Space.
  41985. */
  41986. get fromLinearSpace(): boolean;
  41987. /**
  41988. * Sets wether the input of the processing is in Gamma or Linear Space.
  41989. */
  41990. set fromLinearSpace(value: boolean);
  41991. /**
  41992. * Defines cache preventing GC.
  41993. */
  41994. private _defines;
  41995. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  41996. /**
  41997. * "ImageProcessingPostProcess"
  41998. * @returns "ImageProcessingPostProcess"
  41999. */
  42000. getClassName(): string;
  42001. protected _updateParameters(): void;
  42002. dispose(camera?: Camera): void;
  42003. }
  42004. }
  42005. declare module BABYLON {
  42006. /**
  42007. * Class containing static functions to help procedurally build meshes
  42008. */
  42009. export class GroundBuilder {
  42010. /**
  42011. * Creates a ground mesh
  42012. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  42013. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  42014. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42015. * @param name defines the name of the mesh
  42016. * @param options defines the options used to create the mesh
  42017. * @param scene defines the hosting scene
  42018. * @returns the ground mesh
  42019. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  42020. */
  42021. static CreateGround(name: string, options: {
  42022. width?: number;
  42023. height?: number;
  42024. subdivisions?: number;
  42025. subdivisionsX?: number;
  42026. subdivisionsY?: number;
  42027. updatable?: boolean;
  42028. }, scene: any): Mesh;
  42029. /**
  42030. * Creates a tiled ground mesh
  42031. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  42032. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  42033. * * 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
  42034. * * 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
  42035. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42036. * @param name defines the name of the mesh
  42037. * @param options defines the options used to create the mesh
  42038. * @param scene defines the hosting scene
  42039. * @returns the tiled ground mesh
  42040. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  42041. */
  42042. static CreateTiledGround(name: string, options: {
  42043. xmin: number;
  42044. zmin: number;
  42045. xmax: number;
  42046. zmax: number;
  42047. subdivisions?: {
  42048. w: number;
  42049. h: number;
  42050. };
  42051. precision?: {
  42052. w: number;
  42053. h: number;
  42054. };
  42055. updatable?: boolean;
  42056. }, scene?: Nullable<Scene>): Mesh;
  42057. /**
  42058. * Creates a ground mesh from a height map
  42059. * * The parameter `url` sets the URL of the height map image resource.
  42060. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  42061. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  42062. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  42063. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  42064. * * 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.
  42065. * * 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).
  42066. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  42067. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42068. * @param name defines the name of the mesh
  42069. * @param url defines the url to the height map
  42070. * @param options defines the options used to create the mesh
  42071. * @param scene defines the hosting scene
  42072. * @returns the ground mesh
  42073. * @see https://doc.babylonjs.com/babylon101/height_map
  42074. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  42075. */
  42076. static CreateGroundFromHeightMap(name: string, url: string, options: {
  42077. width?: number;
  42078. height?: number;
  42079. subdivisions?: number;
  42080. minHeight?: number;
  42081. maxHeight?: number;
  42082. colorFilter?: Color3;
  42083. alphaFilter?: number;
  42084. updatable?: boolean;
  42085. onReady?: (mesh: GroundMesh) => void;
  42086. }, scene?: Nullable<Scene>): GroundMesh;
  42087. }
  42088. }
  42089. declare module BABYLON {
  42090. /**
  42091. * Class containing static functions to help procedurally build meshes
  42092. */
  42093. export class TorusBuilder {
  42094. /**
  42095. * Creates a torus mesh
  42096. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  42097. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  42098. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  42099. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42100. * * 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
  42101. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42102. * @param name defines the name of the mesh
  42103. * @param options defines the options used to create the mesh
  42104. * @param scene defines the hosting scene
  42105. * @returns the torus mesh
  42106. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  42107. */
  42108. static CreateTorus(name: string, options: {
  42109. diameter?: number;
  42110. thickness?: number;
  42111. tessellation?: number;
  42112. updatable?: boolean;
  42113. sideOrientation?: number;
  42114. frontUVs?: Vector4;
  42115. backUVs?: Vector4;
  42116. }, scene: any): Mesh;
  42117. }
  42118. }
  42119. declare module BABYLON {
  42120. /**
  42121. * Class containing static functions to help procedurally build meshes
  42122. */
  42123. export class CylinderBuilder {
  42124. /**
  42125. * Creates a cylinder or a cone mesh
  42126. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  42127. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  42128. * * 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.
  42129. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  42130. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  42131. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  42132. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  42133. * * 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).
  42134. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  42135. * * 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).
  42136. * * 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
  42137. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  42138. * * 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
  42139. * * 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.
  42140. * * If `enclose` is false, a ring surface is one element.
  42141. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  42142. * * 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
  42143. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42144. * * 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
  42145. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42146. * @param name defines the name of the mesh
  42147. * @param options defines the options used to create the mesh
  42148. * @param scene defines the hosting scene
  42149. * @returns the cylinder mesh
  42150. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  42151. */
  42152. static CreateCylinder(name: string, options: {
  42153. height?: number;
  42154. diameterTop?: number;
  42155. diameterBottom?: number;
  42156. diameter?: number;
  42157. tessellation?: number;
  42158. subdivisions?: number;
  42159. arc?: number;
  42160. faceColors?: Color4[];
  42161. faceUV?: Vector4[];
  42162. updatable?: boolean;
  42163. hasRings?: boolean;
  42164. enclose?: boolean;
  42165. cap?: number;
  42166. sideOrientation?: number;
  42167. frontUVs?: Vector4;
  42168. backUVs?: Vector4;
  42169. }, scene: any): Mesh;
  42170. }
  42171. }
  42172. declare module BABYLON {
  42173. /**
  42174. * States of the webXR experience
  42175. */
  42176. export enum WebXRState {
  42177. /**
  42178. * Transitioning to being in XR mode
  42179. */
  42180. ENTERING_XR = 0,
  42181. /**
  42182. * Transitioning to non XR mode
  42183. */
  42184. EXITING_XR = 1,
  42185. /**
  42186. * In XR mode and presenting
  42187. */
  42188. IN_XR = 2,
  42189. /**
  42190. * Not entered XR mode
  42191. */
  42192. NOT_IN_XR = 3
  42193. }
  42194. /**
  42195. * Abstraction of the XR render target
  42196. */
  42197. export interface WebXRRenderTarget extends IDisposable {
  42198. /**
  42199. * xrpresent context of the canvas which can be used to display/mirror xr content
  42200. */
  42201. canvasContext: WebGLRenderingContext;
  42202. /**
  42203. * xr layer for the canvas
  42204. */
  42205. xrLayer: Nullable<XRWebGLLayer>;
  42206. /**
  42207. * Initializes the xr layer for the session
  42208. * @param xrSession xr session
  42209. * @returns a promise that will resolve once the XR Layer has been created
  42210. */
  42211. initializeXRLayerAsync(xrSession: XRSession): Promise<void>;
  42212. }
  42213. }
  42214. declare module BABYLON {
  42215. /**
  42216. * COnfiguration object for WebXR output canvas
  42217. */
  42218. export class WebXRManagedOutputCanvasOptions {
  42219. /**
  42220. * Options for this XR Layer output
  42221. */
  42222. canvasOptions: XRWebGLLayerOptions;
  42223. /**
  42224. * CSS styling for a newly created canvas (if not provided)
  42225. */
  42226. newCanvasCssStyle?: string;
  42227. /**
  42228. * Get the default values of the configuration object
  42229. * @returns default values of this configuration object
  42230. */
  42231. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  42232. }
  42233. /**
  42234. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  42235. */
  42236. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  42237. private configuration;
  42238. private _engine;
  42239. private _canvas;
  42240. /**
  42241. * xrpresent context of the canvas which can be used to display/mirror xr content
  42242. */
  42243. canvasContext: WebGLRenderingContext;
  42244. /**
  42245. * xr layer for the canvas
  42246. */
  42247. xrLayer: Nullable<XRWebGLLayer>;
  42248. /**
  42249. * Initializes the xr layer for the session
  42250. * @param xrSession xr session
  42251. * @returns a promise that will resolve once the XR Layer has been created
  42252. */
  42253. initializeXRLayerAsync(xrSession: any): any;
  42254. /**
  42255. * Initializes the canvas to be added/removed upon entering/exiting xr
  42256. * @param engine the Babylon engine
  42257. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  42258. * @param onStateChangedObservable the mechanism by which the canvas will be added/removed based on XR state
  42259. * @param configuration optional configuration for this canvas output. defaults will be used if not provided
  42260. */
  42261. constructor(engine: ThinEngine, canvas?: HTMLCanvasElement, onStateChangedObservable?: Observable<WebXRState>, configuration?: WebXRManagedOutputCanvasOptions);
  42262. /**
  42263. * Disposes of the object
  42264. */
  42265. dispose(): void;
  42266. private _setManagedOutputCanvas;
  42267. private _addCanvas;
  42268. private _removeCanvas;
  42269. }
  42270. }
  42271. declare module BABYLON {
  42272. /**
  42273. * Manages an XRSession to work with Babylon's engine
  42274. * @see https://doc.babylonjs.com/how_to/webxr
  42275. */
  42276. export class WebXRSessionManager implements IDisposable {
  42277. /** The scene which the session should be created for */
  42278. scene: Scene;
  42279. /**
  42280. * Fires every time a new xrFrame arrives which can be used to update the camera
  42281. */
  42282. onXRFrameObservable: Observable<XRFrame>;
  42283. /**
  42284. * Fires when the xr session is ended either by the device or manually done
  42285. */
  42286. onXRSessionEnded: Observable<any>;
  42287. /**
  42288. * Fires when the xr session is ended either by the device or manually done
  42289. */
  42290. onXRSessionInit: Observable<XRSession>;
  42291. /**
  42292. * Underlying xr session
  42293. */
  42294. session: XRSession;
  42295. /**
  42296. * Type of reference space used when creating the session
  42297. */
  42298. referenceSpace: XRReferenceSpace;
  42299. /**
  42300. * Current XR frame
  42301. */
  42302. currentFrame: Nullable<XRFrame>;
  42303. /** WebXR timestamp updated every frame */
  42304. currentTimestamp: number;
  42305. private _xrNavigator;
  42306. private baseLayer;
  42307. private _rttProvider;
  42308. private _sessionEnded;
  42309. /**
  42310. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  42311. * @param scene The scene which the session should be created for
  42312. */
  42313. constructor(
  42314. /** The scene which the session should be created for */
  42315. scene: Scene);
  42316. /**
  42317. * Initializes the manager
  42318. * After initialization enterXR can be called to start an XR session
  42319. * @returns Promise which resolves after it is initialized
  42320. */
  42321. initializeAsync(): Promise<void>;
  42322. /**
  42323. * Initializes an xr session
  42324. * @param xrSessionMode mode to initialize
  42325. * @param optionalFeatures defines optional values to pass to the session builder
  42326. * @returns a promise which will resolve once the session has been initialized
  42327. */
  42328. initializeSessionAsync(xrSessionMode: XRSessionMode, optionalFeatures?: any): Promise<XRSession>;
  42329. /**
  42330. * Sets the reference space on the xr session
  42331. * @param referenceSpace space to set
  42332. * @returns a promise that will resolve once the reference space has been set
  42333. */
  42334. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  42335. /**
  42336. * Updates the render state of the session
  42337. * @param state state to set
  42338. * @returns a promise that resolves once the render state has been updated
  42339. */
  42340. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  42341. /**
  42342. * Starts rendering to the xr layer
  42343. * @returns a promise that will resolve once rendering has started
  42344. */
  42345. startRenderingToXRAsync(): Promise<void>;
  42346. /**
  42347. * Gets the correct render target texture to be rendered this frame for this eye
  42348. * @param eye the eye for which to get the render target
  42349. * @returns the render target for the specified eye
  42350. */
  42351. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  42352. /**
  42353. * Stops the xrSession and restores the renderloop
  42354. * @returns Promise which resolves after it exits XR
  42355. */
  42356. exitXRAsync(): Promise<void>;
  42357. /**
  42358. * Checks if a session would be supported for the creation options specified
  42359. * @param sessionMode session mode to check if supported eg. immersive-vr
  42360. * @returns true if supported
  42361. */
  42362. supportsSessionAsync(sessionMode: XRSessionMode): Promise<boolean>;
  42363. /**
  42364. * Creates a WebXRRenderTarget object for the XR session
  42365. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  42366. * @param options optional options to provide when creating a new render target
  42367. * @returns a WebXR render target to which the session can render
  42368. */
  42369. getWebXRRenderTarget(onStateChangedObservable?: Observable<WebXRState>, options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  42370. /**
  42371. * @hidden
  42372. * Converts the render layer of xrSession to a render target
  42373. * @param session session to create render target for
  42374. * @param scene scene the new render target should be created for
  42375. * @param baseLayer the webgl layer to create the render target for
  42376. */
  42377. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  42378. /**
  42379. * Disposes of the session manager
  42380. */
  42381. dispose(): void;
  42382. /**
  42383. * Gets a promise returning true when fullfiled if the given session mode is supported
  42384. * @param sessionMode defines the session to test
  42385. * @returns a promise
  42386. */
  42387. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  42388. }
  42389. }
  42390. declare module BABYLON {
  42391. /**
  42392. * WebXR Camera which holds the views for the xrSession
  42393. * @see https://doc.babylonjs.com/how_to/webxr
  42394. */
  42395. export class WebXRCamera extends FreeCamera {
  42396. /**
  42397. * Is the camera in debug mode. Used when using an emulator
  42398. */
  42399. debugMode: boolean;
  42400. /**
  42401. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  42402. * @param name the name of the camera
  42403. * @param scene the scene to add the camera to
  42404. */
  42405. constructor(name: string, scene: Scene);
  42406. private _updateNumberOfRigCameras;
  42407. /** @hidden */
  42408. _updateForDualEyeDebugging(): void;
  42409. /**
  42410. * Updates the cameras position from the current pose information of the XR session
  42411. * @param xrSessionManager the session containing pose information
  42412. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  42413. */
  42414. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  42415. }
  42416. }
  42417. declare module BABYLON {
  42418. /**
  42419. * Defining the interface required for a (webxr) feature
  42420. */
  42421. export interface IWebXRFeature extends IDisposable {
  42422. /**
  42423. * Attach the feature to the session
  42424. * Will usually be called by the features manager
  42425. *
  42426. * @returns true if successful.
  42427. */
  42428. attach(): boolean;
  42429. /**
  42430. * Detach the feature from the session
  42431. * Will usually be called by the features manager
  42432. *
  42433. * @returns true if successful.
  42434. */
  42435. detach(): boolean;
  42436. }
  42437. /**
  42438. * Defining the constructor of a feature. Used to register the modules.
  42439. */
  42440. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  42441. /**
  42442. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  42443. * It is mainly used in AR sessions.
  42444. *
  42445. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  42446. */
  42447. export class WebXRFeaturesManager implements IDisposable {
  42448. private _xrSessionManager;
  42449. private static readonly _AvailableFeatures;
  42450. /**
  42451. * Used to register a module. After calling this function a developer can use this feature in the scene.
  42452. * Mainly used internally.
  42453. *
  42454. * @param featureName the name of the feature to register
  42455. * @param constructorFunction the function used to construct the module
  42456. * @param version the (babylon) version of the module
  42457. * @param stable is that a stable version of this module
  42458. */
  42459. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  42460. /**
  42461. * Returns a constructor of a specific feature.
  42462. *
  42463. * @param featureName the name of the feature to construct
  42464. * @param version the version of the feature to load
  42465. * @param xrSessionManager the xrSessionManager. Used to construct the module
  42466. * @param options optional options provided to the module.
  42467. * @returns a function that, when called, will return a new instance of this feature
  42468. */
  42469. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  42470. /**
  42471. * Return the latest unstable version of this feature
  42472. * @param featureName the name of the feature to search
  42473. * @returns the version number. if not found will return -1
  42474. */
  42475. static GetLatestVersionOfFeature(featureName: string): number;
  42476. /**
  42477. * Return the latest stable version of this feature
  42478. * @param featureName the name of the feature to search
  42479. * @returns the version number. if not found will return -1
  42480. */
  42481. static GetStableVersionOfFeature(featureName: string): number;
  42482. /**
  42483. * Can be used to return the list of features currently registered
  42484. *
  42485. * @returns an Array of available features
  42486. */
  42487. static GetAvailableFeatures(): string[];
  42488. /**
  42489. * Gets the versions available for a specific feature
  42490. * @param featureName the name of the feature
  42491. * @returns an array with the available versions
  42492. */
  42493. static GetAvailableVersions(featureName: string): string[];
  42494. private _features;
  42495. /**
  42496. * constructs a new features manages.
  42497. *
  42498. * @param _xrSessionManager an instance of WebXRSessionManager
  42499. */
  42500. constructor(_xrSessionManager: WebXRSessionManager);
  42501. /**
  42502. * 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.
  42503. *
  42504. * @param featureName the name of the feature to load or the class of the feature
  42505. * @param version optional version to load. if not provided the latest version will be enabled
  42506. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  42507. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  42508. * @returns a new constructed feature or throws an error if feature not found.
  42509. */
  42510. enableFeature(featureName: string | {
  42511. Name: string;
  42512. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  42513. /**
  42514. * Used to disable an already-enabled feature
  42515. * @param featureName the feature to disable
  42516. * @returns true if disable was successful
  42517. */
  42518. disableFeature(featureName: string | {
  42519. Name: string;
  42520. }): boolean;
  42521. /**
  42522. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  42523. * Can be used during a session to start a feature
  42524. * @param featureName the name of feature to attach
  42525. */
  42526. attachFeature(featureName: string): void;
  42527. /**
  42528. * Can be used inside a session or when the session ends to detach a specific feature
  42529. * @param featureName the name of the feature to detach
  42530. */
  42531. detachFeature(featureName: string): void;
  42532. /**
  42533. * Get the list of enabled features
  42534. * @returns an array of enabled features
  42535. */
  42536. getEnabledFeatures(): string[];
  42537. /**
  42538. * get the implementation of an enabled feature.
  42539. * @param featureName the name of the feature to load
  42540. * @returns the feature class, if found
  42541. */
  42542. getEnabledFeature(featureName: string): IWebXRFeature;
  42543. /**
  42544. * dispose this features manager
  42545. */
  42546. dispose(): void;
  42547. }
  42548. }
  42549. declare module BABYLON {
  42550. /**
  42551. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  42552. * @see https://doc.babylonjs.com/how_to/webxr
  42553. */
  42554. export class WebXRExperienceHelper implements IDisposable {
  42555. private scene;
  42556. /**
  42557. * Container which stores the xr camera and controllers as children. This can be used to move the camera/user as the camera's position is updated by the xr device
  42558. */
  42559. container: AbstractMesh;
  42560. /**
  42561. * Camera used to render xr content
  42562. */
  42563. camera: WebXRCamera;
  42564. /**
  42565. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  42566. */
  42567. state: WebXRState;
  42568. private _setState;
  42569. private static _TmpVector;
  42570. /**
  42571. * Fires when the state of the experience helper has changed
  42572. */
  42573. onStateChangedObservable: Observable<WebXRState>;
  42574. /** Session manager used to keep track of xr session */
  42575. sessionManager: WebXRSessionManager;
  42576. /** A features manager for this xr session */
  42577. featuresManager: WebXRFeaturesManager;
  42578. private _nonVRCamera;
  42579. private _originalSceneAutoClear;
  42580. private _supported;
  42581. /**
  42582. * Creates the experience helper
  42583. * @param scene the scene to attach the experience helper to
  42584. * @returns a promise for the experience helper
  42585. */
  42586. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  42587. /**
  42588. * Creates a WebXRExperienceHelper
  42589. * @param scene The scene the helper should be created in
  42590. */
  42591. private constructor();
  42592. /**
  42593. * Exits XR mode and returns the scene to its original state
  42594. * @returns promise that resolves after xr mode has exited
  42595. */
  42596. exitXRAsync(): Promise<void>;
  42597. /**
  42598. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  42599. * @param sessionMode options for the XR session
  42600. * @param referenceSpaceType frame of reference of the XR session
  42601. * @param renderTarget the output canvas that will be used to enter XR mode
  42602. * @returns promise that resolves after xr mode has entered
  42603. */
  42604. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget: WebXRRenderTarget): Promise<WebXRSessionManager>;
  42605. /**
  42606. * Updates the global position of the camera by moving the camera's container
  42607. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  42608. * @param position The desired global position of the camera
  42609. */
  42610. setPositionOfCameraUsingContainer(position: Vector3): void;
  42611. /**
  42612. * Rotates the xr camera by rotating the camera's container around the camera's position
  42613. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  42614. * @param rotation the desired quaternion rotation to apply to the camera
  42615. */
  42616. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  42617. /**
  42618. * Disposes of the experience helper
  42619. */
  42620. dispose(): void;
  42621. }
  42622. }
  42623. declare module BABYLON {
  42624. /**
  42625. * Represents an XR input
  42626. */
  42627. export class WebXRController {
  42628. private scene;
  42629. /** The underlying input source for the controller */
  42630. inputSource: XRInputSource;
  42631. private parentContainer;
  42632. /**
  42633. * 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
  42634. */
  42635. grip?: AbstractMesh;
  42636. /**
  42637. * Pointer which can be used to select objects or attach a visible laser to
  42638. */
  42639. pointer: AbstractMesh;
  42640. private _gamepadMode;
  42641. /**
  42642. * If available, this is the gamepad object related to this controller.
  42643. * Using this object it is possible to get click events and trackpad changes of the
  42644. * webxr controller that is currently being used.
  42645. */
  42646. gamepadController?: WebVRController;
  42647. /**
  42648. * Event that fires when the controller is removed/disposed
  42649. */
  42650. onDisposeObservable: Observable<{}>;
  42651. private _tmpQuaternion;
  42652. private _tmpVector;
  42653. /**
  42654. * Creates the controller
  42655. * @see https://doc.babylonjs.com/how_to/webxr
  42656. * @param scene the scene which the controller should be associated to
  42657. * @param inputSource the underlying input source for the controller
  42658. * @param parentContainer parent that the controller meshes should be children of
  42659. */
  42660. constructor(scene: Scene,
  42661. /** The underlying input source for the controller */
  42662. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  42663. /**
  42664. * Updates the controller pose based on the given XRFrame
  42665. * @param xrFrame xr frame to update the pose with
  42666. * @param referenceSpace reference space to use
  42667. */
  42668. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  42669. /**
  42670. * Gets a world space ray coming from the controller
  42671. * @param result the resulting ray
  42672. */
  42673. getWorldPointerRayToRef(result: Ray): void;
  42674. /**
  42675. * Get the scene associated with this controller
  42676. * @returns the scene object
  42677. */
  42678. getScene(): Scene;
  42679. /**
  42680. * Disposes of the object
  42681. */
  42682. dispose(): void;
  42683. }
  42684. }
  42685. declare module BABYLON {
  42686. /**
  42687. * XR input used to track XR inputs such as controllers/rays
  42688. */
  42689. export class WebXRInput implements IDisposable {
  42690. /**
  42691. * Base experience the input listens to
  42692. */
  42693. baseExperience: WebXRExperienceHelper;
  42694. /**
  42695. * XR controllers being tracked
  42696. */
  42697. controllers: Array<WebXRController>;
  42698. private _frameObserver;
  42699. private _stateObserver;
  42700. /**
  42701. * Event when a controller has been connected/added
  42702. */
  42703. onControllerAddedObservable: Observable<WebXRController>;
  42704. /**
  42705. * Event when a controller has been removed/disconnected
  42706. */
  42707. onControllerRemovedObservable: Observable<WebXRController>;
  42708. /**
  42709. * Initializes the WebXRInput
  42710. * @param baseExperience experience helper which the input should be created for
  42711. */
  42712. constructor(
  42713. /**
  42714. * Base experience the input listens to
  42715. */
  42716. baseExperience: WebXRExperienceHelper);
  42717. private _onInputSourcesChange;
  42718. private _addAndRemoveControllers;
  42719. /**
  42720. * Disposes of the object
  42721. */
  42722. dispose(): void;
  42723. }
  42724. }
  42725. declare module BABYLON {
  42726. /**
  42727. * Class used to represent data loading progression
  42728. */
  42729. export class SceneLoaderProgressEvent {
  42730. /** defines if data length to load can be evaluated */
  42731. readonly lengthComputable: boolean;
  42732. /** defines the loaded data length */
  42733. readonly loaded: number;
  42734. /** defines the data length to load */
  42735. readonly total: number;
  42736. /**
  42737. * Create a new progress event
  42738. * @param lengthComputable defines if data length to load can be evaluated
  42739. * @param loaded defines the loaded data length
  42740. * @param total defines the data length to load
  42741. */
  42742. constructor(
  42743. /** defines if data length to load can be evaluated */
  42744. lengthComputable: boolean,
  42745. /** defines the loaded data length */
  42746. loaded: number,
  42747. /** defines the data length to load */
  42748. total: number);
  42749. /**
  42750. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  42751. * @param event defines the source event
  42752. * @returns a new SceneLoaderProgressEvent
  42753. */
  42754. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  42755. }
  42756. /**
  42757. * Interface used by SceneLoader plugins to define supported file extensions
  42758. */
  42759. export interface ISceneLoaderPluginExtensions {
  42760. /**
  42761. * Defines the list of supported extensions
  42762. */
  42763. [extension: string]: {
  42764. isBinary: boolean;
  42765. };
  42766. }
  42767. /**
  42768. * Interface used by SceneLoader plugin factory
  42769. */
  42770. export interface ISceneLoaderPluginFactory {
  42771. /**
  42772. * Defines the name of the factory
  42773. */
  42774. name: string;
  42775. /**
  42776. * Function called to create a new plugin
  42777. * @return the new plugin
  42778. */
  42779. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  42780. /**
  42781. * The callback that returns true if the data can be directly loaded.
  42782. * @param data string containing the file data
  42783. * @returns if the data can be loaded directly
  42784. */
  42785. canDirectLoad?(data: string): boolean;
  42786. }
  42787. /**
  42788. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  42789. */
  42790. export interface ISceneLoaderPluginBase {
  42791. /**
  42792. * The friendly name of this plugin.
  42793. */
  42794. name: string;
  42795. /**
  42796. * The file extensions supported by this plugin.
  42797. */
  42798. extensions: string | ISceneLoaderPluginExtensions;
  42799. /**
  42800. * The callback called when loading from a url.
  42801. * @param scene scene loading this url
  42802. * @param url url to load
  42803. * @param onSuccess callback called when the file successfully loads
  42804. * @param onProgress callback called while file is loading (if the server supports this mode)
  42805. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  42806. * @param onError callback called when the file fails to load
  42807. * @returns a file request object
  42808. */
  42809. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  42810. /**
  42811. * The callback called when loading from a file object.
  42812. * @param scene scene loading this file
  42813. * @param file defines the file to load
  42814. * @param onSuccess defines the callback to call when data is loaded
  42815. * @param onProgress defines the callback to call during loading process
  42816. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  42817. * @param onError defines the callback to call when an error occurs
  42818. * @returns a file request object
  42819. */
  42820. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  42821. /**
  42822. * The callback that returns true if the data can be directly loaded.
  42823. * @param data string containing the file data
  42824. * @returns if the data can be loaded directly
  42825. */
  42826. canDirectLoad?(data: string): boolean;
  42827. /**
  42828. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  42829. * @param scene scene loading this data
  42830. * @param data string containing the data
  42831. * @returns data to pass to the plugin
  42832. */
  42833. directLoad?(scene: Scene, data: string): any;
  42834. /**
  42835. * The callback that allows custom handling of the root url based on the response url.
  42836. * @param rootUrl the original root url
  42837. * @param responseURL the response url if available
  42838. * @returns the new root url
  42839. */
  42840. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  42841. }
  42842. /**
  42843. * Interface used to define a SceneLoader plugin
  42844. */
  42845. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  42846. /**
  42847. * Import meshes into a scene.
  42848. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42849. * @param scene The scene to import into
  42850. * @param data The data to import
  42851. * @param rootUrl The root url for scene and resources
  42852. * @param meshes The meshes array to import into
  42853. * @param particleSystems The particle systems array to import into
  42854. * @param skeletons The skeletons array to import into
  42855. * @param onError The callback when import fails
  42856. * @returns True if successful or false otherwise
  42857. */
  42858. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  42859. /**
  42860. * Load into a scene.
  42861. * @param scene The scene to load into
  42862. * @param data The data to import
  42863. * @param rootUrl The root url for scene and resources
  42864. * @param onError The callback when import fails
  42865. * @returns True if successful or false otherwise
  42866. */
  42867. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  42868. /**
  42869. * Load into an asset container.
  42870. * @param scene The scene to load into
  42871. * @param data The data to import
  42872. * @param rootUrl The root url for scene and resources
  42873. * @param onError The callback when import fails
  42874. * @returns The loaded asset container
  42875. */
  42876. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  42877. }
  42878. /**
  42879. * Interface used to define an async SceneLoader plugin
  42880. */
  42881. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  42882. /**
  42883. * Import meshes into a scene.
  42884. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42885. * @param scene The scene to import into
  42886. * @param data The data to import
  42887. * @param rootUrl The root url for scene and resources
  42888. * @param onProgress The callback when the load progresses
  42889. * @param fileName Defines the name of the file to load
  42890. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  42891. */
  42892. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  42893. meshes: AbstractMesh[];
  42894. particleSystems: IParticleSystem[];
  42895. skeletons: Skeleton[];
  42896. animationGroups: AnimationGroup[];
  42897. }>;
  42898. /**
  42899. * Load into a scene.
  42900. * @param scene The scene to load into
  42901. * @param data The data to import
  42902. * @param rootUrl The root url for scene and resources
  42903. * @param onProgress The callback when the load progresses
  42904. * @param fileName Defines the name of the file to load
  42905. * @returns Nothing
  42906. */
  42907. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  42908. /**
  42909. * Load into an asset container.
  42910. * @param scene The scene to load into
  42911. * @param data The data to import
  42912. * @param rootUrl The root url for scene and resources
  42913. * @param onProgress The callback when the load progresses
  42914. * @param fileName Defines the name of the file to load
  42915. * @returns The loaded asset container
  42916. */
  42917. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  42918. }
  42919. /**
  42920. * Mode that determines how to handle old animation groups before loading new ones.
  42921. */
  42922. export enum SceneLoaderAnimationGroupLoadingMode {
  42923. /**
  42924. * Reset all old animations to initial state then dispose them.
  42925. */
  42926. Clean = 0,
  42927. /**
  42928. * Stop all old animations.
  42929. */
  42930. Stop = 1,
  42931. /**
  42932. * Restart old animations from first frame.
  42933. */
  42934. Sync = 2,
  42935. /**
  42936. * Old animations remains untouched.
  42937. */
  42938. NoSync = 3
  42939. }
  42940. /**
  42941. * Class used to load scene from various file formats using registered plugins
  42942. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  42943. */
  42944. export class SceneLoader {
  42945. /**
  42946. * No logging while loading
  42947. */
  42948. static readonly NO_LOGGING: number;
  42949. /**
  42950. * Minimal logging while loading
  42951. */
  42952. static readonly MINIMAL_LOGGING: number;
  42953. /**
  42954. * Summary logging while loading
  42955. */
  42956. static readonly SUMMARY_LOGGING: number;
  42957. /**
  42958. * Detailled logging while loading
  42959. */
  42960. static readonly DETAILED_LOGGING: number;
  42961. /**
  42962. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  42963. */
  42964. static get ForceFullSceneLoadingForIncremental(): boolean;
  42965. static set ForceFullSceneLoadingForIncremental(value: boolean);
  42966. /**
  42967. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  42968. */
  42969. static get ShowLoadingScreen(): boolean;
  42970. static set ShowLoadingScreen(value: boolean);
  42971. /**
  42972. * Defines the current logging level (while loading the scene)
  42973. * @ignorenaming
  42974. */
  42975. static get loggingLevel(): number;
  42976. static set loggingLevel(value: number);
  42977. /**
  42978. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  42979. */
  42980. static get CleanBoneMatrixWeights(): boolean;
  42981. static set CleanBoneMatrixWeights(value: boolean);
  42982. /**
  42983. * Event raised when a plugin is used to load a scene
  42984. */
  42985. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  42986. private static _registeredPlugins;
  42987. private static _getDefaultPlugin;
  42988. private static _getPluginForExtension;
  42989. private static _getPluginForDirectLoad;
  42990. private static _getPluginForFilename;
  42991. private static _getDirectLoad;
  42992. private static _loadData;
  42993. private static _getFileInfo;
  42994. /**
  42995. * Gets a plugin that can load the given extension
  42996. * @param extension defines the extension to load
  42997. * @returns a plugin or null if none works
  42998. */
  42999. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43000. /**
  43001. * Gets a boolean indicating that the given extension can be loaded
  43002. * @param extension defines the extension to load
  43003. * @returns true if the extension is supported
  43004. */
  43005. static IsPluginForExtensionAvailable(extension: string): boolean;
  43006. /**
  43007. * Adds a new plugin to the list of registered plugins
  43008. * @param plugin defines the plugin to add
  43009. */
  43010. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43011. /**
  43012. * Import meshes into a scene
  43013. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43014. * @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)
  43015. * @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)
  43016. * @param scene the instance of BABYLON.Scene to append to
  43017. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43018. * @param onProgress a callback with a progress event for each file being loaded
  43019. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43020. * @param pluginExtension the extension used to determine the plugin
  43021. * @returns The loaded plugin
  43022. */
  43023. 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>;
  43024. /**
  43025. * Import meshes into a scene
  43026. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43027. * @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)
  43028. * @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)
  43029. * @param scene the instance of BABYLON.Scene to append to
  43030. * @param onProgress a callback with a progress event for each file being loaded
  43031. * @param pluginExtension the extension used to determine the plugin
  43032. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43033. */
  43034. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43035. meshes: AbstractMesh[];
  43036. particleSystems: IParticleSystem[];
  43037. skeletons: Skeleton[];
  43038. animationGroups: AnimationGroup[];
  43039. }>;
  43040. /**
  43041. * Load a scene
  43042. * @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)
  43043. * @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)
  43044. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43045. * @param onSuccess a callback with the scene when import succeeds
  43046. * @param onProgress a callback with a progress event for each file being loaded
  43047. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43048. * @param pluginExtension the extension used to determine the plugin
  43049. * @returns The loaded plugin
  43050. */
  43051. 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>;
  43052. /**
  43053. * Load a scene
  43054. * @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)
  43055. * @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)
  43056. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43057. * @param onProgress a callback with a progress event for each file being loaded
  43058. * @param pluginExtension the extension used to determine the plugin
  43059. * @returns The loaded scene
  43060. */
  43061. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43062. /**
  43063. * Append a scene
  43064. * @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)
  43065. * @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)
  43066. * @param scene is the instance of BABYLON.Scene to append to
  43067. * @param onSuccess a callback with the scene when import succeeds
  43068. * @param onProgress a callback with a progress event for each file being loaded
  43069. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43070. * @param pluginExtension the extension used to determine the plugin
  43071. * @returns The loaded plugin
  43072. */
  43073. 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>;
  43074. /**
  43075. * Append a scene
  43076. * @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)
  43077. * @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)
  43078. * @param scene is the instance of BABYLON.Scene to append to
  43079. * @param onProgress a callback with a progress event for each file being loaded
  43080. * @param pluginExtension the extension used to determine the plugin
  43081. * @returns The given scene
  43082. */
  43083. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43084. /**
  43085. * Load a scene into an asset container
  43086. * @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)
  43087. * @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)
  43088. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43089. * @param onSuccess a callback with the scene when import succeeds
  43090. * @param onProgress a callback with a progress event for each file being loaded
  43091. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43092. * @param pluginExtension the extension used to determine the plugin
  43093. * @returns The loaded plugin
  43094. */
  43095. 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>;
  43096. /**
  43097. * Load a scene into an asset container
  43098. * @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)
  43099. * @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)
  43100. * @param scene is the instance of Scene to append to
  43101. * @param onProgress a callback with a progress event for each file being loaded
  43102. * @param pluginExtension the extension used to determine the plugin
  43103. * @returns The loaded asset container
  43104. */
  43105. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43106. /**
  43107. * Import animations from a file into a scene
  43108. * @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)
  43109. * @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)
  43110. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43111. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  43112. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  43113. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  43114. * @param onSuccess a callback with the scene when import succeeds
  43115. * @param onProgress a callback with a progress event for each file being loaded
  43116. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43117. */
  43118. 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;
  43119. /**
  43120. * Import animations from a file into a scene
  43121. * @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)
  43122. * @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)
  43123. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43124. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  43125. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  43126. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  43127. * @param onSuccess a callback with the scene when import succeeds
  43128. * @param onProgress a callback with a progress event for each file being loaded
  43129. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43130. * @returns the updated scene with imported animations
  43131. */
  43132. 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>;
  43133. }
  43134. }
  43135. declare module BABYLON {
  43136. /**
  43137. * Generic Controller
  43138. */
  43139. export class GenericController extends WebVRController {
  43140. /**
  43141. * Base Url for the controller model.
  43142. */
  43143. static readonly MODEL_BASE_URL: string;
  43144. /**
  43145. * File name for the controller model.
  43146. */
  43147. static readonly MODEL_FILENAME: string;
  43148. /**
  43149. * Creates a new GenericController from a gamepad
  43150. * @param vrGamepad the gamepad that the controller should be created from
  43151. */
  43152. constructor(vrGamepad: any);
  43153. /**
  43154. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43155. * @param scene scene in which to add meshes
  43156. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43157. */
  43158. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43159. /**
  43160. * Called once for each button that changed state since the last frame
  43161. * @param buttonIdx Which button index changed
  43162. * @param state New state of the button
  43163. * @param changes Which properties on the state changed since last frame
  43164. */
  43165. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43166. }
  43167. }
  43168. declare module BABYLON {
  43169. /**
  43170. * Defines the WindowsMotionController object that the state of the windows motion controller
  43171. */
  43172. export class WindowsMotionController extends WebVRController {
  43173. /**
  43174. * The base url used to load the left and right controller models
  43175. */
  43176. static MODEL_BASE_URL: string;
  43177. /**
  43178. * The name of the left controller model file
  43179. */
  43180. static MODEL_LEFT_FILENAME: string;
  43181. /**
  43182. * The name of the right controller model file
  43183. */
  43184. static MODEL_RIGHT_FILENAME: string;
  43185. /**
  43186. * The controller name prefix for this controller type
  43187. */
  43188. static readonly GAMEPAD_ID_PREFIX: string;
  43189. /**
  43190. * The controller id pattern for this controller type
  43191. */
  43192. private static readonly GAMEPAD_ID_PATTERN;
  43193. private _loadedMeshInfo;
  43194. protected readonly _mapping: {
  43195. buttons: string[];
  43196. buttonMeshNames: {
  43197. 'trigger': string;
  43198. 'menu': string;
  43199. 'grip': string;
  43200. 'thumbstick': string;
  43201. 'trackpad': string;
  43202. };
  43203. buttonObservableNames: {
  43204. 'trigger': string;
  43205. 'menu': string;
  43206. 'grip': string;
  43207. 'thumbstick': string;
  43208. 'trackpad': string;
  43209. };
  43210. axisMeshNames: string[];
  43211. pointingPoseMeshName: string;
  43212. };
  43213. /**
  43214. * Fired when the trackpad on this controller is clicked
  43215. */
  43216. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  43217. /**
  43218. * Fired when the trackpad on this controller is modified
  43219. */
  43220. onTrackpadValuesChangedObservable: Observable<StickValues>;
  43221. /**
  43222. * The current x and y values of this controller's trackpad
  43223. */
  43224. trackpad: StickValues;
  43225. /**
  43226. * Creates a new WindowsMotionController from a gamepad
  43227. * @param vrGamepad the gamepad that the controller should be created from
  43228. */
  43229. constructor(vrGamepad: any);
  43230. /**
  43231. * Fired when the trigger on this controller is modified
  43232. */
  43233. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  43234. /**
  43235. * Fired when the menu button on this controller is modified
  43236. */
  43237. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  43238. /**
  43239. * Fired when the grip button on this controller is modified
  43240. */
  43241. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  43242. /**
  43243. * Fired when the thumbstick button on this controller is modified
  43244. */
  43245. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  43246. /**
  43247. * Fired when the touchpad button on this controller is modified
  43248. */
  43249. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  43250. /**
  43251. * Fired when the touchpad values on this controller are modified
  43252. */
  43253. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  43254. protected _updateTrackpad(): void;
  43255. /**
  43256. * Called once per frame by the engine.
  43257. */
  43258. update(): void;
  43259. /**
  43260. * Called once for each button that changed state since the last frame
  43261. * @param buttonIdx Which button index changed
  43262. * @param state New state of the button
  43263. * @param changes Which properties on the state changed since last frame
  43264. */
  43265. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43266. /**
  43267. * Moves the buttons on the controller mesh based on their current state
  43268. * @param buttonName the name of the button to move
  43269. * @param buttonValue the value of the button which determines the buttons new position
  43270. */
  43271. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  43272. /**
  43273. * Moves the axis on the controller mesh based on its current state
  43274. * @param axis the index of the axis
  43275. * @param axisValue the value of the axis which determines the meshes new position
  43276. * @hidden
  43277. */
  43278. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  43279. /**
  43280. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43281. * @param scene scene in which to add meshes
  43282. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43283. */
  43284. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  43285. /**
  43286. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  43287. * can be transformed by button presses and axes values, based on this._mapping.
  43288. *
  43289. * @param scene scene in which the meshes exist
  43290. * @param meshes list of meshes that make up the controller model to process
  43291. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  43292. */
  43293. private processModel;
  43294. private createMeshInfo;
  43295. /**
  43296. * Gets the ray of the controller in the direction the controller is pointing
  43297. * @param length the length the resulting ray should be
  43298. * @returns a ray in the direction the controller is pointing
  43299. */
  43300. getForwardRay(length?: number): Ray;
  43301. /**
  43302. * Disposes of the controller
  43303. */
  43304. dispose(): void;
  43305. }
  43306. /**
  43307. * This class represents a new windows motion controller in XR.
  43308. */
  43309. export class XRWindowsMotionController extends WindowsMotionController {
  43310. /**
  43311. * Changing the original WIndowsMotionController mapping to fir the new mapping
  43312. */
  43313. protected readonly _mapping: {
  43314. buttons: string[];
  43315. buttonMeshNames: {
  43316. 'trigger': string;
  43317. 'menu': string;
  43318. 'grip': string;
  43319. 'thumbstick': string;
  43320. 'trackpad': string;
  43321. };
  43322. buttonObservableNames: {
  43323. 'trigger': string;
  43324. 'menu': string;
  43325. 'grip': string;
  43326. 'thumbstick': string;
  43327. 'trackpad': string;
  43328. };
  43329. axisMeshNames: string[];
  43330. pointingPoseMeshName: string;
  43331. };
  43332. /**
  43333. * Construct a new XR-Based windows motion controller
  43334. *
  43335. * @param gamepadInfo the gamepad object from the browser
  43336. */
  43337. constructor(gamepadInfo: any);
  43338. /**
  43339. * holds the thumbstick values (X,Y)
  43340. */
  43341. thumbstickValues: StickValues;
  43342. /**
  43343. * Fired when the thumbstick on this controller is clicked
  43344. */
  43345. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  43346. /**
  43347. * Fired when the thumbstick on this controller is modified
  43348. */
  43349. onThumbstickValuesChangedObservable: Observable<StickValues>;
  43350. /**
  43351. * Fired when the touchpad button on this controller is modified
  43352. */
  43353. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  43354. /**
  43355. * Fired when the touchpad values on this controller are modified
  43356. */
  43357. onTrackpadValuesChangedObservable: Observable<StickValues>;
  43358. /**
  43359. * Fired when the thumbstick button on this controller is modified
  43360. * here to prevent breaking changes
  43361. */
  43362. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  43363. /**
  43364. * updating the thumbstick(!) and not the trackpad.
  43365. * This is named this way due to the difference between WebVR and XR and to avoid
  43366. * changing the parent class.
  43367. */
  43368. protected _updateTrackpad(): void;
  43369. /**
  43370. * Disposes the class with joy
  43371. */
  43372. dispose(): void;
  43373. }
  43374. }
  43375. declare module BABYLON {
  43376. /**
  43377. * Oculus Touch Controller
  43378. */
  43379. export class OculusTouchController extends WebVRController {
  43380. /**
  43381. * Base Url for the controller model.
  43382. */
  43383. static MODEL_BASE_URL: string;
  43384. /**
  43385. * File name for the left controller model.
  43386. */
  43387. static MODEL_LEFT_FILENAME: string;
  43388. /**
  43389. * File name for the right controller model.
  43390. */
  43391. static MODEL_RIGHT_FILENAME: string;
  43392. /**
  43393. * Base Url for the Quest controller model.
  43394. */
  43395. static QUEST_MODEL_BASE_URL: string;
  43396. /**
  43397. * @hidden
  43398. * If the controllers are running on a device that needs the updated Quest controller models
  43399. */
  43400. static _IsQuest: boolean;
  43401. /**
  43402. * Fired when the secondary trigger on this controller is modified
  43403. */
  43404. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  43405. /**
  43406. * Fired when the thumb rest on this controller is modified
  43407. */
  43408. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  43409. /**
  43410. * Creates a new OculusTouchController from a gamepad
  43411. * @param vrGamepad the gamepad that the controller should be created from
  43412. */
  43413. constructor(vrGamepad: any);
  43414. /**
  43415. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43416. * @param scene scene in which to add meshes
  43417. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43418. */
  43419. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43420. /**
  43421. * Fired when the A button on this controller is modified
  43422. */
  43423. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  43424. /**
  43425. * Fired when the B button on this controller is modified
  43426. */
  43427. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  43428. /**
  43429. * Fired when the X button on this controller is modified
  43430. */
  43431. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  43432. /**
  43433. * Fired when the Y button on this controller is modified
  43434. */
  43435. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  43436. /**
  43437. * Called once for each button that changed state since the last frame
  43438. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  43439. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  43440. * 2) secondary trigger (same)
  43441. * 3) A (right) X (left), touch, pressed = value
  43442. * 4) B / Y
  43443. * 5) thumb rest
  43444. * @param buttonIdx Which button index changed
  43445. * @param state New state of the button
  43446. * @param changes Which properties on the state changed since last frame
  43447. */
  43448. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43449. }
  43450. }
  43451. declare module BABYLON {
  43452. /**
  43453. * Vive Controller
  43454. */
  43455. export class ViveController extends WebVRController {
  43456. /**
  43457. * Base Url for the controller model.
  43458. */
  43459. static MODEL_BASE_URL: string;
  43460. /**
  43461. * File name for the controller model.
  43462. */
  43463. static MODEL_FILENAME: string;
  43464. /**
  43465. * Creates a new ViveController from a gamepad
  43466. * @param vrGamepad the gamepad that the controller should be created from
  43467. */
  43468. constructor(vrGamepad: any);
  43469. /**
  43470. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43471. * @param scene scene in which to add meshes
  43472. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43473. */
  43474. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43475. /**
  43476. * Fired when the left button on this controller is modified
  43477. */
  43478. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  43479. /**
  43480. * Fired when the right button on this controller is modified
  43481. */
  43482. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  43483. /**
  43484. * Fired when the menu button on this controller is modified
  43485. */
  43486. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  43487. /**
  43488. * Called once for each button that changed state since the last frame
  43489. * Vive mapping:
  43490. * 0: touchpad
  43491. * 1: trigger
  43492. * 2: left AND right buttons
  43493. * 3: menu button
  43494. * @param buttonIdx Which button index changed
  43495. * @param state New state of the button
  43496. * @param changes Which properties on the state changed since last frame
  43497. */
  43498. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43499. }
  43500. }
  43501. declare module BABYLON {
  43502. /**
  43503. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  43504. */
  43505. export class WebXRControllerModelLoader {
  43506. /**
  43507. * an observable that triggers when a new model (the mesh itself) was initialized.
  43508. * To know when the mesh was loaded use the controller's own modelLoaded() method
  43509. */
  43510. onControllerModelLoaded: Observable<WebXRController>;
  43511. /**
  43512. * Creates the WebXRControllerModelLoader
  43513. * @param input xr input that creates the controllers
  43514. */
  43515. constructor(input: WebXRInput);
  43516. }
  43517. }
  43518. declare module BABYLON {
  43519. /**
  43520. * Handles pointer input automatically for the pointer of XR controllers
  43521. */
  43522. export class WebXRControllerPointerSelection {
  43523. private static _idCounter;
  43524. private _tmpRay;
  43525. /**
  43526. * Creates a WebXRControllerPointerSelection
  43527. * @param input input manager to setup pointer selection
  43528. */
  43529. constructor(input: WebXRInput);
  43530. private _convertNormalToDirectionOfRay;
  43531. private _updatePointerDistance;
  43532. }
  43533. }
  43534. declare module BABYLON {
  43535. /**
  43536. * Enables teleportation
  43537. */
  43538. export class WebXRControllerTeleportation {
  43539. private _teleportationFillColor;
  43540. private _teleportationBorderColor;
  43541. private _tmpRay;
  43542. private _tmpVector;
  43543. /**
  43544. * when set to true (default) teleportation will wait for thumbstick changes.
  43545. * When set to false teleportation will be disabled.
  43546. *
  43547. * If set to false while teleporting results can be unexpected.
  43548. */
  43549. enabled: boolean;
  43550. /**
  43551. * Creates a WebXRControllerTeleportation
  43552. * @param input input manager to add teleportation to
  43553. * @param floorMeshes floormeshes which can be teleported to
  43554. */
  43555. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  43556. }
  43557. }
  43558. declare module BABYLON {
  43559. /**
  43560. * Button which can be used to enter a different mode of XR
  43561. */
  43562. export class WebXREnterExitUIButton {
  43563. /** button element */
  43564. element: HTMLElement;
  43565. /** XR initialization options for the button */
  43566. sessionMode: XRSessionMode;
  43567. /** Reference space type */
  43568. referenceSpaceType: XRReferenceSpaceType;
  43569. /**
  43570. * Creates a WebXREnterExitUIButton
  43571. * @param element button element
  43572. * @param sessionMode XR initialization session mode
  43573. * @param referenceSpaceType the type of reference space to be used
  43574. */
  43575. constructor(
  43576. /** button element */
  43577. element: HTMLElement,
  43578. /** XR initialization options for the button */
  43579. sessionMode: XRSessionMode,
  43580. /** Reference space type */
  43581. referenceSpaceType: XRReferenceSpaceType);
  43582. /**
  43583. * Overwritable function which can be used to update the button's visuals when the state changes
  43584. * @param activeButton the current active button in the UI
  43585. */
  43586. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  43587. }
  43588. /**
  43589. * Options to create the webXR UI
  43590. */
  43591. export class WebXREnterExitUIOptions {
  43592. /**
  43593. * Context to enter xr with
  43594. */
  43595. renderTarget?: Nullable<WebXRRenderTarget>;
  43596. /**
  43597. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  43598. */
  43599. customButtons?: Array<WebXREnterExitUIButton>;
  43600. /**
  43601. * A session mode to use when creating the default button.
  43602. * Default is immersive-vr
  43603. */
  43604. sessionMode?: XRSessionMode;
  43605. /**
  43606. * A reference space type to use when creating the default button.
  43607. * Default is local-floor
  43608. */
  43609. referenceSpaceType?: XRReferenceSpaceType;
  43610. }
  43611. /**
  43612. * UI to allow the user to enter/exit XR mode
  43613. */
  43614. export class WebXREnterExitUI implements IDisposable {
  43615. private scene;
  43616. /** version of the options passed to this UI */
  43617. options: WebXREnterExitUIOptions;
  43618. private _overlay;
  43619. private _buttons;
  43620. private _activeButton;
  43621. /**
  43622. * Fired every time the active button is changed.
  43623. *
  43624. * When xr is entered via a button that launches xr that button will be the callback parameter
  43625. *
  43626. * When exiting xr the callback parameter will be null)
  43627. */
  43628. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  43629. /**
  43630. * Creates UI to allow the user to enter/exit XR mode
  43631. * @param scene the scene to add the ui to
  43632. * @param helper the xr experience helper to enter/exit xr with
  43633. * @param options options to configure the UI
  43634. * @returns the created ui
  43635. */
  43636. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  43637. /**
  43638. *
  43639. * @param scene babylon scene object to use
  43640. * @param options (read-only) version of the options passed to this UI
  43641. */
  43642. private constructor();
  43643. private _updateButtons;
  43644. /**
  43645. * Disposes of the object
  43646. */
  43647. dispose(): void;
  43648. }
  43649. }
  43650. declare module BABYLON {
  43651. /**
  43652. * Options for the default xr helper
  43653. */
  43654. export class WebXRDefaultExperienceOptions {
  43655. /**
  43656. * Floor meshes that should be used for teleporting
  43657. */
  43658. floorMeshes: Array<AbstractMesh>;
  43659. /**
  43660. * Enable or disable default UI to enter XR
  43661. */
  43662. disableDefaultUI?: boolean;
  43663. /**
  43664. * optional configuration for the output canvas
  43665. */
  43666. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  43667. /**
  43668. * optional UI options. This can be used among other to change session mode and reference space type
  43669. */
  43670. uiOptions?: WebXREnterExitUIOptions;
  43671. }
  43672. /**
  43673. * Default experience which provides a similar setup to the previous webVRExperience
  43674. */
  43675. export class WebXRDefaultExperience {
  43676. /**
  43677. * Base experience
  43678. */
  43679. baseExperience: WebXRExperienceHelper;
  43680. /**
  43681. * Input experience extension
  43682. */
  43683. input: WebXRInput;
  43684. /**
  43685. * Loads the controller models
  43686. */
  43687. controllerModelLoader: WebXRControllerModelLoader;
  43688. /**
  43689. * Enables laser pointer and selection
  43690. */
  43691. pointerSelection: WebXRControllerPointerSelection;
  43692. /**
  43693. * Enables teleportation
  43694. */
  43695. teleportation: WebXRControllerTeleportation;
  43696. /**
  43697. * Enables ui for entering/exiting xr
  43698. */
  43699. enterExitUI: WebXREnterExitUI;
  43700. /**
  43701. * Default target xr should render to
  43702. */
  43703. renderTarget: WebXRRenderTarget;
  43704. /**
  43705. * Creates the default xr experience
  43706. * @param scene scene
  43707. * @param options options for basic configuration
  43708. * @returns resulting WebXRDefaultExperience
  43709. */
  43710. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  43711. private constructor();
  43712. /**
  43713. * DIsposes of the experience helper
  43714. */
  43715. dispose(): void;
  43716. }
  43717. }
  43718. declare module BABYLON {
  43719. /**
  43720. * Options to modify the vr teleportation behavior.
  43721. */
  43722. export interface VRTeleportationOptions {
  43723. /**
  43724. * The name of the mesh which should be used as the teleportation floor. (default: null)
  43725. */
  43726. floorMeshName?: string;
  43727. /**
  43728. * A list of meshes to be used as the teleportation floor. (default: empty)
  43729. */
  43730. floorMeshes?: Mesh[];
  43731. /**
  43732. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  43733. */
  43734. teleportationMode?: number;
  43735. /**
  43736. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  43737. */
  43738. teleportationTime?: number;
  43739. /**
  43740. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  43741. */
  43742. teleportationSpeed?: number;
  43743. /**
  43744. * The easing function used in the animation or null for Linear. (default CircleEase)
  43745. */
  43746. easingFunction?: EasingFunction;
  43747. }
  43748. /**
  43749. * Options to modify the vr experience helper's behavior.
  43750. */
  43751. export interface VRExperienceHelperOptions extends WebVROptions {
  43752. /**
  43753. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  43754. */
  43755. createDeviceOrientationCamera?: boolean;
  43756. /**
  43757. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  43758. */
  43759. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  43760. /**
  43761. * Uses the main button on the controller to toggle the laser casted. (default: true)
  43762. */
  43763. laserToggle?: boolean;
  43764. /**
  43765. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  43766. */
  43767. floorMeshes?: Mesh[];
  43768. /**
  43769. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  43770. */
  43771. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  43772. /**
  43773. * Defines if WebXR should be used instead of WebVR (if available)
  43774. */
  43775. useXR?: boolean;
  43776. }
  43777. /**
  43778. * Event containing information after VR has been entered
  43779. */
  43780. export class OnAfterEnteringVRObservableEvent {
  43781. /**
  43782. * If entering vr was successful
  43783. */
  43784. success: boolean;
  43785. }
  43786. /**
  43787. * Helps to quickly add VR support to an existing scene.
  43788. * See http://doc.babylonjs.com/how_to/webvr_helper
  43789. */
  43790. export class VRExperienceHelper {
  43791. /** Options to modify the vr experience helper's behavior. */
  43792. webVROptions: VRExperienceHelperOptions;
  43793. private _scene;
  43794. private _position;
  43795. private _btnVR;
  43796. private _btnVRDisplayed;
  43797. private _webVRsupported;
  43798. private _webVRready;
  43799. private _webVRrequesting;
  43800. private _webVRpresenting;
  43801. private _hasEnteredVR;
  43802. private _fullscreenVRpresenting;
  43803. private _inputElement;
  43804. private _webVRCamera;
  43805. private _vrDeviceOrientationCamera;
  43806. private _deviceOrientationCamera;
  43807. private _existingCamera;
  43808. private _onKeyDown;
  43809. private _onVrDisplayPresentChange;
  43810. private _onVRDisplayChanged;
  43811. private _onVRRequestPresentStart;
  43812. private _onVRRequestPresentComplete;
  43813. /**
  43814. * 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)
  43815. */
  43816. enableGazeEvenWhenNoPointerLock: boolean;
  43817. /**
  43818. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  43819. */
  43820. exitVROnDoubleTap: boolean;
  43821. /**
  43822. * Observable raised right before entering VR.
  43823. */
  43824. onEnteringVRObservable: Observable<VRExperienceHelper>;
  43825. /**
  43826. * Observable raised when entering VR has completed.
  43827. */
  43828. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  43829. /**
  43830. * Observable raised when exiting VR.
  43831. */
  43832. onExitingVRObservable: Observable<VRExperienceHelper>;
  43833. /**
  43834. * Observable raised when controller mesh is loaded.
  43835. */
  43836. onControllerMeshLoadedObservable: Observable<WebVRController>;
  43837. /** Return this.onEnteringVRObservable
  43838. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  43839. */
  43840. get onEnteringVR(): Observable<VRExperienceHelper>;
  43841. /** Return this.onExitingVRObservable
  43842. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  43843. */
  43844. get onExitingVR(): Observable<VRExperienceHelper>;
  43845. /** Return this.onControllerMeshLoadedObservable
  43846. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  43847. */
  43848. get onControllerMeshLoaded(): Observable<WebVRController>;
  43849. private _rayLength;
  43850. private _useCustomVRButton;
  43851. private _teleportationRequested;
  43852. private _teleportActive;
  43853. private _floorMeshName;
  43854. private _floorMeshesCollection;
  43855. private _teleportationMode;
  43856. private _teleportationTime;
  43857. private _teleportationSpeed;
  43858. private _teleportationEasing;
  43859. private _rotationAllowed;
  43860. private _teleportBackwardsVector;
  43861. private _teleportationTarget;
  43862. private _isDefaultTeleportationTarget;
  43863. private _postProcessMove;
  43864. private _teleportationFillColor;
  43865. private _teleportationBorderColor;
  43866. private _rotationAngle;
  43867. private _haloCenter;
  43868. private _cameraGazer;
  43869. private _padSensibilityUp;
  43870. private _padSensibilityDown;
  43871. private _leftController;
  43872. private _rightController;
  43873. /**
  43874. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  43875. */
  43876. onNewMeshSelected: Observable<AbstractMesh>;
  43877. /**
  43878. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  43879. * This observable will provide the mesh and the controller used to select the mesh
  43880. */
  43881. onMeshSelectedWithController: Observable<{
  43882. mesh: AbstractMesh;
  43883. controller: WebVRController;
  43884. }>;
  43885. /**
  43886. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  43887. */
  43888. onNewMeshPicked: Observable<PickingInfo>;
  43889. private _circleEase;
  43890. /**
  43891. * Observable raised before camera teleportation
  43892. */
  43893. onBeforeCameraTeleport: Observable<Vector3>;
  43894. /**
  43895. * Observable raised after camera teleportation
  43896. */
  43897. onAfterCameraTeleport: Observable<Vector3>;
  43898. /**
  43899. * Observable raised when current selected mesh gets unselected
  43900. */
  43901. onSelectedMeshUnselected: Observable<AbstractMesh>;
  43902. private _raySelectionPredicate;
  43903. /**
  43904. * To be optionaly changed by user to define custom ray selection
  43905. */
  43906. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  43907. /**
  43908. * To be optionaly changed by user to define custom selection logic (after ray selection)
  43909. */
  43910. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  43911. /**
  43912. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  43913. */
  43914. teleportationEnabled: boolean;
  43915. private _defaultHeight;
  43916. private _teleportationInitialized;
  43917. private _interactionsEnabled;
  43918. private _interactionsRequested;
  43919. private _displayGaze;
  43920. private _displayLaserPointer;
  43921. /**
  43922. * The mesh used to display where the user is going to teleport.
  43923. */
  43924. get teleportationTarget(): Mesh;
  43925. /**
  43926. * Sets the mesh to be used to display where the user is going to teleport.
  43927. */
  43928. set teleportationTarget(value: Mesh);
  43929. /**
  43930. * 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
  43931. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  43932. * See http://doc.babylonjs.com/resources/baking_transformations
  43933. */
  43934. get gazeTrackerMesh(): Mesh;
  43935. set gazeTrackerMesh(value: Mesh);
  43936. /**
  43937. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  43938. */
  43939. updateGazeTrackerScale: boolean;
  43940. /**
  43941. * If the gaze trackers color should be updated when selecting meshes
  43942. */
  43943. updateGazeTrackerColor: boolean;
  43944. /**
  43945. * If the controller laser color should be updated when selecting meshes
  43946. */
  43947. updateControllerLaserColor: boolean;
  43948. /**
  43949. * The gaze tracking mesh corresponding to the left controller
  43950. */
  43951. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  43952. /**
  43953. * The gaze tracking mesh corresponding to the right controller
  43954. */
  43955. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  43956. /**
  43957. * If the ray of the gaze should be displayed.
  43958. */
  43959. get displayGaze(): boolean;
  43960. /**
  43961. * Sets if the ray of the gaze should be displayed.
  43962. */
  43963. set displayGaze(value: boolean);
  43964. /**
  43965. * If the ray of the LaserPointer should be displayed.
  43966. */
  43967. get displayLaserPointer(): boolean;
  43968. /**
  43969. * Sets if the ray of the LaserPointer should be displayed.
  43970. */
  43971. set displayLaserPointer(value: boolean);
  43972. /**
  43973. * The deviceOrientationCamera used as the camera when not in VR.
  43974. */
  43975. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  43976. /**
  43977. * Based on the current WebVR support, returns the current VR camera used.
  43978. */
  43979. get currentVRCamera(): Nullable<Camera>;
  43980. /**
  43981. * The webVRCamera which is used when in VR.
  43982. */
  43983. get webVRCamera(): WebVRFreeCamera;
  43984. /**
  43985. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  43986. */
  43987. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  43988. /**
  43989. * The html button that is used to trigger entering into VR.
  43990. */
  43991. get vrButton(): Nullable<HTMLButtonElement>;
  43992. private get _teleportationRequestInitiated();
  43993. /**
  43994. * Defines wether or not Pointer lock should be requested when switching to
  43995. * full screen.
  43996. */
  43997. requestPointerLockOnFullScreen: boolean;
  43998. /**
  43999. * If asking to force XR, this will be populated with the default xr experience
  44000. */
  44001. xr: WebXRDefaultExperience;
  44002. /**
  44003. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  44004. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  44005. */
  44006. xrTestDone: boolean;
  44007. /**
  44008. * Instantiates a VRExperienceHelper.
  44009. * Helps to quickly add VR support to an existing scene.
  44010. * @param scene The scene the VRExperienceHelper belongs to.
  44011. * @param webVROptions Options to modify the vr experience helper's behavior.
  44012. */
  44013. constructor(scene: Scene,
  44014. /** Options to modify the vr experience helper's behavior. */
  44015. webVROptions?: VRExperienceHelperOptions);
  44016. private completeVRInit;
  44017. private _onDefaultMeshLoaded;
  44018. private _onResize;
  44019. private _onFullscreenChange;
  44020. /**
  44021. * Gets a value indicating if we are currently in VR mode.
  44022. */
  44023. get isInVRMode(): boolean;
  44024. private onVrDisplayPresentChange;
  44025. private onVRDisplayChanged;
  44026. private moveButtonToBottomRight;
  44027. private displayVRButton;
  44028. private updateButtonVisibility;
  44029. private _cachedAngularSensibility;
  44030. /**
  44031. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  44032. * Otherwise, will use the fullscreen API.
  44033. */
  44034. enterVR(): void;
  44035. /**
  44036. * Attempt to exit VR, or fullscreen.
  44037. */
  44038. exitVR(): void;
  44039. /**
  44040. * The position of the vr experience helper.
  44041. */
  44042. get position(): Vector3;
  44043. /**
  44044. * Sets the position of the vr experience helper.
  44045. */
  44046. set position(value: Vector3);
  44047. /**
  44048. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  44049. */
  44050. enableInteractions(): void;
  44051. private get _noControllerIsActive();
  44052. private beforeRender;
  44053. private _isTeleportationFloor;
  44054. /**
  44055. * Adds a floor mesh to be used for teleportation.
  44056. * @param floorMesh the mesh to be used for teleportation.
  44057. */
  44058. addFloorMesh(floorMesh: Mesh): void;
  44059. /**
  44060. * Removes a floor mesh from being used for teleportation.
  44061. * @param floorMesh the mesh to be removed.
  44062. */
  44063. removeFloorMesh(floorMesh: Mesh): void;
  44064. /**
  44065. * Enables interactions and teleportation using the VR controllers and gaze.
  44066. * @param vrTeleportationOptions options to modify teleportation behavior.
  44067. */
  44068. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  44069. private _onNewGamepadConnected;
  44070. private _tryEnableInteractionOnController;
  44071. private _onNewGamepadDisconnected;
  44072. private _enableInteractionOnController;
  44073. private _checkTeleportWithRay;
  44074. private _checkRotate;
  44075. private _checkTeleportBackwards;
  44076. private _enableTeleportationOnController;
  44077. private _createTeleportationCircles;
  44078. private _displayTeleportationTarget;
  44079. private _hideTeleportationTarget;
  44080. private _rotateCamera;
  44081. private _moveTeleportationSelectorTo;
  44082. private _workingVector;
  44083. private _workingQuaternion;
  44084. private _workingMatrix;
  44085. /**
  44086. * Time Constant Teleportation Mode
  44087. */
  44088. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  44089. /**
  44090. * Speed Constant Teleportation Mode
  44091. */
  44092. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  44093. /**
  44094. * Teleports the users feet to the desired location
  44095. * @param location The location where the user's feet should be placed
  44096. */
  44097. teleportCamera(location: Vector3): void;
  44098. private _convertNormalToDirectionOfRay;
  44099. private _castRayAndSelectObject;
  44100. private _notifySelectedMeshUnselected;
  44101. /**
  44102. * Sets the color of the laser ray from the vr controllers.
  44103. * @param color new color for the ray.
  44104. */
  44105. changeLaserColor(color: Color3): void;
  44106. /**
  44107. * Sets the color of the ray from the vr headsets gaze.
  44108. * @param color new color for the ray.
  44109. */
  44110. changeGazeColor(color: Color3): void;
  44111. /**
  44112. * Exits VR and disposes of the vr experience helper
  44113. */
  44114. dispose(): void;
  44115. /**
  44116. * Gets the name of the VRExperienceHelper class
  44117. * @returns "VRExperienceHelper"
  44118. */
  44119. getClassName(): string;
  44120. }
  44121. }
  44122. declare module BABYLON {
  44123. /**
  44124. * Options used for hit testing
  44125. */
  44126. export interface IWebXRHitTestOptions {
  44127. /**
  44128. * Only test when user interacted with the scene. Default - hit test every frame
  44129. */
  44130. testOnPointerDownOnly?: boolean;
  44131. /**
  44132. * The node to use to transform the local results to world coordinates
  44133. */
  44134. worldParentNode?: TransformNode;
  44135. }
  44136. /**
  44137. * Interface defining the babylon result of raycasting/hit-test
  44138. */
  44139. export interface IWebXRHitResult {
  44140. /**
  44141. * The native hit test result
  44142. */
  44143. xrHitResult: XRHitResult;
  44144. /**
  44145. * Transformation matrix that can be applied to a node that will put it in the hit point location
  44146. */
  44147. transformationMatrix: Matrix;
  44148. }
  44149. /**
  44150. * The currently-working hit-test module.
  44151. * Hit test (or raycasting) is used to interact with the real world.
  44152. * For further information read here - https://github.com/immersive-web/hit-test
  44153. */
  44154. export class WebXRHitTestLegacy implements IWebXRFeature {
  44155. private _xrSessionManager;
  44156. /**
  44157. * options to use when constructing this feature
  44158. */
  44159. readonly options: IWebXRHitTestOptions;
  44160. /**
  44161. * The module's name
  44162. */
  44163. static readonly Name: string;
  44164. /**
  44165. * The (Babylon) version of this module.
  44166. * This is an integer representing the implementation version.
  44167. * This number does not correspond to the webxr specs version
  44168. */
  44169. static readonly Version: number;
  44170. /**
  44171. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  44172. * @param event the (select) event to use to select with
  44173. * @param referenceSpace the reference space to use for this hit test
  44174. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  44175. */
  44176. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  44177. /**
  44178. * execute a hit test with an XR Ray
  44179. *
  44180. * @param xrSession a native xrSession that will execute this hit test
  44181. * @param xrRay the ray (position and direction) to use for raycasting
  44182. * @param referenceSpace native XR reference space to use for the hit-test
  44183. * @param filter filter function that will filter the results
  44184. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  44185. */
  44186. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  44187. /**
  44188. * Triggered when new babylon (transformed) hit test results are available
  44189. */
  44190. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  44191. /**
  44192. * Creates a new instance of the (legacy version) hit test feature
  44193. * @param _xrSessionManager an instance of WebXRSessionManager
  44194. * @param options options to use when constructing this feature
  44195. */
  44196. constructor(_xrSessionManager: WebXRSessionManager,
  44197. /**
  44198. * options to use when constructing this feature
  44199. */
  44200. options?: IWebXRHitTestOptions);
  44201. private _onSelectEnabled;
  44202. private _xrFrameObserver;
  44203. private _attached;
  44204. /**
  44205. * Populated with the last native XR Hit Results
  44206. */
  44207. lastNativeXRHitResults: XRHitResult[];
  44208. /**
  44209. * attach this feature
  44210. * Will usually be called by the features manager
  44211. *
  44212. * @returns true if successful.
  44213. */
  44214. attach(): boolean;
  44215. /**
  44216. * detach this feature.
  44217. * Will usually be called by the features manager
  44218. *
  44219. * @returns true if successful.
  44220. */
  44221. detach(): boolean;
  44222. private _onHitTestResults;
  44223. private _onSelect;
  44224. /**
  44225. * Dispose this feature and all of the resources attached
  44226. */
  44227. dispose(): void;
  44228. }
  44229. }
  44230. declare module BABYLON {
  44231. /**
  44232. * Options used in the plane detector module
  44233. */
  44234. export interface IWebXRPlaneDetectorOptions {
  44235. /**
  44236. * The node to use to transform the local results to world coordinates
  44237. */
  44238. worldParentNode?: TransformNode;
  44239. }
  44240. /**
  44241. * A babylon interface for a webxr plane.
  44242. * A Plane is actually a polygon, built from N points in space
  44243. */
  44244. export interface IWebXRPlane {
  44245. /**
  44246. * a babylon-assigned ID for this polygon
  44247. */
  44248. id: number;
  44249. /**
  44250. * the native xr-plane object
  44251. */
  44252. xrPlane: XRPlane;
  44253. /**
  44254. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  44255. */
  44256. polygonDefinition: Array<Vector3>;
  44257. /**
  44258. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  44259. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  44260. */
  44261. transformationMatrix: Matrix;
  44262. }
  44263. /**
  44264. * The plane detector is used to detect planes in the real world when in AR
  44265. * For more information see https://github.com/immersive-web/real-world-geometry/
  44266. */
  44267. export class WebXRPlaneDetector implements IWebXRFeature {
  44268. private _xrSessionManager;
  44269. private _options;
  44270. /**
  44271. * The module's name
  44272. */
  44273. static readonly Name: string;
  44274. /**
  44275. * The (Babylon) version of this module.
  44276. * This is an integer representing the implementation version.
  44277. * This number does not correspond to the webxr specs version
  44278. */
  44279. static readonly Version: number;
  44280. /**
  44281. * Observers registered here will be executed when a new plane was added to the session
  44282. */
  44283. onPlaneAddedObservable: Observable<IWebXRPlane>;
  44284. /**
  44285. * Observers registered here will be executed when a plane is no longer detected in the session
  44286. */
  44287. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  44288. /**
  44289. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  44290. * This can execute N times every frame
  44291. */
  44292. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  44293. private _enabled;
  44294. private _attached;
  44295. private _detectedPlanes;
  44296. private _lastFrameDetected;
  44297. private _observerTracked;
  44298. /**
  44299. * construct a new Plane Detector
  44300. * @param _xrSessionManager an instance of xr Session manager
  44301. * @param _options configuration to use when constructing this feature
  44302. */
  44303. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  44304. /**
  44305. * attach this feature
  44306. * Will usually be called by the features manager
  44307. *
  44308. * @returns true if successful.
  44309. */
  44310. attach(): boolean;
  44311. /**
  44312. * detach this feature.
  44313. * Will usually be called by the features manager
  44314. *
  44315. * @returns true if successful.
  44316. */
  44317. detach(): boolean;
  44318. /**
  44319. * Dispose this feature and all of the resources attached
  44320. */
  44321. dispose(): void;
  44322. private _updatePlaneWithXRPlane;
  44323. /**
  44324. * avoiding using Array.find for global support.
  44325. * @param xrPlane the plane to find in the array
  44326. */
  44327. private findIndexInPlaneArray;
  44328. }
  44329. }
  44330. declare module BABYLON {
  44331. /**
  44332. * Configuration options of the anchor system
  44333. */
  44334. export interface IWebXRAnchorSystemOptions {
  44335. /**
  44336. * a node that will be used to convert local to world coordinates
  44337. */
  44338. worldParentNode?: TransformNode;
  44339. /**
  44340. * should the anchor system use plane detection.
  44341. * If set to true, the plane-detection feature should be set using setPlaneDetector
  44342. */
  44343. usePlaneDetection?: boolean;
  44344. /**
  44345. * Should a new anchor be added every time a select event is triggered
  44346. */
  44347. addAnchorOnSelect?: boolean;
  44348. }
  44349. /**
  44350. * A babylon container for an XR Anchor
  44351. */
  44352. export interface IWebXRAnchor {
  44353. /**
  44354. * A babylon-assigned ID for this anchor
  44355. */
  44356. id: number;
  44357. /**
  44358. * The native anchor object
  44359. */
  44360. xrAnchor: XRAnchor;
  44361. /**
  44362. * Transformation matrix to apply to an object attached to this anchor
  44363. */
  44364. transformationMatrix: Matrix;
  44365. }
  44366. /**
  44367. * An implementation of the anchor system of WebXR.
  44368. * Note that the current documented implementation is not available in any browser. Future implementations
  44369. * will use the frame to create an anchor and not the session or a detected plane
  44370. * For further information see https://github.com/immersive-web/anchors/
  44371. */
  44372. export class WebXRAnchorSystem implements IWebXRFeature {
  44373. private _xrSessionManager;
  44374. private _options;
  44375. /**
  44376. * The module's name
  44377. */
  44378. static readonly Name: string;
  44379. /**
  44380. * The (Babylon) version of this module.
  44381. * This is an integer representing the implementation version.
  44382. * This number does not correspond to the webxr specs version
  44383. */
  44384. static readonly Version: number;
  44385. /**
  44386. * Observers registered here will be executed when a new anchor was added to the session
  44387. */
  44388. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  44389. /**
  44390. * Observers registered here will be executed when an existing anchor updates
  44391. * This can execute N times every frame
  44392. */
  44393. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  44394. /**
  44395. * Observers registered here will be executed when an anchor was removed from the session
  44396. */
  44397. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  44398. private _planeDetector;
  44399. private _hitTestModule;
  44400. private _enabled;
  44401. private _attached;
  44402. private _trackedAnchors;
  44403. private _lastFrameDetected;
  44404. private _observerTracked;
  44405. /**
  44406. * constructs a new anchor system
  44407. * @param _xrSessionManager an instance of WebXRSessionManager
  44408. * @param _options configuration object for this feature
  44409. */
  44410. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  44411. /**
  44412. * set the plane detector to use in order to create anchors from frames
  44413. * @param planeDetector the plane-detector module to use
  44414. * @param enable enable plane-anchors. default is true
  44415. */
  44416. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  44417. /**
  44418. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  44419. * @param hitTestModule the hit-test module to use.
  44420. */
  44421. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  44422. /**
  44423. * attach this feature
  44424. * Will usually be called by the features manager
  44425. *
  44426. * @returns true if successful.
  44427. */
  44428. attach(): boolean;
  44429. /**
  44430. * detach this feature.
  44431. * Will usually be called by the features manager
  44432. *
  44433. * @returns true if successful.
  44434. */
  44435. detach(): boolean;
  44436. /**
  44437. * Dispose this feature and all of the resources attached
  44438. */
  44439. dispose(): void;
  44440. private _onSelect;
  44441. /**
  44442. * Add anchor at a specific XR point.
  44443. *
  44444. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  44445. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  44446. * @returns a promise the fulfills when the anchor was created
  44447. */
  44448. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  44449. private _updateAnchorWithXRFrame;
  44450. /**
  44451. * avoiding using Array.find for global support.
  44452. * @param xrAnchor the plane to find in the array
  44453. */
  44454. private _findIndexInAnchorArray;
  44455. }
  44456. }
  44457. declare module BABYLON {
  44458. /**
  44459. * Options interface for the background remover plugin
  44460. */
  44461. export interface IWebXRBackgroundRemoverOptions {
  44462. /**
  44463. * don't disable the environment helper
  44464. */
  44465. ignoreEnvironmentHelper?: boolean;
  44466. /**
  44467. * flags to configure the removal of the environment helper.
  44468. * If not set, the entire background will be removed. If set, flags should be set as well.
  44469. */
  44470. environmentHelperRemovalFlags?: {
  44471. /**
  44472. * Should the skybox be removed (default false)
  44473. */
  44474. skyBox?: boolean;
  44475. /**
  44476. * Should the ground be removed (default false)
  44477. */
  44478. ground?: boolean;
  44479. };
  44480. /**
  44481. * Further background meshes to disable when entering AR
  44482. */
  44483. backgroundMeshes?: AbstractMesh[];
  44484. }
  44485. /**
  44486. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  44487. */
  44488. export class WebXRBackgroundRemover implements IWebXRFeature {
  44489. private _xrSessionManager;
  44490. /**
  44491. * read-only options to be used in this module
  44492. */
  44493. readonly options: IWebXRBackgroundRemoverOptions;
  44494. /**
  44495. * The module's name
  44496. */
  44497. static readonly Name: string;
  44498. /**
  44499. * The (Babylon) version of this module.
  44500. * This is an integer representing the implementation version.
  44501. * This number does not correspond to the webxr specs version
  44502. */
  44503. static readonly Version: number;
  44504. /**
  44505. * registered observers will be triggered when the background state changes
  44506. */
  44507. onBackgroundStateChangedObservable: Observable<boolean>;
  44508. /**
  44509. * constructs a new background remover module
  44510. * @param _xrSessionManager the session manager for this module
  44511. * @param options read-only options to be used in this module
  44512. */
  44513. constructor(_xrSessionManager: WebXRSessionManager,
  44514. /**
  44515. * read-only options to be used in this module
  44516. */
  44517. options?: IWebXRBackgroundRemoverOptions);
  44518. /**
  44519. * attach this feature
  44520. * Will usually be called by the features manager
  44521. *
  44522. * @returns true if successful.
  44523. */
  44524. attach(): boolean;
  44525. /**
  44526. * detach this feature.
  44527. * Will usually be called by the features manager
  44528. *
  44529. * @returns true if successful.
  44530. */
  44531. detach(): boolean;
  44532. private _setBackgroundState;
  44533. /**
  44534. * Dispose this feature and all of the resources attached
  44535. */
  44536. dispose(): void;
  44537. }
  44538. }
  44539. declare module BABYLON {
  44540. /**
  44541. * Contains an array of blocks representing the octree
  44542. */
  44543. export interface IOctreeContainer<T> {
  44544. /**
  44545. * Blocks within the octree
  44546. */
  44547. blocks: Array<OctreeBlock<T>>;
  44548. }
  44549. /**
  44550. * Class used to store a cell in an octree
  44551. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44552. */
  44553. export class OctreeBlock<T> {
  44554. /**
  44555. * Gets the content of the current block
  44556. */
  44557. entries: T[];
  44558. /**
  44559. * Gets the list of block children
  44560. */
  44561. blocks: Array<OctreeBlock<T>>;
  44562. private _depth;
  44563. private _maxDepth;
  44564. private _capacity;
  44565. private _minPoint;
  44566. private _maxPoint;
  44567. private _boundingVectors;
  44568. private _creationFunc;
  44569. /**
  44570. * Creates a new block
  44571. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  44572. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  44573. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  44574. * @param depth defines the current depth of this block in the octree
  44575. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  44576. * @param creationFunc defines a callback to call when an element is added to the block
  44577. */
  44578. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  44579. /**
  44580. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  44581. */
  44582. get capacity(): number;
  44583. /**
  44584. * Gets the minimum vector (in world space) of the block's bounding box
  44585. */
  44586. get minPoint(): Vector3;
  44587. /**
  44588. * Gets the maximum vector (in world space) of the block's bounding box
  44589. */
  44590. get maxPoint(): Vector3;
  44591. /**
  44592. * Add a new element to this block
  44593. * @param entry defines the element to add
  44594. */
  44595. addEntry(entry: T): void;
  44596. /**
  44597. * Remove an element from this block
  44598. * @param entry defines the element to remove
  44599. */
  44600. removeEntry(entry: T): void;
  44601. /**
  44602. * Add an array of elements to this block
  44603. * @param entries defines the array of elements to add
  44604. */
  44605. addEntries(entries: T[]): void;
  44606. /**
  44607. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  44608. * @param frustumPlanes defines the frustum planes to test
  44609. * @param selection defines the array to store current content if selection is positive
  44610. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44611. */
  44612. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  44613. /**
  44614. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  44615. * @param sphereCenter defines the bounding sphere center
  44616. * @param sphereRadius defines the bounding sphere radius
  44617. * @param selection defines the array to store current content if selection is positive
  44618. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44619. */
  44620. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  44621. /**
  44622. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  44623. * @param ray defines the ray to test with
  44624. * @param selection defines the array to store current content if selection is positive
  44625. */
  44626. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  44627. /**
  44628. * Subdivide the content into child blocks (this block will then be empty)
  44629. */
  44630. createInnerBlocks(): void;
  44631. /**
  44632. * @hidden
  44633. */
  44634. 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;
  44635. }
  44636. }
  44637. declare module BABYLON {
  44638. /**
  44639. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  44640. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44641. */
  44642. export class Octree<T> {
  44643. /** 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.) */
  44644. maxDepth: number;
  44645. /**
  44646. * Blocks within the octree containing objects
  44647. */
  44648. blocks: Array<OctreeBlock<T>>;
  44649. /**
  44650. * Content stored in the octree
  44651. */
  44652. dynamicContent: T[];
  44653. private _maxBlockCapacity;
  44654. private _selectionContent;
  44655. private _creationFunc;
  44656. /**
  44657. * Creates a octree
  44658. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44659. * @param creationFunc function to be used to instatiate the octree
  44660. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  44661. * @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.)
  44662. */
  44663. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  44664. /** 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.) */
  44665. maxDepth?: number);
  44666. /**
  44667. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  44668. * @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);
  44669. * @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);
  44670. * @param entries meshes to be added to the octree blocks
  44671. */
  44672. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  44673. /**
  44674. * Adds a mesh to the octree
  44675. * @param entry Mesh to add to the octree
  44676. */
  44677. addMesh(entry: T): void;
  44678. /**
  44679. * Remove an element from the octree
  44680. * @param entry defines the element to remove
  44681. */
  44682. removeMesh(entry: T): void;
  44683. /**
  44684. * Selects an array of meshes within the frustum
  44685. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  44686. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  44687. * @returns array of meshes within the frustum
  44688. */
  44689. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  44690. /**
  44691. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  44692. * @param sphereCenter defines the bounding sphere center
  44693. * @param sphereRadius defines the bounding sphere radius
  44694. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44695. * @returns an array of objects that intersect the sphere
  44696. */
  44697. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  44698. /**
  44699. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  44700. * @param ray defines the ray to test with
  44701. * @returns array of intersected objects
  44702. */
  44703. intersectsRay(ray: Ray): SmartArray<T>;
  44704. /**
  44705. * Adds a mesh into the octree block if it intersects the block
  44706. */
  44707. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  44708. /**
  44709. * Adds a submesh into the octree block if it intersects the block
  44710. */
  44711. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  44712. }
  44713. }
  44714. declare module BABYLON {
  44715. interface Scene {
  44716. /**
  44717. * @hidden
  44718. * Backing Filed
  44719. */
  44720. _selectionOctree: Octree<AbstractMesh>;
  44721. /**
  44722. * Gets the octree used to boost mesh selection (picking)
  44723. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44724. */
  44725. selectionOctree: Octree<AbstractMesh>;
  44726. /**
  44727. * Creates or updates the octree used to boost selection (picking)
  44728. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44729. * @param maxCapacity defines the maximum capacity per leaf
  44730. * @param maxDepth defines the maximum depth of the octree
  44731. * @returns an octree of AbstractMesh
  44732. */
  44733. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  44734. }
  44735. interface AbstractMesh {
  44736. /**
  44737. * @hidden
  44738. * Backing Field
  44739. */
  44740. _submeshesOctree: Octree<SubMesh>;
  44741. /**
  44742. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  44743. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  44744. * @param maxCapacity defines the maximum size of each block (64 by default)
  44745. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  44746. * @returns the new octree
  44747. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  44748. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44749. */
  44750. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  44751. }
  44752. /**
  44753. * Defines the octree scene component responsible to manage any octrees
  44754. * in a given scene.
  44755. */
  44756. export class OctreeSceneComponent {
  44757. /**
  44758. * The component name help to identify the component in the list of scene components.
  44759. */
  44760. readonly name: string;
  44761. /**
  44762. * The scene the component belongs to.
  44763. */
  44764. scene: Scene;
  44765. /**
  44766. * Indicates if the meshes have been checked to make sure they are isEnabled()
  44767. */
  44768. readonly checksIsEnabled: boolean;
  44769. /**
  44770. * Creates a new instance of the component for the given scene
  44771. * @param scene Defines the scene to register the component in
  44772. */
  44773. constructor(scene: Scene);
  44774. /**
  44775. * Registers the component in a given scene
  44776. */
  44777. register(): void;
  44778. /**
  44779. * Return the list of active meshes
  44780. * @returns the list of active meshes
  44781. */
  44782. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  44783. /**
  44784. * Return the list of active sub meshes
  44785. * @param mesh The mesh to get the candidates sub meshes from
  44786. * @returns the list of active sub meshes
  44787. */
  44788. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  44789. private _tempRay;
  44790. /**
  44791. * Return the list of sub meshes intersecting with a given local ray
  44792. * @param mesh defines the mesh to find the submesh for
  44793. * @param localRay defines the ray in local space
  44794. * @returns the list of intersecting sub meshes
  44795. */
  44796. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  44797. /**
  44798. * Return the list of sub meshes colliding with a collider
  44799. * @param mesh defines the mesh to find the submesh for
  44800. * @param collider defines the collider to evaluate the collision against
  44801. * @returns the list of colliding sub meshes
  44802. */
  44803. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  44804. /**
  44805. * Rebuilds the elements related to this component in case of
  44806. * context lost for instance.
  44807. */
  44808. rebuild(): void;
  44809. /**
  44810. * Disposes the component and the associated ressources.
  44811. */
  44812. dispose(): void;
  44813. }
  44814. }
  44815. declare module BABYLON {
  44816. /**
  44817. * Renders a layer on top of an existing scene
  44818. */
  44819. export class UtilityLayerRenderer implements IDisposable {
  44820. /** the original scene that will be rendered on top of */
  44821. originalScene: Scene;
  44822. private _pointerCaptures;
  44823. private _lastPointerEvents;
  44824. private static _DefaultUtilityLayer;
  44825. private static _DefaultKeepDepthUtilityLayer;
  44826. private _sharedGizmoLight;
  44827. private _renderCamera;
  44828. /**
  44829. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  44830. * @returns the camera that is used when rendering the utility layer
  44831. */
  44832. getRenderCamera(): Nullable<Camera>;
  44833. /**
  44834. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  44835. * @param cam the camera that should be used when rendering the utility layer
  44836. */
  44837. setRenderCamera(cam: Nullable<Camera>): void;
  44838. /**
  44839. * @hidden
  44840. * Light which used by gizmos to get light shading
  44841. */
  44842. _getSharedGizmoLight(): HemisphericLight;
  44843. /**
  44844. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  44845. */
  44846. pickUtilitySceneFirst: boolean;
  44847. /**
  44848. * 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)
  44849. */
  44850. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  44851. /**
  44852. * 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)
  44853. */
  44854. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  44855. /**
  44856. * The scene that is rendered on top of the original scene
  44857. */
  44858. utilityLayerScene: Scene;
  44859. /**
  44860. * If the utility layer should automatically be rendered on top of existing scene
  44861. */
  44862. shouldRender: boolean;
  44863. /**
  44864. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  44865. */
  44866. onlyCheckPointerDownEvents: boolean;
  44867. /**
  44868. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  44869. */
  44870. processAllEvents: boolean;
  44871. /**
  44872. * Observable raised when the pointer move from the utility layer scene to the main scene
  44873. */
  44874. onPointerOutObservable: Observable<number>;
  44875. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  44876. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  44877. private _afterRenderObserver;
  44878. private _sceneDisposeObserver;
  44879. private _originalPointerObserver;
  44880. /**
  44881. * Instantiates a UtilityLayerRenderer
  44882. * @param originalScene the original scene that will be rendered on top of
  44883. * @param handleEvents boolean indicating if the utility layer should handle events
  44884. */
  44885. constructor(
  44886. /** the original scene that will be rendered on top of */
  44887. originalScene: Scene, handleEvents?: boolean);
  44888. private _notifyObservers;
  44889. /**
  44890. * Renders the utility layers scene on top of the original scene
  44891. */
  44892. render(): void;
  44893. /**
  44894. * Disposes of the renderer
  44895. */
  44896. dispose(): void;
  44897. private _updateCamera;
  44898. }
  44899. }
  44900. declare module BABYLON {
  44901. /**
  44902. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  44903. */
  44904. export class Gizmo implements IDisposable {
  44905. /** The utility layer the gizmo will be added to */
  44906. gizmoLayer: UtilityLayerRenderer;
  44907. /**
  44908. * The root mesh of the gizmo
  44909. */
  44910. _rootMesh: Mesh;
  44911. private _attachedMesh;
  44912. /**
  44913. * Ratio for the scale of the gizmo (Default: 1)
  44914. */
  44915. scaleRatio: number;
  44916. /**
  44917. * If a custom mesh has been set (Default: false)
  44918. */
  44919. protected _customMeshSet: boolean;
  44920. /**
  44921. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  44922. * * When set, interactions will be enabled
  44923. */
  44924. get attachedMesh(): Nullable<AbstractMesh>;
  44925. set attachedMesh(value: Nullable<AbstractMesh>);
  44926. /**
  44927. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  44928. * @param mesh The mesh to replace the default mesh of the gizmo
  44929. */
  44930. setCustomMesh(mesh: Mesh): void;
  44931. /**
  44932. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  44933. */
  44934. updateGizmoRotationToMatchAttachedMesh: boolean;
  44935. /**
  44936. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  44937. */
  44938. updateGizmoPositionToMatchAttachedMesh: boolean;
  44939. /**
  44940. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  44941. */
  44942. updateScale: boolean;
  44943. protected _interactionsEnabled: boolean;
  44944. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44945. private _beforeRenderObserver;
  44946. private _tempVector;
  44947. /**
  44948. * Creates a gizmo
  44949. * @param gizmoLayer The utility layer the gizmo will be added to
  44950. */
  44951. constructor(
  44952. /** The utility layer the gizmo will be added to */
  44953. gizmoLayer?: UtilityLayerRenderer);
  44954. /**
  44955. * Updates the gizmo to match the attached mesh's position/rotation
  44956. */
  44957. protected _update(): void;
  44958. /**
  44959. * Disposes of the gizmo
  44960. */
  44961. dispose(): void;
  44962. }
  44963. }
  44964. declare module BABYLON {
  44965. /**
  44966. * Single plane drag gizmo
  44967. */
  44968. export class PlaneDragGizmo extends Gizmo {
  44969. /**
  44970. * Drag behavior responsible for the gizmos dragging interactions
  44971. */
  44972. dragBehavior: PointerDragBehavior;
  44973. private _pointerObserver;
  44974. /**
  44975. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44976. */
  44977. snapDistance: number;
  44978. /**
  44979. * Event that fires each time the gizmo snaps to a new location.
  44980. * * snapDistance is the the change in distance
  44981. */
  44982. onSnapObservable: Observable<{
  44983. snapDistance: number;
  44984. }>;
  44985. private _plane;
  44986. private _coloredMaterial;
  44987. private _hoverMaterial;
  44988. private _isEnabled;
  44989. private _parent;
  44990. /** @hidden */
  44991. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  44992. /** @hidden */
  44993. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  44994. /**
  44995. * Creates a PlaneDragGizmo
  44996. * @param gizmoLayer The utility layer the gizmo will be added to
  44997. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  44998. * @param color The color of the gizmo
  44999. */
  45000. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  45001. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45002. /**
  45003. * If the gizmo is enabled
  45004. */
  45005. set isEnabled(value: boolean);
  45006. get isEnabled(): boolean;
  45007. /**
  45008. * Disposes of the gizmo
  45009. */
  45010. dispose(): void;
  45011. }
  45012. }
  45013. declare module BABYLON {
  45014. /**
  45015. * Gizmo that enables dragging a mesh along 3 axis
  45016. */
  45017. export class PositionGizmo extends Gizmo {
  45018. /**
  45019. * Internal gizmo used for interactions on the x axis
  45020. */
  45021. xGizmo: AxisDragGizmo;
  45022. /**
  45023. * Internal gizmo used for interactions on the y axis
  45024. */
  45025. yGizmo: AxisDragGizmo;
  45026. /**
  45027. * Internal gizmo used for interactions on the z axis
  45028. */
  45029. zGizmo: AxisDragGizmo;
  45030. /**
  45031. * Internal gizmo used for interactions on the yz plane
  45032. */
  45033. xPlaneGizmo: PlaneDragGizmo;
  45034. /**
  45035. * Internal gizmo used for interactions on the xz plane
  45036. */
  45037. yPlaneGizmo: PlaneDragGizmo;
  45038. /**
  45039. * Internal gizmo used for interactions on the xy plane
  45040. */
  45041. zPlaneGizmo: PlaneDragGizmo;
  45042. /**
  45043. * private variables
  45044. */
  45045. private _meshAttached;
  45046. private _updateGizmoRotationToMatchAttachedMesh;
  45047. private _snapDistance;
  45048. private _scaleRatio;
  45049. /** Fires an event when any of it's sub gizmos are dragged */
  45050. onDragStartObservable: Observable<unknown>;
  45051. /** Fires an event when any of it's sub gizmos are released from dragging */
  45052. onDragEndObservable: Observable<unknown>;
  45053. /**
  45054. * If set to true, planar drag is enabled
  45055. */
  45056. private _planarGizmoEnabled;
  45057. get attachedMesh(): Nullable<AbstractMesh>;
  45058. set attachedMesh(mesh: Nullable<AbstractMesh>);
  45059. /**
  45060. * Creates a PositionGizmo
  45061. * @param gizmoLayer The utility layer the gizmo will be added to
  45062. */
  45063. constructor(gizmoLayer?: UtilityLayerRenderer);
  45064. /**
  45065. * If the planar drag gizmo is enabled
  45066. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  45067. */
  45068. set planarGizmoEnabled(value: boolean);
  45069. get planarGizmoEnabled(): boolean;
  45070. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  45071. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  45072. /**
  45073. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45074. */
  45075. set snapDistance(value: number);
  45076. get snapDistance(): number;
  45077. /**
  45078. * Ratio for the scale of the gizmo (Default: 1)
  45079. */
  45080. set scaleRatio(value: number);
  45081. get scaleRatio(): number;
  45082. /**
  45083. * Disposes of the gizmo
  45084. */
  45085. dispose(): void;
  45086. /**
  45087. * CustomMeshes are not supported by this gizmo
  45088. * @param mesh The mesh to replace the default mesh of the gizmo
  45089. */
  45090. setCustomMesh(mesh: Mesh): void;
  45091. }
  45092. }
  45093. declare module BABYLON {
  45094. /**
  45095. * Single axis drag gizmo
  45096. */
  45097. export class AxisDragGizmo extends Gizmo {
  45098. /**
  45099. * Drag behavior responsible for the gizmos dragging interactions
  45100. */
  45101. dragBehavior: PointerDragBehavior;
  45102. private _pointerObserver;
  45103. /**
  45104. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45105. */
  45106. snapDistance: number;
  45107. /**
  45108. * Event that fires each time the gizmo snaps to a new location.
  45109. * * snapDistance is the the change in distance
  45110. */
  45111. onSnapObservable: Observable<{
  45112. snapDistance: number;
  45113. }>;
  45114. private _isEnabled;
  45115. private _parent;
  45116. private _arrow;
  45117. private _coloredMaterial;
  45118. private _hoverMaterial;
  45119. /** @hidden */
  45120. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  45121. /** @hidden */
  45122. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  45123. /**
  45124. * Creates an AxisDragGizmo
  45125. * @param gizmoLayer The utility layer the gizmo will be added to
  45126. * @param dragAxis The axis which the gizmo will be able to drag on
  45127. * @param color The color of the gizmo
  45128. */
  45129. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  45130. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45131. /**
  45132. * If the gizmo is enabled
  45133. */
  45134. set isEnabled(value: boolean);
  45135. get isEnabled(): boolean;
  45136. /**
  45137. * Disposes of the gizmo
  45138. */
  45139. dispose(): void;
  45140. }
  45141. }
  45142. declare module BABYLON.Debug {
  45143. /**
  45144. * The Axes viewer will show 3 axes in a specific point in space
  45145. */
  45146. export class AxesViewer {
  45147. private _xAxis;
  45148. private _yAxis;
  45149. private _zAxis;
  45150. private _scaleLinesFactor;
  45151. private _instanced;
  45152. /**
  45153. * Gets the hosting scene
  45154. */
  45155. scene: Scene;
  45156. /**
  45157. * Gets or sets a number used to scale line length
  45158. */
  45159. scaleLines: number;
  45160. /** Gets the node hierarchy used to render x-axis */
  45161. get xAxis(): TransformNode;
  45162. /** Gets the node hierarchy used to render y-axis */
  45163. get yAxis(): TransformNode;
  45164. /** Gets the node hierarchy used to render z-axis */
  45165. get zAxis(): TransformNode;
  45166. /**
  45167. * Creates a new AxesViewer
  45168. * @param scene defines the hosting scene
  45169. * @param scaleLines defines a number used to scale line length (1 by default)
  45170. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  45171. * @param xAxis defines the node hierarchy used to render the x-axis
  45172. * @param yAxis defines the node hierarchy used to render the y-axis
  45173. * @param zAxis defines the node hierarchy used to render the z-axis
  45174. */
  45175. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  45176. /**
  45177. * Force the viewer to update
  45178. * @param position defines the position of the viewer
  45179. * @param xaxis defines the x axis of the viewer
  45180. * @param yaxis defines the y axis of the viewer
  45181. * @param zaxis defines the z axis of the viewer
  45182. */
  45183. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  45184. /**
  45185. * Creates an instance of this axes viewer.
  45186. * @returns a new axes viewer with instanced meshes
  45187. */
  45188. createInstance(): AxesViewer;
  45189. /** Releases resources */
  45190. dispose(): void;
  45191. private static _SetRenderingGroupId;
  45192. }
  45193. }
  45194. declare module BABYLON.Debug {
  45195. /**
  45196. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  45197. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  45198. */
  45199. export class BoneAxesViewer extends AxesViewer {
  45200. /**
  45201. * Gets or sets the target mesh where to display the axes viewer
  45202. */
  45203. mesh: Nullable<Mesh>;
  45204. /**
  45205. * Gets or sets the target bone where to display the axes viewer
  45206. */
  45207. bone: Nullable<Bone>;
  45208. /** Gets current position */
  45209. pos: Vector3;
  45210. /** Gets direction of X axis */
  45211. xaxis: Vector3;
  45212. /** Gets direction of Y axis */
  45213. yaxis: Vector3;
  45214. /** Gets direction of Z axis */
  45215. zaxis: Vector3;
  45216. /**
  45217. * Creates a new BoneAxesViewer
  45218. * @param scene defines the hosting scene
  45219. * @param bone defines the target bone
  45220. * @param mesh defines the target mesh
  45221. * @param scaleLines defines a scaling factor for line length (1 by default)
  45222. */
  45223. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  45224. /**
  45225. * Force the viewer to update
  45226. */
  45227. update(): void;
  45228. /** Releases resources */
  45229. dispose(): void;
  45230. }
  45231. }
  45232. declare module BABYLON {
  45233. /**
  45234. * Interface used to define scene explorer extensibility option
  45235. */
  45236. export interface IExplorerExtensibilityOption {
  45237. /**
  45238. * Define the option label
  45239. */
  45240. label: string;
  45241. /**
  45242. * Defines the action to execute on click
  45243. */
  45244. action: (entity: any) => void;
  45245. }
  45246. /**
  45247. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  45248. */
  45249. export interface IExplorerExtensibilityGroup {
  45250. /**
  45251. * Defines a predicate to test if a given type mut be extended
  45252. */
  45253. predicate: (entity: any) => boolean;
  45254. /**
  45255. * Gets the list of options added to a type
  45256. */
  45257. entries: IExplorerExtensibilityOption[];
  45258. }
  45259. /**
  45260. * Interface used to define the options to use to create the Inspector
  45261. */
  45262. export interface IInspectorOptions {
  45263. /**
  45264. * Display in overlay mode (default: false)
  45265. */
  45266. overlay?: boolean;
  45267. /**
  45268. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  45269. */
  45270. globalRoot?: HTMLElement;
  45271. /**
  45272. * Display the Scene explorer
  45273. */
  45274. showExplorer?: boolean;
  45275. /**
  45276. * Display the property inspector
  45277. */
  45278. showInspector?: boolean;
  45279. /**
  45280. * Display in embed mode (both panes on the right)
  45281. */
  45282. embedMode?: boolean;
  45283. /**
  45284. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  45285. */
  45286. handleResize?: boolean;
  45287. /**
  45288. * Allow the panes to popup (default: true)
  45289. */
  45290. enablePopup?: boolean;
  45291. /**
  45292. * Allow the panes to be closed by users (default: true)
  45293. */
  45294. enableClose?: boolean;
  45295. /**
  45296. * Optional list of extensibility entries
  45297. */
  45298. explorerExtensibility?: IExplorerExtensibilityGroup[];
  45299. /**
  45300. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  45301. */
  45302. inspectorURL?: string;
  45303. /**
  45304. * Optional initial tab (default to DebugLayerTab.Properties)
  45305. */
  45306. initialTab?: DebugLayerTab;
  45307. }
  45308. interface Scene {
  45309. /**
  45310. * @hidden
  45311. * Backing field
  45312. */
  45313. _debugLayer: DebugLayer;
  45314. /**
  45315. * Gets the debug layer (aka Inspector) associated with the scene
  45316. * @see http://doc.babylonjs.com/features/playground_debuglayer
  45317. */
  45318. debugLayer: DebugLayer;
  45319. }
  45320. /**
  45321. * Enum of inspector action tab
  45322. */
  45323. export enum DebugLayerTab {
  45324. /**
  45325. * Properties tag (default)
  45326. */
  45327. Properties = 0,
  45328. /**
  45329. * Debug tab
  45330. */
  45331. Debug = 1,
  45332. /**
  45333. * Statistics tab
  45334. */
  45335. Statistics = 2,
  45336. /**
  45337. * Tools tab
  45338. */
  45339. Tools = 3,
  45340. /**
  45341. * Settings tab
  45342. */
  45343. Settings = 4
  45344. }
  45345. /**
  45346. * The debug layer (aka Inspector) is the go to tool in order to better understand
  45347. * what is happening in your scene
  45348. * @see http://doc.babylonjs.com/features/playground_debuglayer
  45349. */
  45350. export class DebugLayer {
  45351. /**
  45352. * Define the url to get the inspector script from.
  45353. * By default it uses the babylonjs CDN.
  45354. * @ignoreNaming
  45355. */
  45356. static InspectorURL: string;
  45357. private _scene;
  45358. private BJSINSPECTOR;
  45359. private _onPropertyChangedObservable?;
  45360. /**
  45361. * Observable triggered when a property is changed through the inspector.
  45362. */
  45363. get onPropertyChangedObservable(): any;
  45364. /**
  45365. * Instantiates a new debug layer.
  45366. * The debug layer (aka Inspector) is the go to tool in order to better understand
  45367. * what is happening in your scene
  45368. * @see http://doc.babylonjs.com/features/playground_debuglayer
  45369. * @param scene Defines the scene to inspect
  45370. */
  45371. constructor(scene: Scene);
  45372. /** Creates the inspector window. */
  45373. private _createInspector;
  45374. /**
  45375. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  45376. * @param entity defines the entity to select
  45377. * @param lineContainerTitle defines the specific block to highlight
  45378. */
  45379. select(entity: any, lineContainerTitle?: string): void;
  45380. /** Get the inspector from bundle or global */
  45381. private _getGlobalInspector;
  45382. /**
  45383. * Get if the inspector is visible or not.
  45384. * @returns true if visible otherwise, false
  45385. */
  45386. isVisible(): boolean;
  45387. /**
  45388. * Hide the inspector and close its window.
  45389. */
  45390. hide(): void;
  45391. /**
  45392. * Launch the debugLayer.
  45393. * @param config Define the configuration of the inspector
  45394. * @return a promise fulfilled when the debug layer is visible
  45395. */
  45396. show(config?: IInspectorOptions): Promise<DebugLayer>;
  45397. }
  45398. }
  45399. declare module BABYLON {
  45400. /**
  45401. * Class containing static functions to help procedurally build meshes
  45402. */
  45403. export class BoxBuilder {
  45404. /**
  45405. * Creates a box mesh
  45406. * * The parameter `size` sets the size (float) of each box side (default 1)
  45407. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  45408. * * 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)
  45409. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  45410. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45411. * * 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
  45412. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45413. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  45414. * @param name defines the name of the mesh
  45415. * @param options defines the options used to create the mesh
  45416. * @param scene defines the hosting scene
  45417. * @returns the box mesh
  45418. */
  45419. static CreateBox(name: string, options: {
  45420. size?: number;
  45421. width?: number;
  45422. height?: number;
  45423. depth?: number;
  45424. faceUV?: Vector4[];
  45425. faceColors?: Color4[];
  45426. sideOrientation?: number;
  45427. frontUVs?: Vector4;
  45428. backUVs?: Vector4;
  45429. wrap?: boolean;
  45430. topBaseAt?: number;
  45431. bottomBaseAt?: number;
  45432. updatable?: boolean;
  45433. }, scene?: Nullable<Scene>): Mesh;
  45434. }
  45435. }
  45436. declare module BABYLON {
  45437. /**
  45438. * Class containing static functions to help procedurally build meshes
  45439. */
  45440. export class SphereBuilder {
  45441. /**
  45442. * Creates a sphere mesh
  45443. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  45444. * * 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`)
  45445. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  45446. * * 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
  45447. * * 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)
  45448. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45449. * * 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
  45450. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45451. * @param name defines the name of the mesh
  45452. * @param options defines the options used to create the mesh
  45453. * @param scene defines the hosting scene
  45454. * @returns the sphere mesh
  45455. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  45456. */
  45457. static CreateSphere(name: string, options: {
  45458. segments?: number;
  45459. diameter?: number;
  45460. diameterX?: number;
  45461. diameterY?: number;
  45462. diameterZ?: number;
  45463. arc?: number;
  45464. slice?: number;
  45465. sideOrientation?: number;
  45466. frontUVs?: Vector4;
  45467. backUVs?: Vector4;
  45468. updatable?: boolean;
  45469. }, scene?: Nullable<Scene>): Mesh;
  45470. }
  45471. }
  45472. declare module BABYLON.Debug {
  45473. /**
  45474. * Used to show the physics impostor around the specific mesh
  45475. */
  45476. export class PhysicsViewer {
  45477. /** @hidden */
  45478. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  45479. /** @hidden */
  45480. protected _meshes: Array<Nullable<AbstractMesh>>;
  45481. /** @hidden */
  45482. protected _scene: Nullable<Scene>;
  45483. /** @hidden */
  45484. protected _numMeshes: number;
  45485. /** @hidden */
  45486. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  45487. private _renderFunction;
  45488. private _utilityLayer;
  45489. private _debugBoxMesh;
  45490. private _debugSphereMesh;
  45491. private _debugCylinderMesh;
  45492. private _debugMaterial;
  45493. private _debugMeshMeshes;
  45494. /**
  45495. * Creates a new PhysicsViewer
  45496. * @param scene defines the hosting scene
  45497. */
  45498. constructor(scene: Scene);
  45499. /** @hidden */
  45500. protected _updateDebugMeshes(): void;
  45501. /**
  45502. * Renders a specified physic impostor
  45503. * @param impostor defines the impostor to render
  45504. * @param targetMesh defines the mesh represented by the impostor
  45505. * @returns the new debug mesh used to render the impostor
  45506. */
  45507. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  45508. /**
  45509. * Hides a specified physic impostor
  45510. * @param impostor defines the impostor to hide
  45511. */
  45512. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  45513. private _getDebugMaterial;
  45514. private _getDebugBoxMesh;
  45515. private _getDebugSphereMesh;
  45516. private _getDebugCylinderMesh;
  45517. private _getDebugMeshMesh;
  45518. private _getDebugMesh;
  45519. /** Releases all resources */
  45520. dispose(): void;
  45521. }
  45522. }
  45523. declare module BABYLON {
  45524. /**
  45525. * Class containing static functions to help procedurally build meshes
  45526. */
  45527. export class LinesBuilder {
  45528. /**
  45529. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  45530. * * 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
  45531. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  45532. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  45533. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  45534. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  45535. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  45536. * * 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
  45537. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  45538. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45539. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  45540. * @param name defines the name of the new line system
  45541. * @param options defines the options used to create the line system
  45542. * @param scene defines the hosting scene
  45543. * @returns a new line system mesh
  45544. */
  45545. static CreateLineSystem(name: string, options: {
  45546. lines: Vector3[][];
  45547. updatable?: boolean;
  45548. instance?: Nullable<LinesMesh>;
  45549. colors?: Nullable<Color4[][]>;
  45550. useVertexAlpha?: boolean;
  45551. }, scene: Nullable<Scene>): LinesMesh;
  45552. /**
  45553. * Creates a line mesh
  45554. * 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
  45555. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45556. * * The parameter `points` is an array successive Vector3
  45557. * * 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
  45558. * * The optional parameter `colors` is an array of successive Color4, one per line point
  45559. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  45560. * * When updating an instance, remember that only point positions can change, not the number of points
  45561. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45562. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  45563. * @param name defines the name of the new line system
  45564. * @param options defines the options used to create the line system
  45565. * @param scene defines the hosting scene
  45566. * @returns a new line mesh
  45567. */
  45568. static CreateLines(name: string, options: {
  45569. points: Vector3[];
  45570. updatable?: boolean;
  45571. instance?: Nullable<LinesMesh>;
  45572. colors?: Color4[];
  45573. useVertexAlpha?: boolean;
  45574. }, scene?: Nullable<Scene>): LinesMesh;
  45575. /**
  45576. * Creates a dashed line mesh
  45577. * * 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
  45578. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45579. * * The parameter `points` is an array successive Vector3
  45580. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  45581. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  45582. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  45583. * * 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
  45584. * * When updating an instance, remember that only point positions can change, not the number of points
  45585. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45586. * @param name defines the name of the mesh
  45587. * @param options defines the options used to create the mesh
  45588. * @param scene defines the hosting scene
  45589. * @returns the dashed line mesh
  45590. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  45591. */
  45592. static CreateDashedLines(name: string, options: {
  45593. points: Vector3[];
  45594. dashSize?: number;
  45595. gapSize?: number;
  45596. dashNb?: number;
  45597. updatable?: boolean;
  45598. instance?: LinesMesh;
  45599. }, scene?: Nullable<Scene>): LinesMesh;
  45600. }
  45601. }
  45602. declare module BABYLON {
  45603. /**
  45604. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  45605. * in order to better appreciate the issue one might have.
  45606. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  45607. */
  45608. export class RayHelper {
  45609. /**
  45610. * Defines the ray we are currently tryin to visualize.
  45611. */
  45612. ray: Nullable<Ray>;
  45613. private _renderPoints;
  45614. private _renderLine;
  45615. private _renderFunction;
  45616. private _scene;
  45617. private _updateToMeshFunction;
  45618. private _attachedToMesh;
  45619. private _meshSpaceDirection;
  45620. private _meshSpaceOrigin;
  45621. /**
  45622. * Helper function to create a colored helper in a scene in one line.
  45623. * @param ray Defines the ray we are currently tryin to visualize
  45624. * @param scene Defines the scene the ray is used in
  45625. * @param color Defines the color we want to see the ray in
  45626. * @returns The newly created ray helper.
  45627. */
  45628. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  45629. /**
  45630. * Instantiate a new ray helper.
  45631. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  45632. * in order to better appreciate the issue one might have.
  45633. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  45634. * @param ray Defines the ray we are currently tryin to visualize
  45635. */
  45636. constructor(ray: Ray);
  45637. /**
  45638. * Shows the ray we are willing to debug.
  45639. * @param scene Defines the scene the ray needs to be rendered in
  45640. * @param color Defines the color the ray needs to be rendered in
  45641. */
  45642. show(scene: Scene, color?: Color3): void;
  45643. /**
  45644. * Hides the ray we are debugging.
  45645. */
  45646. hide(): void;
  45647. private _render;
  45648. /**
  45649. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  45650. * @param mesh Defines the mesh we want the helper attached to
  45651. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  45652. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  45653. * @param length Defines the length of the ray
  45654. */
  45655. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  45656. /**
  45657. * Detach the ray helper from the mesh it has previously been attached to.
  45658. */
  45659. detachFromMesh(): void;
  45660. private _updateToMesh;
  45661. /**
  45662. * Dispose the helper and release its associated resources.
  45663. */
  45664. dispose(): void;
  45665. }
  45666. }
  45667. declare module BABYLON.Debug {
  45668. /**
  45669. * Class used to render a debug view of a given skeleton
  45670. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  45671. */
  45672. export class SkeletonViewer {
  45673. /** defines the skeleton to render */
  45674. skeleton: Skeleton;
  45675. /** defines the mesh attached to the skeleton */
  45676. mesh: AbstractMesh;
  45677. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  45678. autoUpdateBonesMatrices: boolean;
  45679. /** defines the rendering group id to use with the viewer */
  45680. renderingGroupId: number;
  45681. /** Gets or sets the color used to render the skeleton */
  45682. color: Color3;
  45683. private _scene;
  45684. private _debugLines;
  45685. private _debugMesh;
  45686. private _isEnabled;
  45687. private _renderFunction;
  45688. private _utilityLayer;
  45689. /**
  45690. * Returns the mesh used to render the bones
  45691. */
  45692. get debugMesh(): Nullable<LinesMesh>;
  45693. /**
  45694. * Creates a new SkeletonViewer
  45695. * @param skeleton defines the skeleton to render
  45696. * @param mesh defines the mesh attached to the skeleton
  45697. * @param scene defines the hosting scene
  45698. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  45699. * @param renderingGroupId defines the rendering group id to use with the viewer
  45700. */
  45701. constructor(
  45702. /** defines the skeleton to render */
  45703. skeleton: Skeleton,
  45704. /** defines the mesh attached to the skeleton */
  45705. mesh: AbstractMesh, scene: Scene,
  45706. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  45707. autoUpdateBonesMatrices?: boolean,
  45708. /** defines the rendering group id to use with the viewer */
  45709. renderingGroupId?: number);
  45710. /** Gets or sets a boolean indicating if the viewer is enabled */
  45711. set isEnabled(value: boolean);
  45712. get isEnabled(): boolean;
  45713. private _getBonePosition;
  45714. private _getLinesForBonesWithLength;
  45715. private _getLinesForBonesNoLength;
  45716. /** Update the viewer to sync with current skeleton state */
  45717. update(): void;
  45718. /** Release associated resources */
  45719. dispose(): void;
  45720. }
  45721. }
  45722. declare module BABYLON {
  45723. /**
  45724. * Options to create the null engine
  45725. */
  45726. export class NullEngineOptions {
  45727. /**
  45728. * Render width (Default: 512)
  45729. */
  45730. renderWidth: number;
  45731. /**
  45732. * Render height (Default: 256)
  45733. */
  45734. renderHeight: number;
  45735. /**
  45736. * Texture size (Default: 512)
  45737. */
  45738. textureSize: number;
  45739. /**
  45740. * If delta time between frames should be constant
  45741. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45742. */
  45743. deterministicLockstep: boolean;
  45744. /**
  45745. * Maximum about of steps between frames (Default: 4)
  45746. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45747. */
  45748. lockstepMaxSteps: number;
  45749. }
  45750. /**
  45751. * The null engine class provides support for headless version of babylon.js.
  45752. * This can be used in server side scenario or for testing purposes
  45753. */
  45754. export class NullEngine extends Engine {
  45755. private _options;
  45756. /**
  45757. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  45758. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45759. * @returns true if engine is in deterministic lock step mode
  45760. */
  45761. isDeterministicLockStep(): boolean;
  45762. /**
  45763. * Gets the max steps when engine is running in deterministic lock step
  45764. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45765. * @returns the max steps
  45766. */
  45767. getLockstepMaxSteps(): number;
  45768. /**
  45769. * Gets the current hardware scaling level.
  45770. * By default the hardware scaling level is computed from the window device ratio.
  45771. * 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.
  45772. * @returns a number indicating the current hardware scaling level
  45773. */
  45774. getHardwareScalingLevel(): number;
  45775. constructor(options?: NullEngineOptions);
  45776. /**
  45777. * Creates a vertex buffer
  45778. * @param vertices the data for the vertex buffer
  45779. * @returns the new WebGL static buffer
  45780. */
  45781. createVertexBuffer(vertices: FloatArray): DataBuffer;
  45782. /**
  45783. * Creates a new index buffer
  45784. * @param indices defines the content of the index buffer
  45785. * @param updatable defines if the index buffer must be updatable
  45786. * @returns a new webGL buffer
  45787. */
  45788. createIndexBuffer(indices: IndicesArray): DataBuffer;
  45789. /**
  45790. * Clear the current render buffer or the current render target (if any is set up)
  45791. * @param color defines the color to use
  45792. * @param backBuffer defines if the back buffer must be cleared
  45793. * @param depth defines if the depth buffer must be cleared
  45794. * @param stencil defines if the stencil buffer must be cleared
  45795. */
  45796. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  45797. /**
  45798. * Gets the current render width
  45799. * @param useScreen defines if screen size must be used (or the current render target if any)
  45800. * @returns a number defining the current render width
  45801. */
  45802. getRenderWidth(useScreen?: boolean): number;
  45803. /**
  45804. * Gets the current render height
  45805. * @param useScreen defines if screen size must be used (or the current render target if any)
  45806. * @returns a number defining the current render height
  45807. */
  45808. getRenderHeight(useScreen?: boolean): number;
  45809. /**
  45810. * Set the WebGL's viewport
  45811. * @param viewport defines the viewport element to be used
  45812. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  45813. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  45814. */
  45815. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  45816. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  45817. /**
  45818. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  45819. * @param pipelineContext defines the pipeline context to use
  45820. * @param uniformsNames defines the list of uniform names
  45821. * @returns an array of webGL uniform locations
  45822. */
  45823. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  45824. /**
  45825. * Gets the lsit of active attributes for a given webGL program
  45826. * @param pipelineContext defines the pipeline context to use
  45827. * @param attributesNames defines the list of attribute names to get
  45828. * @returns an array of indices indicating the offset of each attribute
  45829. */
  45830. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  45831. /**
  45832. * Binds an effect to the webGL context
  45833. * @param effect defines the effect to bind
  45834. */
  45835. bindSamplers(effect: Effect): void;
  45836. /**
  45837. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  45838. * @param effect defines the effect to activate
  45839. */
  45840. enableEffect(effect: Effect): void;
  45841. /**
  45842. * Set various states to the webGL context
  45843. * @param culling defines backface culling state
  45844. * @param zOffset defines the value to apply to zOffset (0 by default)
  45845. * @param force defines if states must be applied even if cache is up to date
  45846. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  45847. */
  45848. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  45849. /**
  45850. * Set the value of an uniform to an array of int32
  45851. * @param uniform defines the webGL uniform location where to store the value
  45852. * @param array defines the array of int32 to store
  45853. */
  45854. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  45855. /**
  45856. * Set the value of an uniform to an array of int32 (stored as vec2)
  45857. * @param uniform defines the webGL uniform location where to store the value
  45858. * @param array defines the array of int32 to store
  45859. */
  45860. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  45861. /**
  45862. * Set the value of an uniform to an array of int32 (stored as vec3)
  45863. * @param uniform defines the webGL uniform location where to store the value
  45864. * @param array defines the array of int32 to store
  45865. */
  45866. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  45867. /**
  45868. * Set the value of an uniform to an array of int32 (stored as vec4)
  45869. * @param uniform defines the webGL uniform location where to store the value
  45870. * @param array defines the array of int32 to store
  45871. */
  45872. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  45873. /**
  45874. * Set the value of an uniform to an array of float32
  45875. * @param uniform defines the webGL uniform location where to store the value
  45876. * @param array defines the array of float32 to store
  45877. */
  45878. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  45879. /**
  45880. * Set the value of an uniform to an array of float32 (stored as vec2)
  45881. * @param uniform defines the webGL uniform location where to store the value
  45882. * @param array defines the array of float32 to store
  45883. */
  45884. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  45885. /**
  45886. * Set the value of an uniform to an array of float32 (stored as vec3)
  45887. * @param uniform defines the webGL uniform location where to store the value
  45888. * @param array defines the array of float32 to store
  45889. */
  45890. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  45891. /**
  45892. * Set the value of an uniform to an array of float32 (stored as vec4)
  45893. * @param uniform defines the webGL uniform location where to store the value
  45894. * @param array defines the array of float32 to store
  45895. */
  45896. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  45897. /**
  45898. * Set the value of an uniform to an array of number
  45899. * @param uniform defines the webGL uniform location where to store the value
  45900. * @param array defines the array of number to store
  45901. */
  45902. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  45903. /**
  45904. * Set the value of an uniform to an array of number (stored as vec2)
  45905. * @param uniform defines the webGL uniform location where to store the value
  45906. * @param array defines the array of number to store
  45907. */
  45908. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  45909. /**
  45910. * Set the value of an uniform to an array of number (stored as vec3)
  45911. * @param uniform defines the webGL uniform location where to store the value
  45912. * @param array defines the array of number to store
  45913. */
  45914. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  45915. /**
  45916. * Set the value of an uniform to an array of number (stored as vec4)
  45917. * @param uniform defines the webGL uniform location where to store the value
  45918. * @param array defines the array of number to store
  45919. */
  45920. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  45921. /**
  45922. * Set the value of an uniform to an array of float32 (stored as matrices)
  45923. * @param uniform defines the webGL uniform location where to store the value
  45924. * @param matrices defines the array of float32 to store
  45925. */
  45926. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  45927. /**
  45928. * Set the value of an uniform to a matrix (3x3)
  45929. * @param uniform defines the webGL uniform location where to store the value
  45930. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  45931. */
  45932. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45933. /**
  45934. * Set the value of an uniform to a matrix (2x2)
  45935. * @param uniform defines the webGL uniform location where to store the value
  45936. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  45937. */
  45938. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45939. /**
  45940. * Set the value of an uniform to a number (float)
  45941. * @param uniform defines the webGL uniform location where to store the value
  45942. * @param value defines the float number to store
  45943. */
  45944. setFloat(uniform: WebGLUniformLocation, value: number): void;
  45945. /**
  45946. * Set the value of an uniform to a vec2
  45947. * @param uniform defines the webGL uniform location where to store the value
  45948. * @param x defines the 1st component of the value
  45949. * @param y defines the 2nd component of the value
  45950. */
  45951. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  45952. /**
  45953. * Set the value of an uniform to a vec3
  45954. * @param uniform defines the webGL uniform location where to store the value
  45955. * @param x defines the 1st component of the value
  45956. * @param y defines the 2nd component of the value
  45957. * @param z defines the 3rd component of the value
  45958. */
  45959. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  45960. /**
  45961. * Set the value of an uniform to a boolean
  45962. * @param uniform defines the webGL uniform location where to store the value
  45963. * @param bool defines the boolean to store
  45964. */
  45965. setBool(uniform: WebGLUniformLocation, bool: number): void;
  45966. /**
  45967. * Set the value of an uniform to a vec4
  45968. * @param uniform defines the webGL uniform location where to store the value
  45969. * @param x defines the 1st component of the value
  45970. * @param y defines the 2nd component of the value
  45971. * @param z defines the 3rd component of the value
  45972. * @param w defines the 4th component of the value
  45973. */
  45974. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  45975. /**
  45976. * Sets the current alpha mode
  45977. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  45978. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  45979. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  45980. */
  45981. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  45982. /**
  45983. * Bind webGl buffers directly to the webGL context
  45984. * @param vertexBuffers defines the vertex buffer to bind
  45985. * @param indexBuffer defines the index buffer to bind
  45986. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  45987. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  45988. * @param effect defines the effect associated with the vertex buffer
  45989. */
  45990. bindBuffers(vertexBuffers: {
  45991. [key: string]: VertexBuffer;
  45992. }, indexBuffer: DataBuffer, effect: Effect): void;
  45993. /**
  45994. * Force the entire cache to be cleared
  45995. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  45996. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  45997. */
  45998. wipeCaches(bruteForce?: boolean): void;
  45999. /**
  46000. * Send a draw order
  46001. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  46002. * @param indexStart defines the starting index
  46003. * @param indexCount defines the number of index to draw
  46004. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46005. */
  46006. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  46007. /**
  46008. * Draw a list of indexed primitives
  46009. * @param fillMode defines the primitive to use
  46010. * @param indexStart defines the starting index
  46011. * @param indexCount defines the number of index to draw
  46012. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46013. */
  46014. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  46015. /**
  46016. * Draw a list of unindexed primitives
  46017. * @param fillMode defines the primitive to use
  46018. * @param verticesStart defines the index of first vertex to draw
  46019. * @param verticesCount defines the count of vertices to draw
  46020. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46021. */
  46022. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  46023. /** @hidden */
  46024. _createTexture(): WebGLTexture;
  46025. /** @hidden */
  46026. _releaseTexture(texture: InternalTexture): void;
  46027. /**
  46028. * Usually called from Texture.ts.
  46029. * Passed information to create a WebGLTexture
  46030. * @param urlArg defines a value which contains one of the following:
  46031. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  46032. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  46033. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  46034. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  46035. * @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)
  46036. * @param scene needed for loading to the correct scene
  46037. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  46038. * @param onLoad optional callback to be called upon successful completion
  46039. * @param onError optional callback to be called upon failure
  46040. * @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
  46041. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  46042. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  46043. * @param forcedExtension defines the extension to use to pick the right loader
  46044. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  46045. * @returns a InternalTexture for assignment back into BABYLON.Texture
  46046. */
  46047. 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;
  46048. /**
  46049. * Creates a new render target texture
  46050. * @param size defines the size of the texture
  46051. * @param options defines the options used to create the texture
  46052. * @returns a new render target texture stored in an InternalTexture
  46053. */
  46054. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  46055. /**
  46056. * Update the sampling mode of a given texture
  46057. * @param samplingMode defines the required sampling mode
  46058. * @param texture defines the texture to update
  46059. */
  46060. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  46061. /**
  46062. * Binds the frame buffer to the specified texture.
  46063. * @param texture The texture to render to or null for the default canvas
  46064. * @param faceIndex The face of the texture to render to in case of cube texture
  46065. * @param requiredWidth The width of the target to render to
  46066. * @param requiredHeight The height of the target to render to
  46067. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  46068. * @param depthStencilTexture The depth stencil texture to use to render
  46069. * @param lodLevel defines le lod level to bind to the frame buffer
  46070. */
  46071. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  46072. /**
  46073. * Unbind the current render target texture from the webGL context
  46074. * @param texture defines the render target texture to unbind
  46075. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  46076. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  46077. */
  46078. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  46079. /**
  46080. * Creates a dynamic vertex buffer
  46081. * @param vertices the data for the dynamic vertex buffer
  46082. * @returns the new WebGL dynamic buffer
  46083. */
  46084. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  46085. /**
  46086. * Update the content of a dynamic texture
  46087. * @param texture defines the texture to update
  46088. * @param canvas defines the canvas containing the source
  46089. * @param invertY defines if data must be stored with Y axis inverted
  46090. * @param premulAlpha defines if alpha is stored as premultiplied
  46091. * @param format defines the format of the data
  46092. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  46093. */
  46094. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  46095. /**
  46096. * Gets a boolean indicating if all created effects are ready
  46097. * @returns true if all effects are ready
  46098. */
  46099. areAllEffectsReady(): boolean;
  46100. /**
  46101. * @hidden
  46102. * Get the current error code of the webGL context
  46103. * @returns the error code
  46104. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  46105. */
  46106. getError(): number;
  46107. /** @hidden */
  46108. _getUnpackAlignement(): number;
  46109. /** @hidden */
  46110. _unpackFlipY(value: boolean): void;
  46111. /**
  46112. * Update a dynamic index buffer
  46113. * @param indexBuffer defines the target index buffer
  46114. * @param indices defines the data to update
  46115. * @param offset defines the offset in the target index buffer where update should start
  46116. */
  46117. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  46118. /**
  46119. * Updates a dynamic vertex buffer.
  46120. * @param vertexBuffer the vertex buffer to update
  46121. * @param vertices the data used to update the vertex buffer
  46122. * @param byteOffset the byte offset of the data (optional)
  46123. * @param byteLength the byte length of the data (optional)
  46124. */
  46125. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  46126. /** @hidden */
  46127. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  46128. /** @hidden */
  46129. _bindTexture(channel: number, texture: InternalTexture): void;
  46130. protected _deleteBuffer(buffer: WebGLBuffer): void;
  46131. /**
  46132. * 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
  46133. */
  46134. releaseEffects(): void;
  46135. displayLoadingUI(): void;
  46136. hideLoadingUI(): void;
  46137. /** @hidden */
  46138. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46139. /** @hidden */
  46140. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46141. /** @hidden */
  46142. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46143. /** @hidden */
  46144. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  46145. }
  46146. }
  46147. declare module BABYLON {
  46148. /** @hidden */
  46149. export class _OcclusionDataStorage {
  46150. /** @hidden */
  46151. occlusionInternalRetryCounter: number;
  46152. /** @hidden */
  46153. isOcclusionQueryInProgress: boolean;
  46154. /** @hidden */
  46155. isOccluded: boolean;
  46156. /** @hidden */
  46157. occlusionRetryCount: number;
  46158. /** @hidden */
  46159. occlusionType: number;
  46160. /** @hidden */
  46161. occlusionQueryAlgorithmType: number;
  46162. }
  46163. interface Engine {
  46164. /**
  46165. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  46166. * @return the new query
  46167. */
  46168. createQuery(): WebGLQuery;
  46169. /**
  46170. * Delete and release a webGL query
  46171. * @param query defines the query to delete
  46172. * @return the current engine
  46173. */
  46174. deleteQuery(query: WebGLQuery): Engine;
  46175. /**
  46176. * Check if a given query has resolved and got its value
  46177. * @param query defines the query to check
  46178. * @returns true if the query got its value
  46179. */
  46180. isQueryResultAvailable(query: WebGLQuery): boolean;
  46181. /**
  46182. * Gets the value of a given query
  46183. * @param query defines the query to check
  46184. * @returns the value of the query
  46185. */
  46186. getQueryResult(query: WebGLQuery): number;
  46187. /**
  46188. * Initiates an occlusion query
  46189. * @param algorithmType defines the algorithm to use
  46190. * @param query defines the query to use
  46191. * @returns the current engine
  46192. * @see http://doc.babylonjs.com/features/occlusionquery
  46193. */
  46194. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  46195. /**
  46196. * Ends an occlusion query
  46197. * @see http://doc.babylonjs.com/features/occlusionquery
  46198. * @param algorithmType defines the algorithm to use
  46199. * @returns the current engine
  46200. */
  46201. endOcclusionQuery(algorithmType: number): Engine;
  46202. /**
  46203. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  46204. * Please note that only one query can be issued at a time
  46205. * @returns a time token used to track the time span
  46206. */
  46207. startTimeQuery(): Nullable<_TimeToken>;
  46208. /**
  46209. * Ends a time query
  46210. * @param token defines the token used to measure the time span
  46211. * @returns the time spent (in ns)
  46212. */
  46213. endTimeQuery(token: _TimeToken): int;
  46214. /** @hidden */
  46215. _currentNonTimestampToken: Nullable<_TimeToken>;
  46216. /** @hidden */
  46217. _createTimeQuery(): WebGLQuery;
  46218. /** @hidden */
  46219. _deleteTimeQuery(query: WebGLQuery): void;
  46220. /** @hidden */
  46221. _getGlAlgorithmType(algorithmType: number): number;
  46222. /** @hidden */
  46223. _getTimeQueryResult(query: WebGLQuery): any;
  46224. /** @hidden */
  46225. _getTimeQueryAvailability(query: WebGLQuery): any;
  46226. }
  46227. interface AbstractMesh {
  46228. /**
  46229. * Backing filed
  46230. * @hidden
  46231. */
  46232. __occlusionDataStorage: _OcclusionDataStorage;
  46233. /**
  46234. * Access property
  46235. * @hidden
  46236. */
  46237. _occlusionDataStorage: _OcclusionDataStorage;
  46238. /**
  46239. * 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.
  46240. * The default value is -1 which means don't break the query and wait till the result
  46241. * @see http://doc.babylonjs.com/features/occlusionquery
  46242. */
  46243. occlusionRetryCount: number;
  46244. /**
  46245. * 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:
  46246. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  46247. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  46248. * * 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.
  46249. * @see http://doc.babylonjs.com/features/occlusionquery
  46250. */
  46251. occlusionType: number;
  46252. /**
  46253. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  46254. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  46255. * * 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.
  46256. * @see http://doc.babylonjs.com/features/occlusionquery
  46257. */
  46258. occlusionQueryAlgorithmType: number;
  46259. /**
  46260. * 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
  46261. * @see http://doc.babylonjs.com/features/occlusionquery
  46262. */
  46263. isOccluded: boolean;
  46264. /**
  46265. * Flag to check the progress status of the query
  46266. * @see http://doc.babylonjs.com/features/occlusionquery
  46267. */
  46268. isOcclusionQueryInProgress: boolean;
  46269. }
  46270. }
  46271. declare module BABYLON {
  46272. /** @hidden */
  46273. export var _forceTransformFeedbackToBundle: boolean;
  46274. interface Engine {
  46275. /**
  46276. * Creates a webGL transform feedback object
  46277. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  46278. * @returns the webGL transform feedback object
  46279. */
  46280. createTransformFeedback(): WebGLTransformFeedback;
  46281. /**
  46282. * Delete a webGL transform feedback object
  46283. * @param value defines the webGL transform feedback object to delete
  46284. */
  46285. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  46286. /**
  46287. * Bind a webGL transform feedback object to the webgl context
  46288. * @param value defines the webGL transform feedback object to bind
  46289. */
  46290. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  46291. /**
  46292. * Begins a transform feedback operation
  46293. * @param usePoints defines if points or triangles must be used
  46294. */
  46295. beginTransformFeedback(usePoints: boolean): void;
  46296. /**
  46297. * Ends a transform feedback operation
  46298. */
  46299. endTransformFeedback(): void;
  46300. /**
  46301. * Specify the varyings to use with transform feedback
  46302. * @param program defines the associated webGL program
  46303. * @param value defines the list of strings representing the varying names
  46304. */
  46305. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  46306. /**
  46307. * Bind a webGL buffer for a transform feedback operation
  46308. * @param value defines the webGL buffer to bind
  46309. */
  46310. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  46311. }
  46312. }
  46313. declare module BABYLON {
  46314. /**
  46315. * Creation options of the multi render target texture.
  46316. */
  46317. export interface IMultiRenderTargetOptions {
  46318. /**
  46319. * Define if the texture needs to create mip maps after render.
  46320. */
  46321. generateMipMaps?: boolean;
  46322. /**
  46323. * Define the types of all the draw buffers we want to create
  46324. */
  46325. types?: number[];
  46326. /**
  46327. * Define the sampling modes of all the draw buffers we want to create
  46328. */
  46329. samplingModes?: number[];
  46330. /**
  46331. * Define if a depth buffer is required
  46332. */
  46333. generateDepthBuffer?: boolean;
  46334. /**
  46335. * Define if a stencil buffer is required
  46336. */
  46337. generateStencilBuffer?: boolean;
  46338. /**
  46339. * Define if a depth texture is required instead of a depth buffer
  46340. */
  46341. generateDepthTexture?: boolean;
  46342. /**
  46343. * Define the number of desired draw buffers
  46344. */
  46345. textureCount?: number;
  46346. /**
  46347. * Define if aspect ratio should be adapted to the texture or stay the scene one
  46348. */
  46349. doNotChangeAspectRatio?: boolean;
  46350. /**
  46351. * Define the default type of the buffers we are creating
  46352. */
  46353. defaultType?: number;
  46354. }
  46355. /**
  46356. * A multi render target, like a render target provides the ability to render to a texture.
  46357. * Unlike the render target, it can render to several draw buffers in one draw.
  46358. * This is specially interesting in deferred rendering or for any effects requiring more than
  46359. * just one color from a single pass.
  46360. */
  46361. export class MultiRenderTarget extends RenderTargetTexture {
  46362. private _internalTextures;
  46363. private _textures;
  46364. private _multiRenderTargetOptions;
  46365. /**
  46366. * Get if draw buffers are currently supported by the used hardware and browser.
  46367. */
  46368. get isSupported(): boolean;
  46369. /**
  46370. * Get the list of textures generated by the multi render target.
  46371. */
  46372. get textures(): Texture[];
  46373. /**
  46374. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  46375. */
  46376. get depthTexture(): Texture;
  46377. /**
  46378. * Set the wrapping mode on U of all the textures we are rendering to.
  46379. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  46380. */
  46381. set wrapU(wrap: number);
  46382. /**
  46383. * Set the wrapping mode on V of all the textures we are rendering to.
  46384. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  46385. */
  46386. set wrapV(wrap: number);
  46387. /**
  46388. * Instantiate a new multi render target texture.
  46389. * A multi render target, like a render target provides the ability to render to a texture.
  46390. * Unlike the render target, it can render to several draw buffers in one draw.
  46391. * This is specially interesting in deferred rendering or for any effects requiring more than
  46392. * just one color from a single pass.
  46393. * @param name Define the name of the texture
  46394. * @param size Define the size of the buffers to render to
  46395. * @param count Define the number of target we are rendering into
  46396. * @param scene Define the scene the texture belongs to
  46397. * @param options Define the options used to create the multi render target
  46398. */
  46399. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  46400. /** @hidden */
  46401. _rebuild(): void;
  46402. private _createInternalTextures;
  46403. private _createTextures;
  46404. /**
  46405. * Define the number of samples used if MSAA is enabled.
  46406. */
  46407. get samples(): number;
  46408. set samples(value: number);
  46409. /**
  46410. * Resize all the textures in the multi render target.
  46411. * Be carrefull as it will recreate all the data in the new texture.
  46412. * @param size Define the new size
  46413. */
  46414. resize(size: any): void;
  46415. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  46416. /**
  46417. * Dispose the render targets and their associated resources
  46418. */
  46419. dispose(): void;
  46420. /**
  46421. * Release all the underlying texture used as draw buffers.
  46422. */
  46423. releaseInternalTextures(): void;
  46424. }
  46425. }
  46426. declare module BABYLON {
  46427. interface ThinEngine {
  46428. /**
  46429. * Unbind a list of render target textures from the webGL context
  46430. * This is used only when drawBuffer extension or webGL2 are active
  46431. * @param textures defines the render target textures to unbind
  46432. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  46433. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  46434. */
  46435. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  46436. /**
  46437. * Create a multi render target texture
  46438. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  46439. * @param size defines the size of the texture
  46440. * @param options defines the creation options
  46441. * @returns the cube texture as an InternalTexture
  46442. */
  46443. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  46444. /**
  46445. * Update the sample count for a given multiple render target texture
  46446. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  46447. * @param textures defines the textures to update
  46448. * @param samples defines the sample count to set
  46449. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  46450. */
  46451. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  46452. }
  46453. }
  46454. declare module BABYLON {
  46455. /**
  46456. * Class used to define an additional view for the engine
  46457. * @see https://doc.babylonjs.com/how_to/multi_canvases
  46458. */
  46459. export class EngineView {
  46460. /** Defines the canvas where to render the view */
  46461. target: HTMLCanvasElement;
  46462. /** Defines an optional camera used to render the view (will use active camera else) */
  46463. camera?: Camera;
  46464. }
  46465. interface Engine {
  46466. /**
  46467. * Gets or sets the HTML element to use for attaching events
  46468. */
  46469. inputElement: Nullable<HTMLElement>;
  46470. /**
  46471. * Gets the current engine view
  46472. * @see https://doc.babylonjs.com/how_to/multi_canvases
  46473. */
  46474. activeView: Nullable<EngineView>;
  46475. /** Gets or sets the list of views */
  46476. views: EngineView[];
  46477. /**
  46478. * Register a new child canvas
  46479. * @param canvas defines the canvas to register
  46480. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  46481. * @returns the associated view
  46482. */
  46483. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  46484. /**
  46485. * Remove a registered child canvas
  46486. * @param canvas defines the canvas to remove
  46487. * @returns the current engine
  46488. */
  46489. unRegisterView(canvas: HTMLCanvasElement): Engine;
  46490. }
  46491. }
  46492. declare module BABYLON {
  46493. /**
  46494. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  46495. */
  46496. export interface CubeMapInfo {
  46497. /**
  46498. * The pixel array for the front face.
  46499. * This is stored in format, left to right, up to down format.
  46500. */
  46501. front: Nullable<ArrayBufferView>;
  46502. /**
  46503. * The pixel array for the back face.
  46504. * This is stored in format, left to right, up to down format.
  46505. */
  46506. back: Nullable<ArrayBufferView>;
  46507. /**
  46508. * The pixel array for the left face.
  46509. * This is stored in format, left to right, up to down format.
  46510. */
  46511. left: Nullable<ArrayBufferView>;
  46512. /**
  46513. * The pixel array for the right face.
  46514. * This is stored in format, left to right, up to down format.
  46515. */
  46516. right: Nullable<ArrayBufferView>;
  46517. /**
  46518. * The pixel array for the up face.
  46519. * This is stored in format, left to right, up to down format.
  46520. */
  46521. up: Nullable<ArrayBufferView>;
  46522. /**
  46523. * The pixel array for the down face.
  46524. * This is stored in format, left to right, up to down format.
  46525. */
  46526. down: Nullable<ArrayBufferView>;
  46527. /**
  46528. * The size of the cubemap stored.
  46529. *
  46530. * Each faces will be size * size pixels.
  46531. */
  46532. size: number;
  46533. /**
  46534. * The format of the texture.
  46535. *
  46536. * RGBA, RGB.
  46537. */
  46538. format: number;
  46539. /**
  46540. * The type of the texture data.
  46541. *
  46542. * UNSIGNED_INT, FLOAT.
  46543. */
  46544. type: number;
  46545. /**
  46546. * Specifies whether the texture is in gamma space.
  46547. */
  46548. gammaSpace: boolean;
  46549. }
  46550. /**
  46551. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  46552. */
  46553. export class PanoramaToCubeMapTools {
  46554. private static FACE_FRONT;
  46555. private static FACE_BACK;
  46556. private static FACE_RIGHT;
  46557. private static FACE_LEFT;
  46558. private static FACE_DOWN;
  46559. private static FACE_UP;
  46560. /**
  46561. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  46562. *
  46563. * @param float32Array The source data.
  46564. * @param inputWidth The width of the input panorama.
  46565. * @param inputHeight The height of the input panorama.
  46566. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  46567. * @return The cubemap data
  46568. */
  46569. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  46570. private static CreateCubemapTexture;
  46571. private static CalcProjectionSpherical;
  46572. }
  46573. }
  46574. declare module BABYLON {
  46575. /**
  46576. * Helper class dealing with the extraction of spherical polynomial dataArray
  46577. * from a cube map.
  46578. */
  46579. export class CubeMapToSphericalPolynomialTools {
  46580. private static FileFaces;
  46581. /**
  46582. * Converts a texture to the according Spherical Polynomial data.
  46583. * This extracts the first 3 orders only as they are the only one used in the lighting.
  46584. *
  46585. * @param texture The texture to extract the information from.
  46586. * @return The Spherical Polynomial data.
  46587. */
  46588. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  46589. /**
  46590. * Converts a cubemap to the according Spherical Polynomial data.
  46591. * This extracts the first 3 orders only as they are the only one used in the lighting.
  46592. *
  46593. * @param cubeInfo The Cube map to extract the information from.
  46594. * @return The Spherical Polynomial data.
  46595. */
  46596. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  46597. }
  46598. }
  46599. declare module BABYLON {
  46600. interface BaseTexture {
  46601. /**
  46602. * Get the polynomial representation of the texture data.
  46603. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  46604. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  46605. */
  46606. sphericalPolynomial: Nullable<SphericalPolynomial>;
  46607. }
  46608. }
  46609. declare module BABYLON {
  46610. /** @hidden */
  46611. export var rgbdEncodePixelShader: {
  46612. name: string;
  46613. shader: string;
  46614. };
  46615. }
  46616. declare module BABYLON {
  46617. /** @hidden */
  46618. export var rgbdDecodePixelShader: {
  46619. name: string;
  46620. shader: string;
  46621. };
  46622. }
  46623. declare module BABYLON {
  46624. /**
  46625. * Raw texture data and descriptor sufficient for WebGL texture upload
  46626. */
  46627. export interface EnvironmentTextureInfo {
  46628. /**
  46629. * Version of the environment map
  46630. */
  46631. version: number;
  46632. /**
  46633. * Width of image
  46634. */
  46635. width: number;
  46636. /**
  46637. * Irradiance information stored in the file.
  46638. */
  46639. irradiance: any;
  46640. /**
  46641. * Specular information stored in the file.
  46642. */
  46643. specular: any;
  46644. }
  46645. /**
  46646. * Defines One Image in the file. It requires only the position in the file
  46647. * as well as the length.
  46648. */
  46649. interface BufferImageData {
  46650. /**
  46651. * Length of the image data.
  46652. */
  46653. length: number;
  46654. /**
  46655. * Position of the data from the null terminator delimiting the end of the JSON.
  46656. */
  46657. position: number;
  46658. }
  46659. /**
  46660. * Defines the specular data enclosed in the file.
  46661. * This corresponds to the version 1 of the data.
  46662. */
  46663. export interface EnvironmentTextureSpecularInfoV1 {
  46664. /**
  46665. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  46666. */
  46667. specularDataPosition?: number;
  46668. /**
  46669. * This contains all the images data needed to reconstruct the cubemap.
  46670. */
  46671. mipmaps: Array<BufferImageData>;
  46672. /**
  46673. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  46674. */
  46675. lodGenerationScale: number;
  46676. }
  46677. /**
  46678. * Sets of helpers addressing the serialization and deserialization of environment texture
  46679. * stored in a BabylonJS env file.
  46680. * Those files are usually stored as .env files.
  46681. */
  46682. export class EnvironmentTextureTools {
  46683. /**
  46684. * Magic number identifying the env file.
  46685. */
  46686. private static _MagicBytes;
  46687. /**
  46688. * Gets the environment info from an env file.
  46689. * @param data The array buffer containing the .env bytes.
  46690. * @returns the environment file info (the json header) if successfully parsed.
  46691. */
  46692. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  46693. /**
  46694. * Creates an environment texture from a loaded cube texture.
  46695. * @param texture defines the cube texture to convert in env file
  46696. * @return a promise containing the environment data if succesfull.
  46697. */
  46698. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  46699. /**
  46700. * Creates a JSON representation of the spherical data.
  46701. * @param texture defines the texture containing the polynomials
  46702. * @return the JSON representation of the spherical info
  46703. */
  46704. private static _CreateEnvTextureIrradiance;
  46705. /**
  46706. * Creates the ArrayBufferViews used for initializing environment texture image data.
  46707. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  46708. * @param info parameters that determine what views will be created for accessing the underlying buffer
  46709. * @return the views described by info providing access to the underlying buffer
  46710. */
  46711. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  46712. /**
  46713. * Uploads the texture info contained in the env file to the GPU.
  46714. * @param texture defines the internal texture to upload to
  46715. * @param arrayBuffer defines the buffer cotaining the data to load
  46716. * @param info defines the texture info retrieved through the GetEnvInfo method
  46717. * @returns a promise
  46718. */
  46719. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  46720. private static _OnImageReadyAsync;
  46721. /**
  46722. * Uploads the levels of image data to the GPU.
  46723. * @param texture defines the internal texture to upload to
  46724. * @param imageData defines the array buffer views of image data [mipmap][face]
  46725. * @returns a promise
  46726. */
  46727. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  46728. /**
  46729. * Uploads spherical polynomials information to the texture.
  46730. * @param texture defines the texture we are trying to upload the information to
  46731. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  46732. */
  46733. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  46734. /** @hidden */
  46735. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  46736. }
  46737. }
  46738. declare module BABYLON {
  46739. /**
  46740. * Contains position and normal vectors for a vertex
  46741. */
  46742. export class PositionNormalVertex {
  46743. /** the position of the vertex (defaut: 0,0,0) */
  46744. position: Vector3;
  46745. /** the normal of the vertex (defaut: 0,1,0) */
  46746. normal: Vector3;
  46747. /**
  46748. * Creates a PositionNormalVertex
  46749. * @param position the position of the vertex (defaut: 0,0,0)
  46750. * @param normal the normal of the vertex (defaut: 0,1,0)
  46751. */
  46752. constructor(
  46753. /** the position of the vertex (defaut: 0,0,0) */
  46754. position?: Vector3,
  46755. /** the normal of the vertex (defaut: 0,1,0) */
  46756. normal?: Vector3);
  46757. /**
  46758. * Clones the PositionNormalVertex
  46759. * @returns the cloned PositionNormalVertex
  46760. */
  46761. clone(): PositionNormalVertex;
  46762. }
  46763. /**
  46764. * Contains position, normal and uv vectors for a vertex
  46765. */
  46766. export class PositionNormalTextureVertex {
  46767. /** the position of the vertex (defaut: 0,0,0) */
  46768. position: Vector3;
  46769. /** the normal of the vertex (defaut: 0,1,0) */
  46770. normal: Vector3;
  46771. /** the uv of the vertex (default: 0,0) */
  46772. uv: Vector2;
  46773. /**
  46774. * Creates a PositionNormalTextureVertex
  46775. * @param position the position of the vertex (defaut: 0,0,0)
  46776. * @param normal the normal of the vertex (defaut: 0,1,0)
  46777. * @param uv the uv of the vertex (default: 0,0)
  46778. */
  46779. constructor(
  46780. /** the position of the vertex (defaut: 0,0,0) */
  46781. position?: Vector3,
  46782. /** the normal of the vertex (defaut: 0,1,0) */
  46783. normal?: Vector3,
  46784. /** the uv of the vertex (default: 0,0) */
  46785. uv?: Vector2);
  46786. /**
  46787. * Clones the PositionNormalTextureVertex
  46788. * @returns the cloned PositionNormalTextureVertex
  46789. */
  46790. clone(): PositionNormalTextureVertex;
  46791. }
  46792. }
  46793. declare module BABYLON {
  46794. /** @hidden */
  46795. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  46796. private _genericAttributeLocation;
  46797. private _varyingLocationCount;
  46798. private _varyingLocationMap;
  46799. private _replacements;
  46800. private _textureCount;
  46801. private _uniforms;
  46802. lineProcessor(line: string): string;
  46803. attributeProcessor(attribute: string): string;
  46804. varyingProcessor(varying: string, isFragment: boolean): string;
  46805. uniformProcessor(uniform: string): string;
  46806. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  46807. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  46808. }
  46809. }
  46810. declare module BABYLON {
  46811. /**
  46812. * Container for accessors for natively-stored mesh data buffers.
  46813. */
  46814. class NativeDataBuffer extends DataBuffer {
  46815. /**
  46816. * Accessor value used to identify/retrieve a natively-stored index buffer.
  46817. */
  46818. nativeIndexBuffer?: any;
  46819. /**
  46820. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  46821. */
  46822. nativeVertexBuffer?: any;
  46823. }
  46824. /** @hidden */
  46825. class NativeTexture extends InternalTexture {
  46826. getInternalTexture(): InternalTexture;
  46827. getViewCount(): number;
  46828. }
  46829. /** @hidden */
  46830. export class NativeEngine extends Engine {
  46831. private readonly _native;
  46832. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  46833. private readonly INVALID_HANDLE;
  46834. getHardwareScalingLevel(): number;
  46835. constructor();
  46836. /**
  46837. * Can be used to override the current requestAnimationFrame requester.
  46838. * @hidden
  46839. */
  46840. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  46841. /**
  46842. * Override default engine behavior.
  46843. * @param color
  46844. * @param backBuffer
  46845. * @param depth
  46846. * @param stencil
  46847. */
  46848. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  46849. /**
  46850. * Gets host document
  46851. * @returns the host document object
  46852. */
  46853. getHostDocument(): Nullable<Document>;
  46854. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  46855. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  46856. createVertexBuffer(data: DataArray): NativeDataBuffer;
  46857. recordVertexArrayObject(vertexBuffers: {
  46858. [key: string]: VertexBuffer;
  46859. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  46860. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  46861. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  46862. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  46863. /**
  46864. * Draw a list of indexed primitives
  46865. * @param fillMode defines the primitive to use
  46866. * @param indexStart defines the starting index
  46867. * @param indexCount defines the number of index to draw
  46868. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46869. */
  46870. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  46871. /**
  46872. * Draw a list of unindexed primitives
  46873. * @param fillMode defines the primitive to use
  46874. * @param verticesStart defines the index of first vertex to draw
  46875. * @param verticesCount defines the count of vertices to draw
  46876. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46877. */
  46878. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  46879. createPipelineContext(): IPipelineContext;
  46880. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  46881. /** @hidden */
  46882. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  46883. /** @hidden */
  46884. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  46885. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  46886. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  46887. protected _setProgram(program: WebGLProgram): void;
  46888. _releaseEffect(effect: Effect): void;
  46889. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  46890. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  46891. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  46892. bindSamplers(effect: Effect): void;
  46893. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  46894. getRenderWidth(useScreen?: boolean): number;
  46895. getRenderHeight(useScreen?: boolean): number;
  46896. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  46897. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  46898. /**
  46899. * Set the z offset to apply to current rendering
  46900. * @param value defines the offset to apply
  46901. */
  46902. setZOffset(value: number): void;
  46903. /**
  46904. * Gets the current value of the zOffset
  46905. * @returns the current zOffset state
  46906. */
  46907. getZOffset(): number;
  46908. /**
  46909. * Enable or disable depth buffering
  46910. * @param enable defines the state to set
  46911. */
  46912. setDepthBuffer(enable: boolean): void;
  46913. /**
  46914. * Gets a boolean indicating if depth writing is enabled
  46915. * @returns the current depth writing state
  46916. */
  46917. getDepthWrite(): boolean;
  46918. /**
  46919. * Enable or disable depth writing
  46920. * @param enable defines the state to set
  46921. */
  46922. setDepthWrite(enable: boolean): void;
  46923. /**
  46924. * Enable or disable color writing
  46925. * @param enable defines the state to set
  46926. */
  46927. setColorWrite(enable: boolean): void;
  46928. /**
  46929. * Gets a boolean indicating if color writing is enabled
  46930. * @returns the current color writing state
  46931. */
  46932. getColorWrite(): boolean;
  46933. /**
  46934. * Sets alpha constants used by some alpha blending modes
  46935. * @param r defines the red component
  46936. * @param g defines the green component
  46937. * @param b defines the blue component
  46938. * @param a defines the alpha component
  46939. */
  46940. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  46941. /**
  46942. * Sets the current alpha mode
  46943. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  46944. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  46945. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  46946. */
  46947. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  46948. /**
  46949. * Gets the current alpha mode
  46950. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  46951. * @returns the current alpha mode
  46952. */
  46953. getAlphaMode(): number;
  46954. setInt(uniform: WebGLUniformLocation, int: number): void;
  46955. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  46956. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  46957. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  46958. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  46959. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  46960. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  46961. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  46962. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  46963. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  46964. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  46965. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  46966. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  46967. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  46968. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46969. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46970. setFloat(uniform: WebGLUniformLocation, value: number): void;
  46971. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  46972. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  46973. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  46974. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  46975. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  46976. wipeCaches(bruteForce?: boolean): void;
  46977. _createTexture(): WebGLTexture;
  46978. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  46979. /**
  46980. * Usually called from BABYLON.Texture.ts.
  46981. * Passed information to create a WebGLTexture
  46982. * @param urlArg defines a value which contains one of the following:
  46983. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  46984. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  46985. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  46986. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  46987. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  46988. * @param scene needed for loading to the correct scene
  46989. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  46990. * @param onLoad optional callback to be called upon successful completion
  46991. * @param onError optional callback to be called upon failure
  46992. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  46993. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  46994. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  46995. * @param forcedExtension defines the extension to use to pick the right loader
  46996. * @returns a InternalTexture for assignment back into BABYLON.Texture
  46997. */
  46998. 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;
  46999. /**
  47000. * Creates a cube texture
  47001. * @param rootUrl defines the url where the files to load is located
  47002. * @param scene defines the current scene
  47003. * @param files defines the list of files to load (1 per face)
  47004. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  47005. * @param onLoad defines an optional callback raised when the texture is loaded
  47006. * @param onError defines an optional callback raised if there is an issue to load the texture
  47007. * @param format defines the format of the data
  47008. * @param forcedExtension defines the extension to use to pick the right loader
  47009. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  47010. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  47011. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  47012. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  47013. * @returns the cube texture as an InternalTexture
  47014. */
  47015. 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;
  47016. private _getSamplingFilter;
  47017. private static _GetNativeTextureFormat;
  47018. createRenderTargetTexture(size: number | {
  47019. width: number;
  47020. height: number;
  47021. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  47022. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  47023. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  47024. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  47025. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  47026. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  47027. /**
  47028. * Updates a dynamic vertex buffer.
  47029. * @param vertexBuffer the vertex buffer to update
  47030. * @param data the data used to update the vertex buffer
  47031. * @param byteOffset the byte offset of the data (optional)
  47032. * @param byteLength the byte length of the data (optional)
  47033. */
  47034. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  47035. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  47036. private _updateAnisotropicLevel;
  47037. private _getAddressMode;
  47038. /** @hidden */
  47039. _bindTexture(channel: number, texture: InternalTexture): void;
  47040. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  47041. releaseEffects(): void;
  47042. /** @hidden */
  47043. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47044. /** @hidden */
  47045. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47046. /** @hidden */
  47047. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47048. /** @hidden */
  47049. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  47050. }
  47051. }
  47052. declare module BABYLON {
  47053. /**
  47054. * Gather the list of clipboard event types as constants.
  47055. */
  47056. export class ClipboardEventTypes {
  47057. /**
  47058. * The clipboard event is fired when a copy command is active (pressed).
  47059. */
  47060. static readonly COPY: number;
  47061. /**
  47062. * The clipboard event is fired when a cut command is active (pressed).
  47063. */
  47064. static readonly CUT: number;
  47065. /**
  47066. * The clipboard event is fired when a paste command is active (pressed).
  47067. */
  47068. static readonly PASTE: number;
  47069. }
  47070. /**
  47071. * This class is used to store clipboard related info for the onClipboardObservable event.
  47072. */
  47073. export class ClipboardInfo {
  47074. /**
  47075. * Defines the type of event (BABYLON.ClipboardEventTypes)
  47076. */
  47077. type: number;
  47078. /**
  47079. * Defines the related dom event
  47080. */
  47081. event: ClipboardEvent;
  47082. /**
  47083. *Creates an instance of ClipboardInfo.
  47084. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  47085. * @param event Defines the related dom event
  47086. */
  47087. constructor(
  47088. /**
  47089. * Defines the type of event (BABYLON.ClipboardEventTypes)
  47090. */
  47091. type: number,
  47092. /**
  47093. * Defines the related dom event
  47094. */
  47095. event: ClipboardEvent);
  47096. /**
  47097. * Get the clipboard event's type from the keycode.
  47098. * @param keyCode Defines the keyCode for the current keyboard event.
  47099. * @return {number}
  47100. */
  47101. static GetTypeFromCharacter(keyCode: number): number;
  47102. }
  47103. }
  47104. declare module BABYLON {
  47105. /**
  47106. * Google Daydream controller
  47107. */
  47108. export class DaydreamController extends WebVRController {
  47109. /**
  47110. * Base Url for the controller model.
  47111. */
  47112. static MODEL_BASE_URL: string;
  47113. /**
  47114. * File name for the controller model.
  47115. */
  47116. static MODEL_FILENAME: string;
  47117. /**
  47118. * Gamepad Id prefix used to identify Daydream Controller.
  47119. */
  47120. static readonly GAMEPAD_ID_PREFIX: string;
  47121. /**
  47122. * Creates a new DaydreamController from a gamepad
  47123. * @param vrGamepad the gamepad that the controller should be created from
  47124. */
  47125. constructor(vrGamepad: any);
  47126. /**
  47127. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  47128. * @param scene scene in which to add meshes
  47129. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  47130. */
  47131. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  47132. /**
  47133. * Called once for each button that changed state since the last frame
  47134. * @param buttonIdx Which button index changed
  47135. * @param state New state of the button
  47136. * @param changes Which properties on the state changed since last frame
  47137. */
  47138. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  47139. }
  47140. }
  47141. declare module BABYLON {
  47142. /**
  47143. * Gear VR Controller
  47144. */
  47145. export class GearVRController extends WebVRController {
  47146. /**
  47147. * Base Url for the controller model.
  47148. */
  47149. static MODEL_BASE_URL: string;
  47150. /**
  47151. * File name for the controller model.
  47152. */
  47153. static MODEL_FILENAME: string;
  47154. /**
  47155. * Gamepad Id prefix used to identify this controller.
  47156. */
  47157. static readonly GAMEPAD_ID_PREFIX: string;
  47158. private readonly _buttonIndexToObservableNameMap;
  47159. /**
  47160. * Creates a new GearVRController from a gamepad
  47161. * @param vrGamepad the gamepad that the controller should be created from
  47162. */
  47163. constructor(vrGamepad: any);
  47164. /**
  47165. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  47166. * @param scene scene in which to add meshes
  47167. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  47168. */
  47169. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  47170. /**
  47171. * Called once for each button that changed state since the last frame
  47172. * @param buttonIdx Which button index changed
  47173. * @param state New state of the button
  47174. * @param changes Which properties on the state changed since last frame
  47175. */
  47176. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  47177. }
  47178. }
  47179. declare module BABYLON {
  47180. /**
  47181. * Class containing static functions to help procedurally build meshes
  47182. */
  47183. export class PolyhedronBuilder {
  47184. /**
  47185. * Creates a polyhedron mesh
  47186. * * 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
  47187. * * The parameter `size` (positive float, default 1) sets the polygon size
  47188. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  47189. * * 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`
  47190. * * 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
  47191. * * 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)`)
  47192. * * 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
  47193. * * 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
  47194. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47195. * * 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
  47196. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47197. * @param name defines the name of the mesh
  47198. * @param options defines the options used to create the mesh
  47199. * @param scene defines the hosting scene
  47200. * @returns the polyhedron mesh
  47201. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  47202. */
  47203. static CreatePolyhedron(name: string, options: {
  47204. type?: number;
  47205. size?: number;
  47206. sizeX?: number;
  47207. sizeY?: number;
  47208. sizeZ?: number;
  47209. custom?: any;
  47210. faceUV?: Vector4[];
  47211. faceColors?: Color4[];
  47212. flat?: boolean;
  47213. updatable?: boolean;
  47214. sideOrientation?: number;
  47215. frontUVs?: Vector4;
  47216. backUVs?: Vector4;
  47217. }, scene?: Nullable<Scene>): Mesh;
  47218. }
  47219. }
  47220. declare module BABYLON {
  47221. /**
  47222. * Gizmo that enables scaling a mesh along 3 axis
  47223. */
  47224. export class ScaleGizmo extends Gizmo {
  47225. /**
  47226. * Internal gizmo used for interactions on the x axis
  47227. */
  47228. xGizmo: AxisScaleGizmo;
  47229. /**
  47230. * Internal gizmo used for interactions on the y axis
  47231. */
  47232. yGizmo: AxisScaleGizmo;
  47233. /**
  47234. * Internal gizmo used for interactions on the z axis
  47235. */
  47236. zGizmo: AxisScaleGizmo;
  47237. /**
  47238. * Internal gizmo used to scale all axis equally
  47239. */
  47240. uniformScaleGizmo: AxisScaleGizmo;
  47241. private _meshAttached;
  47242. private _updateGizmoRotationToMatchAttachedMesh;
  47243. private _snapDistance;
  47244. private _scaleRatio;
  47245. private _uniformScalingMesh;
  47246. private _octahedron;
  47247. private _sensitivity;
  47248. /** Fires an event when any of it's sub gizmos are dragged */
  47249. onDragStartObservable: Observable<unknown>;
  47250. /** Fires an event when any of it's sub gizmos are released from dragging */
  47251. onDragEndObservable: Observable<unknown>;
  47252. get attachedMesh(): Nullable<AbstractMesh>;
  47253. set attachedMesh(mesh: Nullable<AbstractMesh>);
  47254. /**
  47255. * Creates a ScaleGizmo
  47256. * @param gizmoLayer The utility layer the gizmo will be added to
  47257. */
  47258. constructor(gizmoLayer?: UtilityLayerRenderer);
  47259. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  47260. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  47261. /**
  47262. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47263. */
  47264. set snapDistance(value: number);
  47265. get snapDistance(): number;
  47266. /**
  47267. * Ratio for the scale of the gizmo (Default: 1)
  47268. */
  47269. set scaleRatio(value: number);
  47270. get scaleRatio(): number;
  47271. /**
  47272. * Sensitivity factor for dragging (Default: 1)
  47273. */
  47274. set sensitivity(value: number);
  47275. get sensitivity(): number;
  47276. /**
  47277. * Disposes of the gizmo
  47278. */
  47279. dispose(): void;
  47280. }
  47281. }
  47282. declare module BABYLON {
  47283. /**
  47284. * Single axis scale gizmo
  47285. */
  47286. export class AxisScaleGizmo extends Gizmo {
  47287. /**
  47288. * Drag behavior responsible for the gizmos dragging interactions
  47289. */
  47290. dragBehavior: PointerDragBehavior;
  47291. private _pointerObserver;
  47292. /**
  47293. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47294. */
  47295. snapDistance: number;
  47296. /**
  47297. * Event that fires each time the gizmo snaps to a new location.
  47298. * * snapDistance is the the change in distance
  47299. */
  47300. onSnapObservable: Observable<{
  47301. snapDistance: number;
  47302. }>;
  47303. /**
  47304. * If the scaling operation should be done on all axis (default: false)
  47305. */
  47306. uniformScaling: boolean;
  47307. /**
  47308. * Custom sensitivity value for the drag strength
  47309. */
  47310. sensitivity: number;
  47311. private _isEnabled;
  47312. private _parent;
  47313. private _arrow;
  47314. private _coloredMaterial;
  47315. private _hoverMaterial;
  47316. /**
  47317. * Creates an AxisScaleGizmo
  47318. * @param gizmoLayer The utility layer the gizmo will be added to
  47319. * @param dragAxis The axis which the gizmo will be able to scale on
  47320. * @param color The color of the gizmo
  47321. */
  47322. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  47323. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47324. /**
  47325. * If the gizmo is enabled
  47326. */
  47327. set isEnabled(value: boolean);
  47328. get isEnabled(): boolean;
  47329. /**
  47330. * Disposes of the gizmo
  47331. */
  47332. dispose(): void;
  47333. /**
  47334. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  47335. * @param mesh The mesh to replace the default mesh of the gizmo
  47336. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  47337. */
  47338. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  47339. }
  47340. }
  47341. declare module BABYLON {
  47342. /**
  47343. * Bounding box gizmo
  47344. */
  47345. export class BoundingBoxGizmo extends Gizmo {
  47346. private _lineBoundingBox;
  47347. private _rotateSpheresParent;
  47348. private _scaleBoxesParent;
  47349. private _boundingDimensions;
  47350. private _renderObserver;
  47351. private _pointerObserver;
  47352. private _scaleDragSpeed;
  47353. private _tmpQuaternion;
  47354. private _tmpVector;
  47355. private _tmpRotationMatrix;
  47356. /**
  47357. * 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)
  47358. */
  47359. ignoreChildren: boolean;
  47360. /**
  47361. * 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)
  47362. */
  47363. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  47364. /**
  47365. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  47366. */
  47367. rotationSphereSize: number;
  47368. /**
  47369. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  47370. */
  47371. scaleBoxSize: number;
  47372. /**
  47373. * 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)
  47374. */
  47375. fixedDragMeshScreenSize: boolean;
  47376. /**
  47377. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  47378. */
  47379. fixedDragMeshScreenSizeDistanceFactor: number;
  47380. /**
  47381. * Fired when a rotation sphere or scale box is dragged
  47382. */
  47383. onDragStartObservable: Observable<{}>;
  47384. /**
  47385. * Fired when a scale box is dragged
  47386. */
  47387. onScaleBoxDragObservable: Observable<{}>;
  47388. /**
  47389. * Fired when a scale box drag is ended
  47390. */
  47391. onScaleBoxDragEndObservable: Observable<{}>;
  47392. /**
  47393. * Fired when a rotation sphere is dragged
  47394. */
  47395. onRotationSphereDragObservable: Observable<{}>;
  47396. /**
  47397. * Fired when a rotation sphere drag is ended
  47398. */
  47399. onRotationSphereDragEndObservable: Observable<{}>;
  47400. /**
  47401. * 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)
  47402. */
  47403. scalePivot: Nullable<Vector3>;
  47404. /**
  47405. * Mesh used as a pivot to rotate the attached mesh
  47406. */
  47407. private _anchorMesh;
  47408. private _existingMeshScale;
  47409. private _dragMesh;
  47410. private pointerDragBehavior;
  47411. private coloredMaterial;
  47412. private hoverColoredMaterial;
  47413. /**
  47414. * Sets the color of the bounding box gizmo
  47415. * @param color the color to set
  47416. */
  47417. setColor(color: Color3): void;
  47418. /**
  47419. * Creates an BoundingBoxGizmo
  47420. * @param gizmoLayer The utility layer the gizmo will be added to
  47421. * @param color The color of the gizmo
  47422. */
  47423. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  47424. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47425. private _selectNode;
  47426. /**
  47427. * Updates the bounding box information for the Gizmo
  47428. */
  47429. updateBoundingBox(): void;
  47430. private _updateRotationSpheres;
  47431. private _updateScaleBoxes;
  47432. /**
  47433. * Enables rotation on the specified axis and disables rotation on the others
  47434. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  47435. */
  47436. setEnabledRotationAxis(axis: string): void;
  47437. /**
  47438. * Enables/disables scaling
  47439. * @param enable if scaling should be enabled
  47440. */
  47441. setEnabledScaling(enable: boolean): void;
  47442. private _updateDummy;
  47443. /**
  47444. * Enables a pointer drag behavior on the bounding box of the gizmo
  47445. */
  47446. enableDragBehavior(): void;
  47447. /**
  47448. * Disposes of the gizmo
  47449. */
  47450. dispose(): void;
  47451. /**
  47452. * 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)
  47453. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  47454. * @returns the bounding box mesh with the passed in mesh as a child
  47455. */
  47456. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  47457. /**
  47458. * CustomMeshes are not supported by this gizmo
  47459. * @param mesh The mesh to replace the default mesh of the gizmo
  47460. */
  47461. setCustomMesh(mesh: Mesh): void;
  47462. }
  47463. }
  47464. declare module BABYLON {
  47465. /**
  47466. * Single plane rotation gizmo
  47467. */
  47468. export class PlaneRotationGizmo extends Gizmo {
  47469. /**
  47470. * Drag behavior responsible for the gizmos dragging interactions
  47471. */
  47472. dragBehavior: PointerDragBehavior;
  47473. private _pointerObserver;
  47474. /**
  47475. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  47476. */
  47477. snapDistance: number;
  47478. /**
  47479. * Event that fires each time the gizmo snaps to a new location.
  47480. * * snapDistance is the the change in distance
  47481. */
  47482. onSnapObservable: Observable<{
  47483. snapDistance: number;
  47484. }>;
  47485. private _isEnabled;
  47486. private _parent;
  47487. /**
  47488. * Creates a PlaneRotationGizmo
  47489. * @param gizmoLayer The utility layer the gizmo will be added to
  47490. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  47491. * @param color The color of the gizmo
  47492. * @param tessellation Amount of tessellation to be used when creating rotation circles
  47493. * @param useEulerRotation Use and update Euler angle instead of quaternion
  47494. */
  47495. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  47496. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47497. /**
  47498. * If the gizmo is enabled
  47499. */
  47500. set isEnabled(value: boolean);
  47501. get isEnabled(): boolean;
  47502. /**
  47503. * Disposes of the gizmo
  47504. */
  47505. dispose(): void;
  47506. }
  47507. }
  47508. declare module BABYLON {
  47509. /**
  47510. * Gizmo that enables rotating a mesh along 3 axis
  47511. */
  47512. export class RotationGizmo extends Gizmo {
  47513. /**
  47514. * Internal gizmo used for interactions on the x axis
  47515. */
  47516. xGizmo: PlaneRotationGizmo;
  47517. /**
  47518. * Internal gizmo used for interactions on the y axis
  47519. */
  47520. yGizmo: PlaneRotationGizmo;
  47521. /**
  47522. * Internal gizmo used for interactions on the z axis
  47523. */
  47524. zGizmo: PlaneRotationGizmo;
  47525. /** Fires an event when any of it's sub gizmos are dragged */
  47526. onDragStartObservable: Observable<unknown>;
  47527. /** Fires an event when any of it's sub gizmos are released from dragging */
  47528. onDragEndObservable: Observable<unknown>;
  47529. private _meshAttached;
  47530. get attachedMesh(): Nullable<AbstractMesh>;
  47531. set attachedMesh(mesh: Nullable<AbstractMesh>);
  47532. /**
  47533. * Creates a RotationGizmo
  47534. * @param gizmoLayer The utility layer the gizmo will be added to
  47535. * @param tessellation Amount of tessellation to be used when creating rotation circles
  47536. * @param useEulerRotation Use and update Euler angle instead of quaternion
  47537. */
  47538. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  47539. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  47540. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  47541. /**
  47542. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47543. */
  47544. set snapDistance(value: number);
  47545. get snapDistance(): number;
  47546. /**
  47547. * Ratio for the scale of the gizmo (Default: 1)
  47548. */
  47549. set scaleRatio(value: number);
  47550. get scaleRatio(): number;
  47551. /**
  47552. * Disposes of the gizmo
  47553. */
  47554. dispose(): void;
  47555. /**
  47556. * CustomMeshes are not supported by this gizmo
  47557. * @param mesh The mesh to replace the default mesh of the gizmo
  47558. */
  47559. setCustomMesh(mesh: Mesh): void;
  47560. }
  47561. }
  47562. declare module BABYLON {
  47563. /**
  47564. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  47565. */
  47566. export class GizmoManager implements IDisposable {
  47567. private scene;
  47568. /**
  47569. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  47570. */
  47571. gizmos: {
  47572. positionGizmo: Nullable<PositionGizmo>;
  47573. rotationGizmo: Nullable<RotationGizmo>;
  47574. scaleGizmo: Nullable<ScaleGizmo>;
  47575. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  47576. };
  47577. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  47578. clearGizmoOnEmptyPointerEvent: boolean;
  47579. /** Fires an event when the manager is attached to a mesh */
  47580. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  47581. private _gizmosEnabled;
  47582. private _pointerObserver;
  47583. private _attachedMesh;
  47584. private _boundingBoxColor;
  47585. private _defaultUtilityLayer;
  47586. private _defaultKeepDepthUtilityLayer;
  47587. /**
  47588. * When bounding box gizmo is enabled, this can be used to track drag/end events
  47589. */
  47590. boundingBoxDragBehavior: SixDofDragBehavior;
  47591. /**
  47592. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  47593. */
  47594. attachableMeshes: Nullable<Array<AbstractMesh>>;
  47595. /**
  47596. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  47597. */
  47598. usePointerToAttachGizmos: boolean;
  47599. /**
  47600. * Utility layer that the bounding box gizmo belongs to
  47601. */
  47602. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  47603. /**
  47604. * Utility layer that all gizmos besides bounding box belong to
  47605. */
  47606. get utilityLayer(): UtilityLayerRenderer;
  47607. /**
  47608. * Instatiates a gizmo manager
  47609. * @param scene the scene to overlay the gizmos on top of
  47610. */
  47611. constructor(scene: Scene);
  47612. /**
  47613. * Attaches a set of gizmos to the specified mesh
  47614. * @param mesh The mesh the gizmo's should be attached to
  47615. */
  47616. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  47617. /**
  47618. * If the position gizmo is enabled
  47619. */
  47620. set positionGizmoEnabled(value: boolean);
  47621. get positionGizmoEnabled(): boolean;
  47622. /**
  47623. * If the rotation gizmo is enabled
  47624. */
  47625. set rotationGizmoEnabled(value: boolean);
  47626. get rotationGizmoEnabled(): boolean;
  47627. /**
  47628. * If the scale gizmo is enabled
  47629. */
  47630. set scaleGizmoEnabled(value: boolean);
  47631. get scaleGizmoEnabled(): boolean;
  47632. /**
  47633. * If the boundingBox gizmo is enabled
  47634. */
  47635. set boundingBoxGizmoEnabled(value: boolean);
  47636. get boundingBoxGizmoEnabled(): boolean;
  47637. /**
  47638. * Disposes of the gizmo manager
  47639. */
  47640. dispose(): void;
  47641. }
  47642. }
  47643. declare module BABYLON {
  47644. /**
  47645. * A directional light is defined by a direction (what a surprise!).
  47646. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  47647. * 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.
  47648. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47649. */
  47650. export class DirectionalLight extends ShadowLight {
  47651. private _shadowFrustumSize;
  47652. /**
  47653. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  47654. */
  47655. get shadowFrustumSize(): number;
  47656. /**
  47657. * Specifies a fix frustum size for the shadow generation.
  47658. */
  47659. set shadowFrustumSize(value: number);
  47660. private _shadowOrthoScale;
  47661. /**
  47662. * Gets the shadow projection scale against the optimal computed one.
  47663. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  47664. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  47665. */
  47666. get shadowOrthoScale(): number;
  47667. /**
  47668. * Sets the shadow projection scale against the optimal computed one.
  47669. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  47670. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  47671. */
  47672. set shadowOrthoScale(value: number);
  47673. /**
  47674. * Automatically compute the projection matrix to best fit (including all the casters)
  47675. * on each frame.
  47676. */
  47677. autoUpdateExtends: boolean;
  47678. private _orthoLeft;
  47679. private _orthoRight;
  47680. private _orthoTop;
  47681. private _orthoBottom;
  47682. /**
  47683. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  47684. * The directional light is emitted from everywhere in the given direction.
  47685. * It can cast shadows.
  47686. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47687. * @param name The friendly name of the light
  47688. * @param direction The direction of the light
  47689. * @param scene The scene the light belongs to
  47690. */
  47691. constructor(name: string, direction: Vector3, scene: Scene);
  47692. /**
  47693. * Returns the string "DirectionalLight".
  47694. * @return The class name
  47695. */
  47696. getClassName(): string;
  47697. /**
  47698. * Returns the integer 1.
  47699. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47700. */
  47701. getTypeID(): number;
  47702. /**
  47703. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  47704. * Returns the DirectionalLight Shadow projection matrix.
  47705. */
  47706. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47707. /**
  47708. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  47709. * Returns the DirectionalLight Shadow projection matrix.
  47710. */
  47711. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  47712. /**
  47713. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  47714. * Returns the DirectionalLight Shadow projection matrix.
  47715. */
  47716. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47717. protected _buildUniformLayout(): void;
  47718. /**
  47719. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  47720. * @param effect The effect to update
  47721. * @param lightIndex The index of the light in the effect to update
  47722. * @returns The directional light
  47723. */
  47724. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  47725. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  47726. /**
  47727. * Gets the minZ used for shadow according to both the scene and the light.
  47728. *
  47729. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  47730. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  47731. * @param activeCamera The camera we are returning the min for
  47732. * @returns the depth min z
  47733. */
  47734. getDepthMinZ(activeCamera: Camera): number;
  47735. /**
  47736. * Gets the maxZ used for shadow according to both the scene and the light.
  47737. *
  47738. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  47739. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  47740. * @param activeCamera The camera we are returning the max for
  47741. * @returns the depth max z
  47742. */
  47743. getDepthMaxZ(activeCamera: Camera): number;
  47744. /**
  47745. * Prepares the list of defines specific to the light type.
  47746. * @param defines the list of defines
  47747. * @param lightIndex defines the index of the light for the effect
  47748. */
  47749. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47750. }
  47751. }
  47752. declare module BABYLON {
  47753. /**
  47754. * Class containing static functions to help procedurally build meshes
  47755. */
  47756. export class HemisphereBuilder {
  47757. /**
  47758. * Creates a hemisphere mesh
  47759. * @param name defines the name of the mesh
  47760. * @param options defines the options used to create the mesh
  47761. * @param scene defines the hosting scene
  47762. * @returns the hemisphere mesh
  47763. */
  47764. static CreateHemisphere(name: string, options: {
  47765. segments?: number;
  47766. diameter?: number;
  47767. sideOrientation?: number;
  47768. }, scene: any): Mesh;
  47769. }
  47770. }
  47771. declare module BABYLON {
  47772. /**
  47773. * A spot light is defined by a position, a direction, an angle, and an exponent.
  47774. * These values define a cone of light starting from the position, emitting toward the direction.
  47775. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  47776. * and the exponent defines the speed of the decay of the light with distance (reach).
  47777. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47778. */
  47779. export class SpotLight extends ShadowLight {
  47780. private _angle;
  47781. private _innerAngle;
  47782. private _cosHalfAngle;
  47783. private _lightAngleScale;
  47784. private _lightAngleOffset;
  47785. /**
  47786. * Gets the cone angle of the spot light in Radians.
  47787. */
  47788. get angle(): number;
  47789. /**
  47790. * Sets the cone angle of the spot light in Radians.
  47791. */
  47792. set angle(value: number);
  47793. /**
  47794. * Only used in gltf falloff mode, this defines the angle where
  47795. * the directional falloff will start before cutting at angle which could be seen
  47796. * as outer angle.
  47797. */
  47798. get innerAngle(): number;
  47799. /**
  47800. * Only used in gltf falloff mode, this defines the angle where
  47801. * the directional falloff will start before cutting at angle which could be seen
  47802. * as outer angle.
  47803. */
  47804. set innerAngle(value: number);
  47805. private _shadowAngleScale;
  47806. /**
  47807. * Allows scaling the angle of the light for shadow generation only.
  47808. */
  47809. get shadowAngleScale(): number;
  47810. /**
  47811. * Allows scaling the angle of the light for shadow generation only.
  47812. */
  47813. set shadowAngleScale(value: number);
  47814. /**
  47815. * The light decay speed with the distance from the emission spot.
  47816. */
  47817. exponent: number;
  47818. private _projectionTextureMatrix;
  47819. /**
  47820. * Allows reading the projecton texture
  47821. */
  47822. get projectionTextureMatrix(): Matrix;
  47823. protected _projectionTextureLightNear: number;
  47824. /**
  47825. * Gets the near clip of the Spotlight for texture projection.
  47826. */
  47827. get projectionTextureLightNear(): number;
  47828. /**
  47829. * Sets the near clip of the Spotlight for texture projection.
  47830. */
  47831. set projectionTextureLightNear(value: number);
  47832. protected _projectionTextureLightFar: number;
  47833. /**
  47834. * Gets the far clip of the Spotlight for texture projection.
  47835. */
  47836. get projectionTextureLightFar(): number;
  47837. /**
  47838. * Sets the far clip of the Spotlight for texture projection.
  47839. */
  47840. set projectionTextureLightFar(value: number);
  47841. protected _projectionTextureUpDirection: Vector3;
  47842. /**
  47843. * Gets the Up vector of the Spotlight for texture projection.
  47844. */
  47845. get projectionTextureUpDirection(): Vector3;
  47846. /**
  47847. * Sets the Up vector of the Spotlight for texture projection.
  47848. */
  47849. set projectionTextureUpDirection(value: Vector3);
  47850. private _projectionTexture;
  47851. /**
  47852. * Gets the projection texture of the light.
  47853. */
  47854. get projectionTexture(): Nullable<BaseTexture>;
  47855. /**
  47856. * Sets the projection texture of the light.
  47857. */
  47858. set projectionTexture(value: Nullable<BaseTexture>);
  47859. private _projectionTextureViewLightDirty;
  47860. private _projectionTextureProjectionLightDirty;
  47861. private _projectionTextureDirty;
  47862. private _projectionTextureViewTargetVector;
  47863. private _projectionTextureViewLightMatrix;
  47864. private _projectionTextureProjectionLightMatrix;
  47865. private _projectionTextureScalingMatrix;
  47866. /**
  47867. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  47868. * It can cast shadows.
  47869. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47870. * @param name The light friendly name
  47871. * @param position The position of the spot light in the scene
  47872. * @param direction The direction of the light in the scene
  47873. * @param angle The cone angle of the light in Radians
  47874. * @param exponent The light decay speed with the distance from the emission spot
  47875. * @param scene The scene the lights belongs to
  47876. */
  47877. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  47878. /**
  47879. * Returns the string "SpotLight".
  47880. * @returns the class name
  47881. */
  47882. getClassName(): string;
  47883. /**
  47884. * Returns the integer 2.
  47885. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47886. */
  47887. getTypeID(): number;
  47888. /**
  47889. * Overrides the direction setter to recompute the projection texture view light Matrix.
  47890. */
  47891. protected _setDirection(value: Vector3): void;
  47892. /**
  47893. * Overrides the position setter to recompute the projection texture view light Matrix.
  47894. */
  47895. protected _setPosition(value: Vector3): void;
  47896. /**
  47897. * 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.
  47898. * Returns the SpotLight.
  47899. */
  47900. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47901. protected _computeProjectionTextureViewLightMatrix(): void;
  47902. protected _computeProjectionTextureProjectionLightMatrix(): void;
  47903. /**
  47904. * Main function for light texture projection matrix computing.
  47905. */
  47906. protected _computeProjectionTextureMatrix(): void;
  47907. protected _buildUniformLayout(): void;
  47908. private _computeAngleValues;
  47909. /**
  47910. * Sets the passed Effect "effect" with the Light textures.
  47911. * @param effect The effect to update
  47912. * @param lightIndex The index of the light in the effect to update
  47913. * @returns The light
  47914. */
  47915. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  47916. /**
  47917. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  47918. * @param effect The effect to update
  47919. * @param lightIndex The index of the light in the effect to update
  47920. * @returns The spot light
  47921. */
  47922. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  47923. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  47924. /**
  47925. * Disposes the light and the associated resources.
  47926. */
  47927. dispose(): void;
  47928. /**
  47929. * Prepares the list of defines specific to the light type.
  47930. * @param defines the list of defines
  47931. * @param lightIndex defines the index of the light for the effect
  47932. */
  47933. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47934. }
  47935. }
  47936. declare module BABYLON {
  47937. /**
  47938. * Gizmo that enables viewing a light
  47939. */
  47940. export class LightGizmo extends Gizmo {
  47941. private _lightMesh;
  47942. private _material;
  47943. private _cachedPosition;
  47944. private _cachedForward;
  47945. private _attachedMeshParent;
  47946. /**
  47947. * Creates a LightGizmo
  47948. * @param gizmoLayer The utility layer the gizmo will be added to
  47949. */
  47950. constructor(gizmoLayer?: UtilityLayerRenderer);
  47951. private _light;
  47952. /**
  47953. * The light that the gizmo is attached to
  47954. */
  47955. set light(light: Nullable<Light>);
  47956. get light(): Nullable<Light>;
  47957. /**
  47958. * Gets the material used to render the light gizmo
  47959. */
  47960. get material(): StandardMaterial;
  47961. /**
  47962. * @hidden
  47963. * Updates the gizmo to match the attached mesh's position/rotation
  47964. */
  47965. protected _update(): void;
  47966. private static _Scale;
  47967. /**
  47968. * Creates the lines for a light mesh
  47969. */
  47970. private static _CreateLightLines;
  47971. /**
  47972. * Disposes of the light gizmo
  47973. */
  47974. dispose(): void;
  47975. private static _CreateHemisphericLightMesh;
  47976. private static _CreatePointLightMesh;
  47977. private static _CreateSpotLightMesh;
  47978. private static _CreateDirectionalLightMesh;
  47979. }
  47980. }
  47981. declare module BABYLON {
  47982. /** @hidden */
  47983. export var backgroundFragmentDeclaration: {
  47984. name: string;
  47985. shader: string;
  47986. };
  47987. }
  47988. declare module BABYLON {
  47989. /** @hidden */
  47990. export var backgroundUboDeclaration: {
  47991. name: string;
  47992. shader: string;
  47993. };
  47994. }
  47995. declare module BABYLON {
  47996. /** @hidden */
  47997. export var backgroundPixelShader: {
  47998. name: string;
  47999. shader: string;
  48000. };
  48001. }
  48002. declare module BABYLON {
  48003. /** @hidden */
  48004. export var backgroundVertexDeclaration: {
  48005. name: string;
  48006. shader: string;
  48007. };
  48008. }
  48009. declare module BABYLON {
  48010. /** @hidden */
  48011. export var backgroundVertexShader: {
  48012. name: string;
  48013. shader: string;
  48014. };
  48015. }
  48016. declare module BABYLON {
  48017. /**
  48018. * Background material used to create an efficient environement around your scene.
  48019. */
  48020. export class BackgroundMaterial extends PushMaterial {
  48021. /**
  48022. * Standard reflectance value at parallel view angle.
  48023. */
  48024. static StandardReflectance0: number;
  48025. /**
  48026. * Standard reflectance value at grazing angle.
  48027. */
  48028. static StandardReflectance90: number;
  48029. protected _primaryColor: Color3;
  48030. /**
  48031. * Key light Color (multiply against the environement texture)
  48032. */
  48033. primaryColor: Color3;
  48034. protected __perceptualColor: Nullable<Color3>;
  48035. /**
  48036. * Experimental Internal Use Only.
  48037. *
  48038. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  48039. * This acts as a helper to set the primary color to a more "human friendly" value.
  48040. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  48041. * output color as close as possible from the chosen value.
  48042. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  48043. * part of lighting setup.)
  48044. */
  48045. get _perceptualColor(): Nullable<Color3>;
  48046. set _perceptualColor(value: Nullable<Color3>);
  48047. protected _primaryColorShadowLevel: float;
  48048. /**
  48049. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  48050. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  48051. */
  48052. get primaryColorShadowLevel(): float;
  48053. set primaryColorShadowLevel(value: float);
  48054. protected _primaryColorHighlightLevel: float;
  48055. /**
  48056. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  48057. * The primary color is used at the level chosen to define what the white area would look.
  48058. */
  48059. get primaryColorHighlightLevel(): float;
  48060. set primaryColorHighlightLevel(value: float);
  48061. protected _reflectionTexture: Nullable<BaseTexture>;
  48062. /**
  48063. * Reflection Texture used in the material.
  48064. * Should be author in a specific way for the best result (refer to the documentation).
  48065. */
  48066. reflectionTexture: Nullable<BaseTexture>;
  48067. protected _reflectionBlur: float;
  48068. /**
  48069. * Reflection Texture level of blur.
  48070. *
  48071. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  48072. * texture twice.
  48073. */
  48074. reflectionBlur: float;
  48075. protected _diffuseTexture: Nullable<BaseTexture>;
  48076. /**
  48077. * Diffuse Texture used in the material.
  48078. * Should be author in a specific way for the best result (refer to the documentation).
  48079. */
  48080. diffuseTexture: Nullable<BaseTexture>;
  48081. protected _shadowLights: Nullable<IShadowLight[]>;
  48082. /**
  48083. * Specify the list of lights casting shadow on the material.
  48084. * All scene shadow lights will be included if null.
  48085. */
  48086. shadowLights: Nullable<IShadowLight[]>;
  48087. protected _shadowLevel: float;
  48088. /**
  48089. * Helps adjusting the shadow to a softer level if required.
  48090. * 0 means black shadows and 1 means no shadows.
  48091. */
  48092. shadowLevel: float;
  48093. protected _sceneCenter: Vector3;
  48094. /**
  48095. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  48096. * It is usually zero but might be interesting to modify according to your setup.
  48097. */
  48098. sceneCenter: Vector3;
  48099. protected _opacityFresnel: boolean;
  48100. /**
  48101. * This helps specifying that the material is falling off to the sky box at grazing angle.
  48102. * This helps ensuring a nice transition when the camera goes under the ground.
  48103. */
  48104. opacityFresnel: boolean;
  48105. protected _reflectionFresnel: boolean;
  48106. /**
  48107. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  48108. * This helps adding a mirror texture on the ground.
  48109. */
  48110. reflectionFresnel: boolean;
  48111. protected _reflectionFalloffDistance: number;
  48112. /**
  48113. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  48114. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  48115. */
  48116. reflectionFalloffDistance: number;
  48117. protected _reflectionAmount: number;
  48118. /**
  48119. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  48120. */
  48121. reflectionAmount: number;
  48122. protected _reflectionReflectance0: number;
  48123. /**
  48124. * This specifies the weight of the reflection at grazing angle.
  48125. */
  48126. reflectionReflectance0: number;
  48127. protected _reflectionReflectance90: number;
  48128. /**
  48129. * This specifies the weight of the reflection at a perpendicular point of view.
  48130. */
  48131. reflectionReflectance90: number;
  48132. /**
  48133. * Sets the reflection reflectance fresnel values according to the default standard
  48134. * empirically know to work well :-)
  48135. */
  48136. set reflectionStandardFresnelWeight(value: number);
  48137. protected _useRGBColor: boolean;
  48138. /**
  48139. * Helps to directly use the maps channels instead of their level.
  48140. */
  48141. useRGBColor: boolean;
  48142. protected _enableNoise: boolean;
  48143. /**
  48144. * This helps reducing the banding effect that could occur on the background.
  48145. */
  48146. enableNoise: boolean;
  48147. /**
  48148. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48149. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  48150. * Recommended to be keep at 1.0 except for special cases.
  48151. */
  48152. get fovMultiplier(): number;
  48153. set fovMultiplier(value: number);
  48154. private _fovMultiplier;
  48155. /**
  48156. * Enable the FOV adjustment feature controlled by fovMultiplier.
  48157. */
  48158. useEquirectangularFOV: boolean;
  48159. private _maxSimultaneousLights;
  48160. /**
  48161. * Number of Simultaneous lights allowed on the material.
  48162. */
  48163. maxSimultaneousLights: int;
  48164. /**
  48165. * Default configuration related to image processing available in the Background Material.
  48166. */
  48167. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  48168. /**
  48169. * Keep track of the image processing observer to allow dispose and replace.
  48170. */
  48171. private _imageProcessingObserver;
  48172. /**
  48173. * Attaches a new image processing configuration to the PBR Material.
  48174. * @param configuration (if null the scene configuration will be use)
  48175. */
  48176. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  48177. /**
  48178. * Gets the image processing configuration used either in this material.
  48179. */
  48180. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  48181. /**
  48182. * Sets the Default image processing configuration used either in the this material.
  48183. *
  48184. * If sets to null, the scene one is in use.
  48185. */
  48186. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  48187. /**
  48188. * Gets wether the color curves effect is enabled.
  48189. */
  48190. get cameraColorCurvesEnabled(): boolean;
  48191. /**
  48192. * Sets wether the color curves effect is enabled.
  48193. */
  48194. set cameraColorCurvesEnabled(value: boolean);
  48195. /**
  48196. * Gets wether the color grading effect is enabled.
  48197. */
  48198. get cameraColorGradingEnabled(): boolean;
  48199. /**
  48200. * Gets wether the color grading effect is enabled.
  48201. */
  48202. set cameraColorGradingEnabled(value: boolean);
  48203. /**
  48204. * Gets wether tonemapping is enabled or not.
  48205. */
  48206. get cameraToneMappingEnabled(): boolean;
  48207. /**
  48208. * Sets wether tonemapping is enabled or not
  48209. */
  48210. set cameraToneMappingEnabled(value: boolean);
  48211. /**
  48212. * The camera exposure used on this material.
  48213. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48214. * This corresponds to a photographic exposure.
  48215. */
  48216. get cameraExposure(): float;
  48217. /**
  48218. * The camera exposure used on this material.
  48219. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48220. * This corresponds to a photographic exposure.
  48221. */
  48222. set cameraExposure(value: float);
  48223. /**
  48224. * Gets The camera contrast used on this material.
  48225. */
  48226. get cameraContrast(): float;
  48227. /**
  48228. * Sets The camera contrast used on this material.
  48229. */
  48230. set cameraContrast(value: float);
  48231. /**
  48232. * Gets the Color Grading 2D Lookup Texture.
  48233. */
  48234. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  48235. /**
  48236. * Sets the Color Grading 2D Lookup Texture.
  48237. */
  48238. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  48239. /**
  48240. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48241. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48242. * 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;
  48243. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48244. */
  48245. get cameraColorCurves(): Nullable<ColorCurves>;
  48246. /**
  48247. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48248. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48249. * 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;
  48250. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48251. */
  48252. set cameraColorCurves(value: Nullable<ColorCurves>);
  48253. /**
  48254. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  48255. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  48256. */
  48257. switchToBGR: boolean;
  48258. private _renderTargets;
  48259. private _reflectionControls;
  48260. private _white;
  48261. private _primaryShadowColor;
  48262. private _primaryHighlightColor;
  48263. /**
  48264. * Instantiates a Background Material in the given scene
  48265. * @param name The friendly name of the material
  48266. * @param scene The scene to add the material to
  48267. */
  48268. constructor(name: string, scene: Scene);
  48269. /**
  48270. * Gets a boolean indicating that current material needs to register RTT
  48271. */
  48272. get hasRenderTargetTextures(): boolean;
  48273. /**
  48274. * The entire material has been created in order to prevent overdraw.
  48275. * @returns false
  48276. */
  48277. needAlphaTesting(): boolean;
  48278. /**
  48279. * The entire material has been created in order to prevent overdraw.
  48280. * @returns true if blending is enable
  48281. */
  48282. needAlphaBlending(): boolean;
  48283. /**
  48284. * Checks wether the material is ready to be rendered for a given mesh.
  48285. * @param mesh The mesh to render
  48286. * @param subMesh The submesh to check against
  48287. * @param useInstances Specify wether or not the material is used with instances
  48288. * @returns true if all the dependencies are ready (Textures, Effects...)
  48289. */
  48290. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  48291. /**
  48292. * Compute the primary color according to the chosen perceptual color.
  48293. */
  48294. private _computePrimaryColorFromPerceptualColor;
  48295. /**
  48296. * Compute the highlights and shadow colors according to their chosen levels.
  48297. */
  48298. private _computePrimaryColors;
  48299. /**
  48300. * Build the uniform buffer used in the material.
  48301. */
  48302. buildUniformLayout(): void;
  48303. /**
  48304. * Unbind the material.
  48305. */
  48306. unbind(): void;
  48307. /**
  48308. * Bind only the world matrix to the material.
  48309. * @param world The world matrix to bind.
  48310. */
  48311. bindOnlyWorldMatrix(world: Matrix): void;
  48312. /**
  48313. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  48314. * @param world The world matrix to bind.
  48315. * @param subMesh The submesh to bind for.
  48316. */
  48317. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  48318. /**
  48319. * Checks to see if a texture is used in the material.
  48320. * @param texture - Base texture to use.
  48321. * @returns - Boolean specifying if a texture is used in the material.
  48322. */
  48323. hasTexture(texture: BaseTexture): boolean;
  48324. /**
  48325. * Dispose the material.
  48326. * @param forceDisposeEffect Force disposal of the associated effect.
  48327. * @param forceDisposeTextures Force disposal of the associated textures.
  48328. */
  48329. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  48330. /**
  48331. * Clones the material.
  48332. * @param name The cloned name.
  48333. * @returns The cloned material.
  48334. */
  48335. clone(name: string): BackgroundMaterial;
  48336. /**
  48337. * Serializes the current material to its JSON representation.
  48338. * @returns The JSON representation.
  48339. */
  48340. serialize(): any;
  48341. /**
  48342. * Gets the class name of the material
  48343. * @returns "BackgroundMaterial"
  48344. */
  48345. getClassName(): string;
  48346. /**
  48347. * Parse a JSON input to create back a background material.
  48348. * @param source The JSON data to parse
  48349. * @param scene The scene to create the parsed material in
  48350. * @param rootUrl The root url of the assets the material depends upon
  48351. * @returns the instantiated BackgroundMaterial.
  48352. */
  48353. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  48354. }
  48355. }
  48356. declare module BABYLON {
  48357. /**
  48358. * Represents the different options available during the creation of
  48359. * a Environment helper.
  48360. *
  48361. * This can control the default ground, skybox and image processing setup of your scene.
  48362. */
  48363. export interface IEnvironmentHelperOptions {
  48364. /**
  48365. * Specifies wether or not to create a ground.
  48366. * True by default.
  48367. */
  48368. createGround: boolean;
  48369. /**
  48370. * Specifies the ground size.
  48371. * 15 by default.
  48372. */
  48373. groundSize: number;
  48374. /**
  48375. * The texture used on the ground for the main color.
  48376. * Comes from the BabylonJS CDN by default.
  48377. *
  48378. * Remarks: Can be either a texture or a url.
  48379. */
  48380. groundTexture: string | BaseTexture;
  48381. /**
  48382. * The color mixed in the ground texture by default.
  48383. * BabylonJS clearColor by default.
  48384. */
  48385. groundColor: Color3;
  48386. /**
  48387. * Specifies the ground opacity.
  48388. * 1 by default.
  48389. */
  48390. groundOpacity: number;
  48391. /**
  48392. * Enables the ground to receive shadows.
  48393. * True by default.
  48394. */
  48395. enableGroundShadow: boolean;
  48396. /**
  48397. * Helps preventing the shadow to be fully black on the ground.
  48398. * 0.5 by default.
  48399. */
  48400. groundShadowLevel: number;
  48401. /**
  48402. * Creates a mirror texture attach to the ground.
  48403. * false by default.
  48404. */
  48405. enableGroundMirror: boolean;
  48406. /**
  48407. * Specifies the ground mirror size ratio.
  48408. * 0.3 by default as the default kernel is 64.
  48409. */
  48410. groundMirrorSizeRatio: number;
  48411. /**
  48412. * Specifies the ground mirror blur kernel size.
  48413. * 64 by default.
  48414. */
  48415. groundMirrorBlurKernel: number;
  48416. /**
  48417. * Specifies the ground mirror visibility amount.
  48418. * 1 by default
  48419. */
  48420. groundMirrorAmount: number;
  48421. /**
  48422. * Specifies the ground mirror reflectance weight.
  48423. * This uses the standard weight of the background material to setup the fresnel effect
  48424. * of the mirror.
  48425. * 1 by default.
  48426. */
  48427. groundMirrorFresnelWeight: number;
  48428. /**
  48429. * Specifies the ground mirror Falloff distance.
  48430. * This can helps reducing the size of the reflection.
  48431. * 0 by Default.
  48432. */
  48433. groundMirrorFallOffDistance: number;
  48434. /**
  48435. * Specifies the ground mirror texture type.
  48436. * Unsigned Int by Default.
  48437. */
  48438. groundMirrorTextureType: number;
  48439. /**
  48440. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  48441. * the shown objects.
  48442. */
  48443. groundYBias: number;
  48444. /**
  48445. * Specifies wether or not to create a skybox.
  48446. * True by default.
  48447. */
  48448. createSkybox: boolean;
  48449. /**
  48450. * Specifies the skybox size.
  48451. * 20 by default.
  48452. */
  48453. skyboxSize: number;
  48454. /**
  48455. * The texture used on the skybox for the main color.
  48456. * Comes from the BabylonJS CDN by default.
  48457. *
  48458. * Remarks: Can be either a texture or a url.
  48459. */
  48460. skyboxTexture: string | BaseTexture;
  48461. /**
  48462. * The color mixed in the skybox texture by default.
  48463. * BabylonJS clearColor by default.
  48464. */
  48465. skyboxColor: Color3;
  48466. /**
  48467. * The background rotation around the Y axis of the scene.
  48468. * This helps aligning the key lights of your scene with the background.
  48469. * 0 by default.
  48470. */
  48471. backgroundYRotation: number;
  48472. /**
  48473. * Compute automatically the size of the elements to best fit with the scene.
  48474. */
  48475. sizeAuto: boolean;
  48476. /**
  48477. * Default position of the rootMesh if autoSize is not true.
  48478. */
  48479. rootPosition: Vector3;
  48480. /**
  48481. * Sets up the image processing in the scene.
  48482. * true by default.
  48483. */
  48484. setupImageProcessing: boolean;
  48485. /**
  48486. * The texture used as your environment texture in the scene.
  48487. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  48488. *
  48489. * Remarks: Can be either a texture or a url.
  48490. */
  48491. environmentTexture: string | BaseTexture;
  48492. /**
  48493. * The value of the exposure to apply to the scene.
  48494. * 0.6 by default if setupImageProcessing is true.
  48495. */
  48496. cameraExposure: number;
  48497. /**
  48498. * The value of the contrast to apply to the scene.
  48499. * 1.6 by default if setupImageProcessing is true.
  48500. */
  48501. cameraContrast: number;
  48502. /**
  48503. * Specifies wether or not tonemapping should be enabled in the scene.
  48504. * true by default if setupImageProcessing is true.
  48505. */
  48506. toneMappingEnabled: boolean;
  48507. }
  48508. /**
  48509. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  48510. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  48511. * It also helps with the default setup of your imageProcessing configuration.
  48512. */
  48513. export class EnvironmentHelper {
  48514. /**
  48515. * Default ground texture URL.
  48516. */
  48517. private static _groundTextureCDNUrl;
  48518. /**
  48519. * Default skybox texture URL.
  48520. */
  48521. private static _skyboxTextureCDNUrl;
  48522. /**
  48523. * Default environment texture URL.
  48524. */
  48525. private static _environmentTextureCDNUrl;
  48526. /**
  48527. * Creates the default options for the helper.
  48528. */
  48529. private static _getDefaultOptions;
  48530. private _rootMesh;
  48531. /**
  48532. * Gets the root mesh created by the helper.
  48533. */
  48534. get rootMesh(): Mesh;
  48535. private _skybox;
  48536. /**
  48537. * Gets the skybox created by the helper.
  48538. */
  48539. get skybox(): Nullable<Mesh>;
  48540. private _skyboxTexture;
  48541. /**
  48542. * Gets the skybox texture created by the helper.
  48543. */
  48544. get skyboxTexture(): Nullable<BaseTexture>;
  48545. private _skyboxMaterial;
  48546. /**
  48547. * Gets the skybox material created by the helper.
  48548. */
  48549. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  48550. private _ground;
  48551. /**
  48552. * Gets the ground mesh created by the helper.
  48553. */
  48554. get ground(): Nullable<Mesh>;
  48555. private _groundTexture;
  48556. /**
  48557. * Gets the ground texture created by the helper.
  48558. */
  48559. get groundTexture(): Nullable<BaseTexture>;
  48560. private _groundMirror;
  48561. /**
  48562. * Gets the ground mirror created by the helper.
  48563. */
  48564. get groundMirror(): Nullable<MirrorTexture>;
  48565. /**
  48566. * Gets the ground mirror render list to helps pushing the meshes
  48567. * you wish in the ground reflection.
  48568. */
  48569. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  48570. private _groundMaterial;
  48571. /**
  48572. * Gets the ground material created by the helper.
  48573. */
  48574. get groundMaterial(): Nullable<BackgroundMaterial>;
  48575. /**
  48576. * Stores the creation options.
  48577. */
  48578. private readonly _scene;
  48579. private _options;
  48580. /**
  48581. * This observable will be notified with any error during the creation of the environment,
  48582. * mainly texture creation errors.
  48583. */
  48584. onErrorObservable: Observable<{
  48585. message?: string;
  48586. exception?: any;
  48587. }>;
  48588. /**
  48589. * constructor
  48590. * @param options Defines the options we want to customize the helper
  48591. * @param scene The scene to add the material to
  48592. */
  48593. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  48594. /**
  48595. * Updates the background according to the new options
  48596. * @param options
  48597. */
  48598. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  48599. /**
  48600. * Sets the primary color of all the available elements.
  48601. * @param color the main color to affect to the ground and the background
  48602. */
  48603. setMainColor(color: Color3): void;
  48604. /**
  48605. * Setup the image processing according to the specified options.
  48606. */
  48607. private _setupImageProcessing;
  48608. /**
  48609. * Setup the environment texture according to the specified options.
  48610. */
  48611. private _setupEnvironmentTexture;
  48612. /**
  48613. * Setup the background according to the specified options.
  48614. */
  48615. private _setupBackground;
  48616. /**
  48617. * Get the scene sizes according to the setup.
  48618. */
  48619. private _getSceneSize;
  48620. /**
  48621. * Setup the ground according to the specified options.
  48622. */
  48623. private _setupGround;
  48624. /**
  48625. * Setup the ground material according to the specified options.
  48626. */
  48627. private _setupGroundMaterial;
  48628. /**
  48629. * Setup the ground diffuse texture according to the specified options.
  48630. */
  48631. private _setupGroundDiffuseTexture;
  48632. /**
  48633. * Setup the ground mirror texture according to the specified options.
  48634. */
  48635. private _setupGroundMirrorTexture;
  48636. /**
  48637. * Setup the ground to receive the mirror texture.
  48638. */
  48639. private _setupMirrorInGroundMaterial;
  48640. /**
  48641. * Setup the skybox according to the specified options.
  48642. */
  48643. private _setupSkybox;
  48644. /**
  48645. * Setup the skybox material according to the specified options.
  48646. */
  48647. private _setupSkyboxMaterial;
  48648. /**
  48649. * Setup the skybox reflection texture according to the specified options.
  48650. */
  48651. private _setupSkyboxReflectionTexture;
  48652. private _errorHandler;
  48653. /**
  48654. * Dispose all the elements created by the Helper.
  48655. */
  48656. dispose(): void;
  48657. }
  48658. }
  48659. declare module BABYLON {
  48660. /**
  48661. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  48662. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  48663. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  48664. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  48665. */
  48666. export class PhotoDome extends TransformNode {
  48667. /**
  48668. * Define the image as a Monoscopic panoramic 360 image.
  48669. */
  48670. static readonly MODE_MONOSCOPIC: number;
  48671. /**
  48672. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  48673. */
  48674. static readonly MODE_TOPBOTTOM: number;
  48675. /**
  48676. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  48677. */
  48678. static readonly MODE_SIDEBYSIDE: number;
  48679. private _useDirectMapping;
  48680. /**
  48681. * The texture being displayed on the sphere
  48682. */
  48683. protected _photoTexture: Texture;
  48684. /**
  48685. * Gets or sets the texture being displayed on the sphere
  48686. */
  48687. get photoTexture(): Texture;
  48688. set photoTexture(value: Texture);
  48689. /**
  48690. * Observable raised when an error occured while loading the 360 image
  48691. */
  48692. onLoadErrorObservable: Observable<string>;
  48693. /**
  48694. * The skybox material
  48695. */
  48696. protected _material: BackgroundMaterial;
  48697. /**
  48698. * The surface used for the skybox
  48699. */
  48700. protected _mesh: Mesh;
  48701. /**
  48702. * Gets the mesh used for the skybox.
  48703. */
  48704. get mesh(): Mesh;
  48705. /**
  48706. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48707. * Also see the options.resolution property.
  48708. */
  48709. get fovMultiplier(): number;
  48710. set fovMultiplier(value: number);
  48711. private _imageMode;
  48712. /**
  48713. * Gets or set the current video mode for the video. It can be:
  48714. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  48715. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  48716. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  48717. */
  48718. get imageMode(): number;
  48719. set imageMode(value: number);
  48720. /**
  48721. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  48722. * @param name Element's name, child elements will append suffixes for their own names.
  48723. * @param urlsOfPhoto defines the url of the photo to display
  48724. * @param options defines an object containing optional or exposed sub element properties
  48725. * @param onError defines a callback called when an error occured while loading the texture
  48726. */
  48727. constructor(name: string, urlOfPhoto: string, options: {
  48728. resolution?: number;
  48729. size?: number;
  48730. useDirectMapping?: boolean;
  48731. faceForward?: boolean;
  48732. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  48733. private _onBeforeCameraRenderObserver;
  48734. private _changeImageMode;
  48735. /**
  48736. * Releases resources associated with this node.
  48737. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  48738. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  48739. */
  48740. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  48741. }
  48742. }
  48743. declare module BABYLON {
  48744. /**
  48745. * Class used to host RGBD texture specific utilities
  48746. */
  48747. export class RGBDTextureTools {
  48748. /**
  48749. * Expand the RGBD Texture from RGBD to Half Float if possible.
  48750. * @param texture the texture to expand.
  48751. */
  48752. static ExpandRGBDTexture(texture: Texture): void;
  48753. }
  48754. }
  48755. declare module BABYLON {
  48756. /**
  48757. * Class used to host texture specific utilities
  48758. */
  48759. export class BRDFTextureTools {
  48760. /**
  48761. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  48762. * @param scene defines the hosting scene
  48763. * @returns the environment BRDF texture
  48764. */
  48765. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  48766. private static _environmentBRDFBase64Texture;
  48767. }
  48768. }
  48769. declare module BABYLON {
  48770. /**
  48771. * @hidden
  48772. */
  48773. export interface IMaterialClearCoatDefines {
  48774. CLEARCOAT: boolean;
  48775. CLEARCOAT_DEFAULTIOR: boolean;
  48776. CLEARCOAT_TEXTURE: boolean;
  48777. CLEARCOAT_TEXTUREDIRECTUV: number;
  48778. CLEARCOAT_BUMP: boolean;
  48779. CLEARCOAT_BUMPDIRECTUV: number;
  48780. CLEARCOAT_TINT: boolean;
  48781. CLEARCOAT_TINT_TEXTURE: boolean;
  48782. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  48783. /** @hidden */
  48784. _areTexturesDirty: boolean;
  48785. }
  48786. /**
  48787. * Define the code related to the clear coat parameters of the pbr material.
  48788. */
  48789. export class PBRClearCoatConfiguration {
  48790. /**
  48791. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  48792. * The default fits with a polyurethane material.
  48793. */
  48794. private static readonly _DefaultIndexOfRefraction;
  48795. private _isEnabled;
  48796. /**
  48797. * Defines if the clear coat is enabled in the material.
  48798. */
  48799. isEnabled: boolean;
  48800. /**
  48801. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  48802. */
  48803. intensity: number;
  48804. /**
  48805. * Defines the clear coat layer roughness.
  48806. */
  48807. roughness: number;
  48808. private _indexOfRefraction;
  48809. /**
  48810. * Defines the index of refraction of the clear coat.
  48811. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  48812. * The default fits with a polyurethane material.
  48813. * Changing the default value is more performance intensive.
  48814. */
  48815. indexOfRefraction: number;
  48816. private _texture;
  48817. /**
  48818. * Stores the clear coat values in a texture.
  48819. */
  48820. texture: Nullable<BaseTexture>;
  48821. private _bumpTexture;
  48822. /**
  48823. * Define the clear coat specific bump texture.
  48824. */
  48825. bumpTexture: Nullable<BaseTexture>;
  48826. private _isTintEnabled;
  48827. /**
  48828. * Defines if the clear coat tint is enabled in the material.
  48829. */
  48830. isTintEnabled: boolean;
  48831. /**
  48832. * Defines the clear coat tint of the material.
  48833. * This is only use if tint is enabled
  48834. */
  48835. tintColor: Color3;
  48836. /**
  48837. * Defines the distance at which the tint color should be found in the
  48838. * clear coat media.
  48839. * This is only use if tint is enabled
  48840. */
  48841. tintColorAtDistance: number;
  48842. /**
  48843. * Defines the clear coat layer thickness.
  48844. * This is only use if tint is enabled
  48845. */
  48846. tintThickness: number;
  48847. private _tintTexture;
  48848. /**
  48849. * Stores the clear tint values in a texture.
  48850. * rgb is tint
  48851. * a is a thickness factor
  48852. */
  48853. tintTexture: Nullable<BaseTexture>;
  48854. /** @hidden */
  48855. private _internalMarkAllSubMeshesAsTexturesDirty;
  48856. /** @hidden */
  48857. _markAllSubMeshesAsTexturesDirty(): void;
  48858. /**
  48859. * Instantiate a new istance of clear coat configuration.
  48860. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48861. */
  48862. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48863. /**
  48864. * Gets wehter the submesh is ready to be used or not.
  48865. * @param defines the list of "defines" to update.
  48866. * @param scene defines the scene the material belongs to.
  48867. * @param engine defines the engine the material belongs to.
  48868. * @param disableBumpMap defines wether the material disables bump or not.
  48869. * @returns - boolean indicating that the submesh is ready or not.
  48870. */
  48871. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  48872. /**
  48873. * Checks to see if a texture is used in the material.
  48874. * @param defines the list of "defines" to update.
  48875. * @param scene defines the scene to the material belongs to.
  48876. */
  48877. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  48878. /**
  48879. * Binds the material data.
  48880. * @param uniformBuffer defines the Uniform buffer to fill in.
  48881. * @param scene defines the scene the material belongs to.
  48882. * @param engine defines the engine the material belongs to.
  48883. * @param disableBumpMap defines wether the material disables bump or not.
  48884. * @param isFrozen defines wether the material is frozen or not.
  48885. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  48886. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  48887. */
  48888. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  48889. /**
  48890. * Checks to see if a texture is used in the material.
  48891. * @param texture - Base texture to use.
  48892. * @returns - Boolean specifying if a texture is used in the material.
  48893. */
  48894. hasTexture(texture: BaseTexture): boolean;
  48895. /**
  48896. * Returns an array of the actively used textures.
  48897. * @param activeTextures Array of BaseTextures
  48898. */
  48899. getActiveTextures(activeTextures: BaseTexture[]): void;
  48900. /**
  48901. * Returns the animatable textures.
  48902. * @param animatables Array of animatable textures.
  48903. */
  48904. getAnimatables(animatables: IAnimatable[]): void;
  48905. /**
  48906. * Disposes the resources of the material.
  48907. * @param forceDisposeTextures - Forces the disposal of all textures.
  48908. */
  48909. dispose(forceDisposeTextures?: boolean): void;
  48910. /**
  48911. * Get the current class name of the texture useful for serialization or dynamic coding.
  48912. * @returns "PBRClearCoatConfiguration"
  48913. */
  48914. getClassName(): string;
  48915. /**
  48916. * Add fallbacks to the effect fallbacks list.
  48917. * @param defines defines the Base texture to use.
  48918. * @param fallbacks defines the current fallback list.
  48919. * @param currentRank defines the current fallback rank.
  48920. * @returns the new fallback rank.
  48921. */
  48922. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48923. /**
  48924. * Add the required uniforms to the current list.
  48925. * @param uniforms defines the current uniform list.
  48926. */
  48927. static AddUniforms(uniforms: string[]): void;
  48928. /**
  48929. * Add the required samplers to the current list.
  48930. * @param samplers defines the current sampler list.
  48931. */
  48932. static AddSamplers(samplers: string[]): void;
  48933. /**
  48934. * Add the required uniforms to the current buffer.
  48935. * @param uniformBuffer defines the current uniform buffer.
  48936. */
  48937. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48938. /**
  48939. * Makes a duplicate of the current configuration into another one.
  48940. * @param clearCoatConfiguration define the config where to copy the info
  48941. */
  48942. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  48943. /**
  48944. * Serializes this clear coat configuration.
  48945. * @returns - An object with the serialized config.
  48946. */
  48947. serialize(): any;
  48948. /**
  48949. * Parses a anisotropy Configuration from a serialized object.
  48950. * @param source - Serialized object.
  48951. * @param scene Defines the scene we are parsing for
  48952. * @param rootUrl Defines the rootUrl to load from
  48953. */
  48954. parse(source: any, scene: Scene, rootUrl: string): void;
  48955. }
  48956. }
  48957. declare module BABYLON {
  48958. /**
  48959. * @hidden
  48960. */
  48961. export interface IMaterialAnisotropicDefines {
  48962. ANISOTROPIC: boolean;
  48963. ANISOTROPIC_TEXTURE: boolean;
  48964. ANISOTROPIC_TEXTUREDIRECTUV: number;
  48965. MAINUV1: boolean;
  48966. _areTexturesDirty: boolean;
  48967. _needUVs: boolean;
  48968. }
  48969. /**
  48970. * Define the code related to the anisotropic parameters of the pbr material.
  48971. */
  48972. export class PBRAnisotropicConfiguration {
  48973. private _isEnabled;
  48974. /**
  48975. * Defines if the anisotropy is enabled in the material.
  48976. */
  48977. isEnabled: boolean;
  48978. /**
  48979. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  48980. */
  48981. intensity: number;
  48982. /**
  48983. * Defines if the effect is along the tangents, bitangents or in between.
  48984. * By default, the effect is "strectching" the highlights along the tangents.
  48985. */
  48986. direction: Vector2;
  48987. private _texture;
  48988. /**
  48989. * Stores the anisotropy values in a texture.
  48990. * rg is direction (like normal from -1 to 1)
  48991. * b is a intensity
  48992. */
  48993. texture: Nullable<BaseTexture>;
  48994. /** @hidden */
  48995. private _internalMarkAllSubMeshesAsTexturesDirty;
  48996. /** @hidden */
  48997. _markAllSubMeshesAsTexturesDirty(): void;
  48998. /**
  48999. * Instantiate a new istance of anisotropy configuration.
  49000. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49001. */
  49002. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49003. /**
  49004. * Specifies that the submesh is ready to be used.
  49005. * @param defines the list of "defines" to update.
  49006. * @param scene defines the scene the material belongs to.
  49007. * @returns - boolean indicating that the submesh is ready or not.
  49008. */
  49009. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  49010. /**
  49011. * Checks to see if a texture is used in the material.
  49012. * @param defines the list of "defines" to update.
  49013. * @param mesh the mesh we are preparing the defines for.
  49014. * @param scene defines the scene the material belongs to.
  49015. */
  49016. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  49017. /**
  49018. * Binds the material data.
  49019. * @param uniformBuffer defines the Uniform buffer to fill in.
  49020. * @param scene defines the scene the material belongs to.
  49021. * @param isFrozen defines wether the material is frozen or not.
  49022. */
  49023. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  49024. /**
  49025. * Checks to see if a texture is used in the material.
  49026. * @param texture - Base texture to use.
  49027. * @returns - Boolean specifying if a texture is used in the material.
  49028. */
  49029. hasTexture(texture: BaseTexture): boolean;
  49030. /**
  49031. * Returns an array of the actively used textures.
  49032. * @param activeTextures Array of BaseTextures
  49033. */
  49034. getActiveTextures(activeTextures: BaseTexture[]): void;
  49035. /**
  49036. * Returns the animatable textures.
  49037. * @param animatables Array of animatable textures.
  49038. */
  49039. getAnimatables(animatables: IAnimatable[]): void;
  49040. /**
  49041. * Disposes the resources of the material.
  49042. * @param forceDisposeTextures - Forces the disposal of all textures.
  49043. */
  49044. dispose(forceDisposeTextures?: boolean): void;
  49045. /**
  49046. * Get the current class name of the texture useful for serialization or dynamic coding.
  49047. * @returns "PBRAnisotropicConfiguration"
  49048. */
  49049. getClassName(): string;
  49050. /**
  49051. * Add fallbacks to the effect fallbacks list.
  49052. * @param defines defines the Base texture to use.
  49053. * @param fallbacks defines the current fallback list.
  49054. * @param currentRank defines the current fallback rank.
  49055. * @returns the new fallback rank.
  49056. */
  49057. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49058. /**
  49059. * Add the required uniforms to the current list.
  49060. * @param uniforms defines the current uniform list.
  49061. */
  49062. static AddUniforms(uniforms: string[]): void;
  49063. /**
  49064. * Add the required uniforms to the current buffer.
  49065. * @param uniformBuffer defines the current uniform buffer.
  49066. */
  49067. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49068. /**
  49069. * Add the required samplers to the current list.
  49070. * @param samplers defines the current sampler list.
  49071. */
  49072. static AddSamplers(samplers: string[]): void;
  49073. /**
  49074. * Makes a duplicate of the current configuration into another one.
  49075. * @param anisotropicConfiguration define the config where to copy the info
  49076. */
  49077. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  49078. /**
  49079. * Serializes this anisotropy configuration.
  49080. * @returns - An object with the serialized config.
  49081. */
  49082. serialize(): any;
  49083. /**
  49084. * Parses a anisotropy Configuration from a serialized object.
  49085. * @param source - Serialized object.
  49086. * @param scene Defines the scene we are parsing for
  49087. * @param rootUrl Defines the rootUrl to load from
  49088. */
  49089. parse(source: any, scene: Scene, rootUrl: string): void;
  49090. }
  49091. }
  49092. declare module BABYLON {
  49093. /**
  49094. * @hidden
  49095. */
  49096. export interface IMaterialBRDFDefines {
  49097. BRDF_V_HEIGHT_CORRELATED: boolean;
  49098. MS_BRDF_ENERGY_CONSERVATION: boolean;
  49099. SPHERICAL_HARMONICS: boolean;
  49100. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  49101. /** @hidden */
  49102. _areMiscDirty: boolean;
  49103. }
  49104. /**
  49105. * Define the code related to the BRDF parameters of the pbr material.
  49106. */
  49107. export class PBRBRDFConfiguration {
  49108. /**
  49109. * Default value used for the energy conservation.
  49110. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  49111. */
  49112. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  49113. /**
  49114. * Default value used for the Smith Visibility Height Correlated mode.
  49115. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  49116. */
  49117. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  49118. /**
  49119. * Default value used for the IBL diffuse part.
  49120. * This can help switching back to the polynomials mode globally which is a tiny bit
  49121. * less GPU intensive at the drawback of a lower quality.
  49122. */
  49123. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  49124. /**
  49125. * Default value used for activating energy conservation for the specular workflow.
  49126. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  49127. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  49128. */
  49129. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  49130. private _useEnergyConservation;
  49131. /**
  49132. * Defines if the material uses energy conservation.
  49133. */
  49134. useEnergyConservation: boolean;
  49135. private _useSmithVisibilityHeightCorrelated;
  49136. /**
  49137. * LEGACY Mode set to false
  49138. * Defines if the material uses height smith correlated visibility term.
  49139. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  49140. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  49141. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  49142. * Not relying on height correlated will also disable energy conservation.
  49143. */
  49144. useSmithVisibilityHeightCorrelated: boolean;
  49145. private _useSphericalHarmonics;
  49146. /**
  49147. * LEGACY Mode set to false
  49148. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  49149. * diffuse part of the IBL.
  49150. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  49151. * to the ground truth.
  49152. */
  49153. useSphericalHarmonics: boolean;
  49154. private _useSpecularGlossinessInputEnergyConservation;
  49155. /**
  49156. * Defines if the material uses energy conservation, when the specular workflow is active.
  49157. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  49158. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  49159. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  49160. */
  49161. useSpecularGlossinessInputEnergyConservation: boolean;
  49162. /** @hidden */
  49163. private _internalMarkAllSubMeshesAsMiscDirty;
  49164. /** @hidden */
  49165. _markAllSubMeshesAsMiscDirty(): void;
  49166. /**
  49167. * Instantiate a new istance of clear coat configuration.
  49168. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  49169. */
  49170. constructor(markAllSubMeshesAsMiscDirty: () => void);
  49171. /**
  49172. * Checks to see if a texture is used in the material.
  49173. * @param defines the list of "defines" to update.
  49174. */
  49175. prepareDefines(defines: IMaterialBRDFDefines): void;
  49176. /**
  49177. * Get the current class name of the texture useful for serialization or dynamic coding.
  49178. * @returns "PBRClearCoatConfiguration"
  49179. */
  49180. getClassName(): string;
  49181. /**
  49182. * Makes a duplicate of the current configuration into another one.
  49183. * @param brdfConfiguration define the config where to copy the info
  49184. */
  49185. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  49186. /**
  49187. * Serializes this BRDF configuration.
  49188. * @returns - An object with the serialized config.
  49189. */
  49190. serialize(): any;
  49191. /**
  49192. * Parses a anisotropy Configuration from a serialized object.
  49193. * @param source - Serialized object.
  49194. * @param scene Defines the scene we are parsing for
  49195. * @param rootUrl Defines the rootUrl to load from
  49196. */
  49197. parse(source: any, scene: Scene, rootUrl: string): void;
  49198. }
  49199. }
  49200. declare module BABYLON {
  49201. /**
  49202. * @hidden
  49203. */
  49204. export interface IMaterialSheenDefines {
  49205. SHEEN: boolean;
  49206. SHEEN_TEXTURE: boolean;
  49207. SHEEN_TEXTUREDIRECTUV: number;
  49208. SHEEN_LINKWITHALBEDO: boolean;
  49209. /** @hidden */
  49210. _areTexturesDirty: boolean;
  49211. }
  49212. /**
  49213. * Define the code related to the Sheen parameters of the pbr material.
  49214. */
  49215. export class PBRSheenConfiguration {
  49216. private _isEnabled;
  49217. /**
  49218. * Defines if the material uses sheen.
  49219. */
  49220. isEnabled: boolean;
  49221. private _linkSheenWithAlbedo;
  49222. /**
  49223. * Defines if the sheen is linked to the sheen color.
  49224. */
  49225. linkSheenWithAlbedo: boolean;
  49226. /**
  49227. * Defines the sheen intensity.
  49228. */
  49229. intensity: number;
  49230. /**
  49231. * Defines the sheen color.
  49232. */
  49233. color: Color3;
  49234. private _texture;
  49235. /**
  49236. * Stores the sheen tint values in a texture.
  49237. * rgb is tint
  49238. * a is a intensity
  49239. */
  49240. texture: Nullable<BaseTexture>;
  49241. /** @hidden */
  49242. private _internalMarkAllSubMeshesAsTexturesDirty;
  49243. /** @hidden */
  49244. _markAllSubMeshesAsTexturesDirty(): void;
  49245. /**
  49246. * Instantiate a new istance of clear coat configuration.
  49247. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49248. */
  49249. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49250. /**
  49251. * Specifies that the submesh is ready to be used.
  49252. * @param defines the list of "defines" to update.
  49253. * @param scene defines the scene the material belongs to.
  49254. * @returns - boolean indicating that the submesh is ready or not.
  49255. */
  49256. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  49257. /**
  49258. * Checks to see if a texture is used in the material.
  49259. * @param defines the list of "defines" to update.
  49260. * @param scene defines the scene the material belongs to.
  49261. */
  49262. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  49263. /**
  49264. * Binds the material data.
  49265. * @param uniformBuffer defines the Uniform buffer to fill in.
  49266. * @param scene defines the scene the material belongs to.
  49267. * @param isFrozen defines wether the material is frozen or not.
  49268. */
  49269. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  49270. /**
  49271. * Checks to see if a texture is used in the material.
  49272. * @param texture - Base texture to use.
  49273. * @returns - Boolean specifying if a texture is used in the material.
  49274. */
  49275. hasTexture(texture: BaseTexture): boolean;
  49276. /**
  49277. * Returns an array of the actively used textures.
  49278. * @param activeTextures Array of BaseTextures
  49279. */
  49280. getActiveTextures(activeTextures: BaseTexture[]): void;
  49281. /**
  49282. * Returns the animatable textures.
  49283. * @param animatables Array of animatable textures.
  49284. */
  49285. getAnimatables(animatables: IAnimatable[]): void;
  49286. /**
  49287. * Disposes the resources of the material.
  49288. * @param forceDisposeTextures - Forces the disposal of all textures.
  49289. */
  49290. dispose(forceDisposeTextures?: boolean): void;
  49291. /**
  49292. * Get the current class name of the texture useful for serialization or dynamic coding.
  49293. * @returns "PBRSheenConfiguration"
  49294. */
  49295. getClassName(): string;
  49296. /**
  49297. * Add fallbacks to the effect fallbacks list.
  49298. * @param defines defines the Base texture to use.
  49299. * @param fallbacks defines the current fallback list.
  49300. * @param currentRank defines the current fallback rank.
  49301. * @returns the new fallback rank.
  49302. */
  49303. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49304. /**
  49305. * Add the required uniforms to the current list.
  49306. * @param uniforms defines the current uniform list.
  49307. */
  49308. static AddUniforms(uniforms: string[]): void;
  49309. /**
  49310. * Add the required uniforms to the current buffer.
  49311. * @param uniformBuffer defines the current uniform buffer.
  49312. */
  49313. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49314. /**
  49315. * Add the required samplers to the current list.
  49316. * @param samplers defines the current sampler list.
  49317. */
  49318. static AddSamplers(samplers: string[]): void;
  49319. /**
  49320. * Makes a duplicate of the current configuration into another one.
  49321. * @param sheenConfiguration define the config where to copy the info
  49322. */
  49323. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  49324. /**
  49325. * Serializes this BRDF configuration.
  49326. * @returns - An object with the serialized config.
  49327. */
  49328. serialize(): any;
  49329. /**
  49330. * Parses a anisotropy Configuration from a serialized object.
  49331. * @param source - Serialized object.
  49332. * @param scene Defines the scene we are parsing for
  49333. * @param rootUrl Defines the rootUrl to load from
  49334. */
  49335. parse(source: any, scene: Scene, rootUrl: string): void;
  49336. }
  49337. }
  49338. declare module BABYLON {
  49339. /**
  49340. * @hidden
  49341. */
  49342. export interface IMaterialSubSurfaceDefines {
  49343. SUBSURFACE: boolean;
  49344. SS_REFRACTION: boolean;
  49345. SS_TRANSLUCENCY: boolean;
  49346. SS_SCATERRING: boolean;
  49347. SS_THICKNESSANDMASK_TEXTURE: boolean;
  49348. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  49349. SS_REFRACTIONMAP_3D: boolean;
  49350. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  49351. SS_LODINREFRACTIONALPHA: boolean;
  49352. SS_GAMMAREFRACTION: boolean;
  49353. SS_RGBDREFRACTION: boolean;
  49354. SS_LINEARSPECULARREFRACTION: boolean;
  49355. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  49356. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  49357. /** @hidden */
  49358. _areTexturesDirty: boolean;
  49359. }
  49360. /**
  49361. * Define the code related to the sub surface parameters of the pbr material.
  49362. */
  49363. export class PBRSubSurfaceConfiguration {
  49364. private _isRefractionEnabled;
  49365. /**
  49366. * Defines if the refraction is enabled in the material.
  49367. */
  49368. isRefractionEnabled: boolean;
  49369. private _isTranslucencyEnabled;
  49370. /**
  49371. * Defines if the translucency is enabled in the material.
  49372. */
  49373. isTranslucencyEnabled: boolean;
  49374. private _isScatteringEnabled;
  49375. /**
  49376. * Defines the refraction intensity of the material.
  49377. * The refraction when enabled replaces the Diffuse part of the material.
  49378. * The intensity helps transitionning between diffuse and refraction.
  49379. */
  49380. refractionIntensity: number;
  49381. /**
  49382. * Defines the translucency intensity of the material.
  49383. * When translucency has been enabled, this defines how much of the "translucency"
  49384. * is addded to the diffuse part of the material.
  49385. */
  49386. translucencyIntensity: number;
  49387. /**
  49388. * Defines the scattering intensity of the material.
  49389. * When scattering has been enabled, this defines how much of the "scattered light"
  49390. * is addded to the diffuse part of the material.
  49391. */
  49392. scatteringIntensity: number;
  49393. private _thicknessTexture;
  49394. /**
  49395. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  49396. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  49397. * 0 would mean minimumThickness
  49398. * 1 would mean maximumThickness
  49399. * The other channels might be use as a mask to vary the different effects intensity.
  49400. */
  49401. thicknessTexture: Nullable<BaseTexture>;
  49402. private _refractionTexture;
  49403. /**
  49404. * Defines the texture to use for refraction.
  49405. */
  49406. refractionTexture: Nullable<BaseTexture>;
  49407. private _indexOfRefraction;
  49408. /**
  49409. * Defines the index of refraction used in the material.
  49410. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  49411. */
  49412. indexOfRefraction: number;
  49413. private _invertRefractionY;
  49414. /**
  49415. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  49416. */
  49417. invertRefractionY: boolean;
  49418. private _linkRefractionWithTransparency;
  49419. /**
  49420. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  49421. * Materials half opaque for instance using refraction could benefit from this control.
  49422. */
  49423. linkRefractionWithTransparency: boolean;
  49424. /**
  49425. * Defines the minimum thickness stored in the thickness map.
  49426. * If no thickness map is defined, this value will be used to simulate thickness.
  49427. */
  49428. minimumThickness: number;
  49429. /**
  49430. * Defines the maximum thickness stored in the thickness map.
  49431. */
  49432. maximumThickness: number;
  49433. /**
  49434. * Defines the volume tint of the material.
  49435. * This is used for both translucency and scattering.
  49436. */
  49437. tintColor: Color3;
  49438. /**
  49439. * Defines the distance at which the tint color should be found in the media.
  49440. * This is used for refraction only.
  49441. */
  49442. tintColorAtDistance: number;
  49443. /**
  49444. * Defines how far each channel transmit through the media.
  49445. * It is defined as a color to simplify it selection.
  49446. */
  49447. diffusionDistance: Color3;
  49448. private _useMaskFromThicknessTexture;
  49449. /**
  49450. * Stores the intensity of the different subsurface effects in the thickness texture.
  49451. * * the green channel is the translucency intensity.
  49452. * * the blue channel is the scattering intensity.
  49453. * * the alpha channel is the refraction intensity.
  49454. */
  49455. useMaskFromThicknessTexture: boolean;
  49456. /** @hidden */
  49457. private _internalMarkAllSubMeshesAsTexturesDirty;
  49458. /** @hidden */
  49459. _markAllSubMeshesAsTexturesDirty(): void;
  49460. /**
  49461. * Instantiate a new istance of sub surface configuration.
  49462. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49463. */
  49464. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49465. /**
  49466. * Gets wehter the submesh is ready to be used or not.
  49467. * @param defines the list of "defines" to update.
  49468. * @param scene defines the scene the material belongs to.
  49469. * @returns - boolean indicating that the submesh is ready or not.
  49470. */
  49471. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  49472. /**
  49473. * Checks to see if a texture is used in the material.
  49474. * @param defines the list of "defines" to update.
  49475. * @param scene defines the scene to the material belongs to.
  49476. */
  49477. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  49478. /**
  49479. * Binds the material data.
  49480. * @param uniformBuffer defines the Uniform buffer to fill in.
  49481. * @param scene defines the scene the material belongs to.
  49482. * @param engine defines the engine the material belongs to.
  49483. * @param isFrozen defines wether the material is frozen or not.
  49484. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  49485. */
  49486. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  49487. /**
  49488. * Unbinds the material from the mesh.
  49489. * @param activeEffect defines the effect that should be unbound from.
  49490. * @returns true if unbound, otherwise false
  49491. */
  49492. unbind(activeEffect: Effect): boolean;
  49493. /**
  49494. * Returns the texture used for refraction or null if none is used.
  49495. * @param scene defines the scene the material belongs to.
  49496. * @returns - Refraction texture if present. If no refraction texture and refraction
  49497. * is linked with transparency, returns environment texture. Otherwise, returns null.
  49498. */
  49499. private _getRefractionTexture;
  49500. /**
  49501. * Returns true if alpha blending should be disabled.
  49502. */
  49503. get disableAlphaBlending(): boolean;
  49504. /**
  49505. * Fills the list of render target textures.
  49506. * @param renderTargets the list of render targets to update
  49507. */
  49508. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  49509. /**
  49510. * Checks to see if a texture is used in the material.
  49511. * @param texture - Base texture to use.
  49512. * @returns - Boolean specifying if a texture is used in the material.
  49513. */
  49514. hasTexture(texture: BaseTexture): boolean;
  49515. /**
  49516. * Gets a boolean indicating that current material needs to register RTT
  49517. * @returns true if this uses a render target otherwise false.
  49518. */
  49519. hasRenderTargetTextures(): boolean;
  49520. /**
  49521. * Returns an array of the actively used textures.
  49522. * @param activeTextures Array of BaseTextures
  49523. */
  49524. getActiveTextures(activeTextures: BaseTexture[]): void;
  49525. /**
  49526. * Returns the animatable textures.
  49527. * @param animatables Array of animatable textures.
  49528. */
  49529. getAnimatables(animatables: IAnimatable[]): void;
  49530. /**
  49531. * Disposes the resources of the material.
  49532. * @param forceDisposeTextures - Forces the disposal of all textures.
  49533. */
  49534. dispose(forceDisposeTextures?: boolean): void;
  49535. /**
  49536. * Get the current class name of the texture useful for serialization or dynamic coding.
  49537. * @returns "PBRSubSurfaceConfiguration"
  49538. */
  49539. getClassName(): string;
  49540. /**
  49541. * Add fallbacks to the effect fallbacks list.
  49542. * @param defines defines the Base texture to use.
  49543. * @param fallbacks defines the current fallback list.
  49544. * @param currentRank defines the current fallback rank.
  49545. * @returns the new fallback rank.
  49546. */
  49547. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49548. /**
  49549. * Add the required uniforms to the current list.
  49550. * @param uniforms defines the current uniform list.
  49551. */
  49552. static AddUniforms(uniforms: string[]): void;
  49553. /**
  49554. * Add the required samplers to the current list.
  49555. * @param samplers defines the current sampler list.
  49556. */
  49557. static AddSamplers(samplers: string[]): void;
  49558. /**
  49559. * Add the required uniforms to the current buffer.
  49560. * @param uniformBuffer defines the current uniform buffer.
  49561. */
  49562. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49563. /**
  49564. * Makes a duplicate of the current configuration into another one.
  49565. * @param configuration define the config where to copy the info
  49566. */
  49567. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  49568. /**
  49569. * Serializes this Sub Surface configuration.
  49570. * @returns - An object with the serialized config.
  49571. */
  49572. serialize(): any;
  49573. /**
  49574. * Parses a anisotropy Configuration from a serialized object.
  49575. * @param source - Serialized object.
  49576. * @param scene Defines the scene we are parsing for
  49577. * @param rootUrl Defines the rootUrl to load from
  49578. */
  49579. parse(source: any, scene: Scene, rootUrl: string): void;
  49580. }
  49581. }
  49582. declare module BABYLON {
  49583. /** @hidden */
  49584. export var pbrFragmentDeclaration: {
  49585. name: string;
  49586. shader: string;
  49587. };
  49588. }
  49589. declare module BABYLON {
  49590. /** @hidden */
  49591. export var pbrUboDeclaration: {
  49592. name: string;
  49593. shader: string;
  49594. };
  49595. }
  49596. declare module BABYLON {
  49597. /** @hidden */
  49598. export var pbrFragmentExtraDeclaration: {
  49599. name: string;
  49600. shader: string;
  49601. };
  49602. }
  49603. declare module BABYLON {
  49604. /** @hidden */
  49605. export var pbrFragmentSamplersDeclaration: {
  49606. name: string;
  49607. shader: string;
  49608. };
  49609. }
  49610. declare module BABYLON {
  49611. /** @hidden */
  49612. export var pbrHelperFunctions: {
  49613. name: string;
  49614. shader: string;
  49615. };
  49616. }
  49617. declare module BABYLON {
  49618. /** @hidden */
  49619. export var harmonicsFunctions: {
  49620. name: string;
  49621. shader: string;
  49622. };
  49623. }
  49624. declare module BABYLON {
  49625. /** @hidden */
  49626. export var pbrDirectLightingSetupFunctions: {
  49627. name: string;
  49628. shader: string;
  49629. };
  49630. }
  49631. declare module BABYLON {
  49632. /** @hidden */
  49633. export var pbrDirectLightingFalloffFunctions: {
  49634. name: string;
  49635. shader: string;
  49636. };
  49637. }
  49638. declare module BABYLON {
  49639. /** @hidden */
  49640. export var pbrBRDFFunctions: {
  49641. name: string;
  49642. shader: string;
  49643. };
  49644. }
  49645. declare module BABYLON {
  49646. /** @hidden */
  49647. export var pbrDirectLightingFunctions: {
  49648. name: string;
  49649. shader: string;
  49650. };
  49651. }
  49652. declare module BABYLON {
  49653. /** @hidden */
  49654. export var pbrIBLFunctions: {
  49655. name: string;
  49656. shader: string;
  49657. };
  49658. }
  49659. declare module BABYLON {
  49660. /** @hidden */
  49661. export var pbrDebug: {
  49662. name: string;
  49663. shader: string;
  49664. };
  49665. }
  49666. declare module BABYLON {
  49667. /** @hidden */
  49668. export var pbrPixelShader: {
  49669. name: string;
  49670. shader: string;
  49671. };
  49672. }
  49673. declare module BABYLON {
  49674. /** @hidden */
  49675. export var pbrVertexDeclaration: {
  49676. name: string;
  49677. shader: string;
  49678. };
  49679. }
  49680. declare module BABYLON {
  49681. /** @hidden */
  49682. export var pbrVertexShader: {
  49683. name: string;
  49684. shader: string;
  49685. };
  49686. }
  49687. declare module BABYLON {
  49688. /**
  49689. * Manages the defines for the PBR Material.
  49690. * @hidden
  49691. */
  49692. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  49693. PBR: boolean;
  49694. MAINUV1: boolean;
  49695. MAINUV2: boolean;
  49696. UV1: boolean;
  49697. UV2: boolean;
  49698. ALBEDO: boolean;
  49699. ALBEDODIRECTUV: number;
  49700. VERTEXCOLOR: boolean;
  49701. AMBIENT: boolean;
  49702. AMBIENTDIRECTUV: number;
  49703. AMBIENTINGRAYSCALE: boolean;
  49704. OPACITY: boolean;
  49705. VERTEXALPHA: boolean;
  49706. OPACITYDIRECTUV: number;
  49707. OPACITYRGB: boolean;
  49708. ALPHATEST: boolean;
  49709. DEPTHPREPASS: boolean;
  49710. ALPHABLEND: boolean;
  49711. ALPHAFROMALBEDO: boolean;
  49712. ALPHATESTVALUE: string;
  49713. SPECULAROVERALPHA: boolean;
  49714. RADIANCEOVERALPHA: boolean;
  49715. ALPHAFRESNEL: boolean;
  49716. LINEARALPHAFRESNEL: boolean;
  49717. PREMULTIPLYALPHA: boolean;
  49718. EMISSIVE: boolean;
  49719. EMISSIVEDIRECTUV: number;
  49720. REFLECTIVITY: boolean;
  49721. REFLECTIVITYDIRECTUV: number;
  49722. SPECULARTERM: boolean;
  49723. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  49724. MICROSURFACEAUTOMATIC: boolean;
  49725. LODBASEDMICROSFURACE: boolean;
  49726. MICROSURFACEMAP: boolean;
  49727. MICROSURFACEMAPDIRECTUV: number;
  49728. METALLICWORKFLOW: boolean;
  49729. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  49730. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  49731. METALLNESSSTOREINMETALMAPBLUE: boolean;
  49732. AOSTOREINMETALMAPRED: boolean;
  49733. METALLICF0FACTORFROMMETALLICMAP: boolean;
  49734. ENVIRONMENTBRDF: boolean;
  49735. ENVIRONMENTBRDF_RGBD: boolean;
  49736. NORMAL: boolean;
  49737. TANGENT: boolean;
  49738. BUMP: boolean;
  49739. BUMPDIRECTUV: number;
  49740. OBJECTSPACE_NORMALMAP: boolean;
  49741. PARALLAX: boolean;
  49742. PARALLAXOCCLUSION: boolean;
  49743. NORMALXYSCALE: boolean;
  49744. LIGHTMAP: boolean;
  49745. LIGHTMAPDIRECTUV: number;
  49746. USELIGHTMAPASSHADOWMAP: boolean;
  49747. GAMMALIGHTMAP: boolean;
  49748. RGBDLIGHTMAP: boolean;
  49749. REFLECTION: boolean;
  49750. REFLECTIONMAP_3D: boolean;
  49751. REFLECTIONMAP_SPHERICAL: boolean;
  49752. REFLECTIONMAP_PLANAR: boolean;
  49753. REFLECTIONMAP_CUBIC: boolean;
  49754. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  49755. REFLECTIONMAP_PROJECTION: boolean;
  49756. REFLECTIONMAP_SKYBOX: boolean;
  49757. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  49758. REFLECTIONMAP_EXPLICIT: boolean;
  49759. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  49760. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  49761. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  49762. INVERTCUBICMAP: boolean;
  49763. USESPHERICALFROMREFLECTIONMAP: boolean;
  49764. USEIRRADIANCEMAP: boolean;
  49765. SPHERICAL_HARMONICS: boolean;
  49766. USESPHERICALINVERTEX: boolean;
  49767. REFLECTIONMAP_OPPOSITEZ: boolean;
  49768. LODINREFLECTIONALPHA: boolean;
  49769. GAMMAREFLECTION: boolean;
  49770. RGBDREFLECTION: boolean;
  49771. LINEARSPECULARREFLECTION: boolean;
  49772. RADIANCEOCCLUSION: boolean;
  49773. HORIZONOCCLUSION: boolean;
  49774. INSTANCES: boolean;
  49775. NUM_BONE_INFLUENCERS: number;
  49776. BonesPerMesh: number;
  49777. BONETEXTURE: boolean;
  49778. NONUNIFORMSCALING: boolean;
  49779. MORPHTARGETS: boolean;
  49780. MORPHTARGETS_NORMAL: boolean;
  49781. MORPHTARGETS_TANGENT: boolean;
  49782. MORPHTARGETS_UV: boolean;
  49783. NUM_MORPH_INFLUENCERS: number;
  49784. IMAGEPROCESSING: boolean;
  49785. VIGNETTE: boolean;
  49786. VIGNETTEBLENDMODEMULTIPLY: boolean;
  49787. VIGNETTEBLENDMODEOPAQUE: boolean;
  49788. TONEMAPPING: boolean;
  49789. TONEMAPPING_ACES: boolean;
  49790. CONTRAST: boolean;
  49791. COLORCURVES: boolean;
  49792. COLORGRADING: boolean;
  49793. COLORGRADING3D: boolean;
  49794. SAMPLER3DGREENDEPTH: boolean;
  49795. SAMPLER3DBGRMAP: boolean;
  49796. IMAGEPROCESSINGPOSTPROCESS: boolean;
  49797. EXPOSURE: boolean;
  49798. MULTIVIEW: boolean;
  49799. USEPHYSICALLIGHTFALLOFF: boolean;
  49800. USEGLTFLIGHTFALLOFF: boolean;
  49801. TWOSIDEDLIGHTING: boolean;
  49802. SHADOWFLOAT: boolean;
  49803. CLIPPLANE: boolean;
  49804. CLIPPLANE2: boolean;
  49805. CLIPPLANE3: boolean;
  49806. CLIPPLANE4: boolean;
  49807. CLIPPLANE5: boolean;
  49808. CLIPPLANE6: boolean;
  49809. POINTSIZE: boolean;
  49810. FOG: boolean;
  49811. LOGARITHMICDEPTH: boolean;
  49812. FORCENORMALFORWARD: boolean;
  49813. SPECULARAA: boolean;
  49814. CLEARCOAT: boolean;
  49815. CLEARCOAT_DEFAULTIOR: boolean;
  49816. CLEARCOAT_TEXTURE: boolean;
  49817. CLEARCOAT_TEXTUREDIRECTUV: number;
  49818. CLEARCOAT_BUMP: boolean;
  49819. CLEARCOAT_BUMPDIRECTUV: number;
  49820. CLEARCOAT_TINT: boolean;
  49821. CLEARCOAT_TINT_TEXTURE: boolean;
  49822. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  49823. ANISOTROPIC: boolean;
  49824. ANISOTROPIC_TEXTURE: boolean;
  49825. ANISOTROPIC_TEXTUREDIRECTUV: number;
  49826. BRDF_V_HEIGHT_CORRELATED: boolean;
  49827. MS_BRDF_ENERGY_CONSERVATION: boolean;
  49828. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  49829. SHEEN: boolean;
  49830. SHEEN_TEXTURE: boolean;
  49831. SHEEN_TEXTUREDIRECTUV: number;
  49832. SHEEN_LINKWITHALBEDO: boolean;
  49833. SUBSURFACE: boolean;
  49834. SS_REFRACTION: boolean;
  49835. SS_TRANSLUCENCY: boolean;
  49836. SS_SCATERRING: boolean;
  49837. SS_THICKNESSANDMASK_TEXTURE: boolean;
  49838. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  49839. SS_REFRACTIONMAP_3D: boolean;
  49840. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  49841. SS_LODINREFRACTIONALPHA: boolean;
  49842. SS_GAMMAREFRACTION: boolean;
  49843. SS_RGBDREFRACTION: boolean;
  49844. SS_LINEARSPECULARREFRACTION: boolean;
  49845. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  49846. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  49847. UNLIT: boolean;
  49848. DEBUGMODE: number;
  49849. /**
  49850. * Initializes the PBR Material defines.
  49851. */
  49852. constructor();
  49853. /**
  49854. * Resets the PBR Material defines.
  49855. */
  49856. reset(): void;
  49857. }
  49858. /**
  49859. * The Physically based material base class of BJS.
  49860. *
  49861. * This offers the main features of a standard PBR material.
  49862. * For more information, please refer to the documentation :
  49863. * https://doc.babylonjs.com/how_to/physically_based_rendering
  49864. */
  49865. export abstract class PBRBaseMaterial extends PushMaterial {
  49866. /**
  49867. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  49868. */
  49869. static readonly PBRMATERIAL_OPAQUE: number;
  49870. /**
  49871. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  49872. */
  49873. static readonly PBRMATERIAL_ALPHATEST: number;
  49874. /**
  49875. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49876. */
  49877. static readonly PBRMATERIAL_ALPHABLEND: number;
  49878. /**
  49879. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49880. * They are also discarded below the alpha cutoff threshold to improve performances.
  49881. */
  49882. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  49883. /**
  49884. * Defines the default value of how much AO map is occluding the analytical lights
  49885. * (point spot...).
  49886. */
  49887. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  49888. /**
  49889. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  49890. */
  49891. static readonly LIGHTFALLOFF_PHYSICAL: number;
  49892. /**
  49893. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  49894. * to enhance interoperability with other engines.
  49895. */
  49896. static readonly LIGHTFALLOFF_GLTF: number;
  49897. /**
  49898. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  49899. * to enhance interoperability with other materials.
  49900. */
  49901. static readonly LIGHTFALLOFF_STANDARD: number;
  49902. /**
  49903. * Intensity of the direct lights e.g. the four lights available in your scene.
  49904. * This impacts both the direct diffuse and specular highlights.
  49905. */
  49906. protected _directIntensity: number;
  49907. /**
  49908. * Intensity of the emissive part of the material.
  49909. * This helps controlling the emissive effect without modifying the emissive color.
  49910. */
  49911. protected _emissiveIntensity: number;
  49912. /**
  49913. * Intensity of the environment e.g. how much the environment will light the object
  49914. * either through harmonics for rough material or through the refelction for shiny ones.
  49915. */
  49916. protected _environmentIntensity: number;
  49917. /**
  49918. * This is a special control allowing the reduction of the specular highlights coming from the
  49919. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  49920. */
  49921. protected _specularIntensity: number;
  49922. /**
  49923. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  49924. */
  49925. private _lightingInfos;
  49926. /**
  49927. * Debug Control allowing disabling the bump map on this material.
  49928. */
  49929. protected _disableBumpMap: boolean;
  49930. /**
  49931. * AKA Diffuse Texture in standard nomenclature.
  49932. */
  49933. protected _albedoTexture: Nullable<BaseTexture>;
  49934. /**
  49935. * AKA Occlusion Texture in other nomenclature.
  49936. */
  49937. protected _ambientTexture: Nullable<BaseTexture>;
  49938. /**
  49939. * AKA Occlusion Texture Intensity in other nomenclature.
  49940. */
  49941. protected _ambientTextureStrength: number;
  49942. /**
  49943. * Defines how much the AO map is occluding the analytical lights (point spot...).
  49944. * 1 means it completely occludes it
  49945. * 0 mean it has no impact
  49946. */
  49947. protected _ambientTextureImpactOnAnalyticalLights: number;
  49948. /**
  49949. * Stores the alpha values in a texture.
  49950. */
  49951. protected _opacityTexture: Nullable<BaseTexture>;
  49952. /**
  49953. * Stores the reflection values in a texture.
  49954. */
  49955. protected _reflectionTexture: Nullable<BaseTexture>;
  49956. /**
  49957. * Stores the emissive values in a texture.
  49958. */
  49959. protected _emissiveTexture: Nullable<BaseTexture>;
  49960. /**
  49961. * AKA Specular texture in other nomenclature.
  49962. */
  49963. protected _reflectivityTexture: Nullable<BaseTexture>;
  49964. /**
  49965. * Used to switch from specular/glossiness to metallic/roughness workflow.
  49966. */
  49967. protected _metallicTexture: Nullable<BaseTexture>;
  49968. /**
  49969. * Specifies the metallic scalar of the metallic/roughness workflow.
  49970. * Can also be used to scale the metalness values of the metallic texture.
  49971. */
  49972. protected _metallic: Nullable<number>;
  49973. /**
  49974. * Specifies the roughness scalar of the metallic/roughness workflow.
  49975. * Can also be used to scale the roughness values of the metallic texture.
  49976. */
  49977. protected _roughness: Nullable<number>;
  49978. /**
  49979. * Specifies the an F0 factor to help configuring the material F0.
  49980. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  49981. * to 0.5 the previously hard coded value stays the same.
  49982. * Can also be used to scale the F0 values of the metallic texture.
  49983. */
  49984. protected _metallicF0Factor: number;
  49985. /**
  49986. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  49987. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  49988. * your expectation as it multiplies with the texture data.
  49989. */
  49990. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  49991. /**
  49992. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  49993. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  49994. */
  49995. protected _microSurfaceTexture: Nullable<BaseTexture>;
  49996. /**
  49997. * Stores surface normal data used to displace a mesh in a texture.
  49998. */
  49999. protected _bumpTexture: Nullable<BaseTexture>;
  50000. /**
  50001. * Stores the pre-calculated light information of a mesh in a texture.
  50002. */
  50003. protected _lightmapTexture: Nullable<BaseTexture>;
  50004. /**
  50005. * The color of a material in ambient lighting.
  50006. */
  50007. protected _ambientColor: Color3;
  50008. /**
  50009. * AKA Diffuse Color in other nomenclature.
  50010. */
  50011. protected _albedoColor: Color3;
  50012. /**
  50013. * AKA Specular Color in other nomenclature.
  50014. */
  50015. protected _reflectivityColor: Color3;
  50016. /**
  50017. * The color applied when light is reflected from a material.
  50018. */
  50019. protected _reflectionColor: Color3;
  50020. /**
  50021. * The color applied when light is emitted from a material.
  50022. */
  50023. protected _emissiveColor: Color3;
  50024. /**
  50025. * AKA Glossiness in other nomenclature.
  50026. */
  50027. protected _microSurface: number;
  50028. /**
  50029. * Specifies that the material will use the light map as a show map.
  50030. */
  50031. protected _useLightmapAsShadowmap: boolean;
  50032. /**
  50033. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  50034. * makes the reflect vector face the model (under horizon).
  50035. */
  50036. protected _useHorizonOcclusion: boolean;
  50037. /**
  50038. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  50039. * too much the area relying on ambient texture to define their ambient occlusion.
  50040. */
  50041. protected _useRadianceOcclusion: boolean;
  50042. /**
  50043. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  50044. */
  50045. protected _useAlphaFromAlbedoTexture: boolean;
  50046. /**
  50047. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  50048. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  50049. */
  50050. protected _useSpecularOverAlpha: boolean;
  50051. /**
  50052. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  50053. */
  50054. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  50055. /**
  50056. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  50057. */
  50058. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  50059. /**
  50060. * Specifies if the metallic texture contains the roughness information in its green channel.
  50061. */
  50062. protected _useRoughnessFromMetallicTextureGreen: boolean;
  50063. /**
  50064. * Specifies if the metallic texture contains the metallness information in its blue channel.
  50065. */
  50066. protected _useMetallnessFromMetallicTextureBlue: boolean;
  50067. /**
  50068. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  50069. */
  50070. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  50071. /**
  50072. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  50073. */
  50074. protected _useAmbientInGrayScale: boolean;
  50075. /**
  50076. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  50077. * The material will try to infer what glossiness each pixel should be.
  50078. */
  50079. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  50080. /**
  50081. * Defines the falloff type used in this material.
  50082. * It by default is Physical.
  50083. */
  50084. protected _lightFalloff: number;
  50085. /**
  50086. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  50087. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  50088. */
  50089. protected _useRadianceOverAlpha: boolean;
  50090. /**
  50091. * Allows using an object space normal map (instead of tangent space).
  50092. */
  50093. protected _useObjectSpaceNormalMap: boolean;
  50094. /**
  50095. * Allows using the bump map in parallax mode.
  50096. */
  50097. protected _useParallax: boolean;
  50098. /**
  50099. * Allows using the bump map in parallax occlusion mode.
  50100. */
  50101. protected _useParallaxOcclusion: boolean;
  50102. /**
  50103. * Controls the scale bias of the parallax mode.
  50104. */
  50105. protected _parallaxScaleBias: number;
  50106. /**
  50107. * If sets to true, disables all the lights affecting the material.
  50108. */
  50109. protected _disableLighting: boolean;
  50110. /**
  50111. * Number of Simultaneous lights allowed on the material.
  50112. */
  50113. protected _maxSimultaneousLights: number;
  50114. /**
  50115. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  50116. */
  50117. protected _invertNormalMapX: boolean;
  50118. /**
  50119. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  50120. */
  50121. protected _invertNormalMapY: boolean;
  50122. /**
  50123. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  50124. */
  50125. protected _twoSidedLighting: boolean;
  50126. /**
  50127. * Defines the alpha limits in alpha test mode.
  50128. */
  50129. protected _alphaCutOff: number;
  50130. /**
  50131. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  50132. */
  50133. protected _forceAlphaTest: boolean;
  50134. /**
  50135. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50136. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  50137. */
  50138. protected _useAlphaFresnel: boolean;
  50139. /**
  50140. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50141. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  50142. */
  50143. protected _useLinearAlphaFresnel: boolean;
  50144. /**
  50145. * The transparency mode of the material.
  50146. */
  50147. protected _transparencyMode: Nullable<number>;
  50148. /**
  50149. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  50150. * from cos thetav and roughness:
  50151. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  50152. */
  50153. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  50154. /**
  50155. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  50156. */
  50157. protected _forceIrradianceInFragment: boolean;
  50158. /**
  50159. * Force normal to face away from face.
  50160. */
  50161. protected _forceNormalForward: boolean;
  50162. /**
  50163. * Enables specular anti aliasing in the PBR shader.
  50164. * It will both interacts on the Geometry for analytical and IBL lighting.
  50165. * It also prefilter the roughness map based on the bump values.
  50166. */
  50167. protected _enableSpecularAntiAliasing: boolean;
  50168. /**
  50169. * Default configuration related to image processing available in the PBR Material.
  50170. */
  50171. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  50172. /**
  50173. * Keep track of the image processing observer to allow dispose and replace.
  50174. */
  50175. private _imageProcessingObserver;
  50176. /**
  50177. * Attaches a new image processing configuration to the PBR Material.
  50178. * @param configuration
  50179. */
  50180. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  50181. /**
  50182. * Stores the available render targets.
  50183. */
  50184. private _renderTargets;
  50185. /**
  50186. * Sets the global ambient color for the material used in lighting calculations.
  50187. */
  50188. private _globalAmbientColor;
  50189. /**
  50190. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  50191. */
  50192. private _useLogarithmicDepth;
  50193. /**
  50194. * If set to true, no lighting calculations will be applied.
  50195. */
  50196. private _unlit;
  50197. private _debugMode;
  50198. /**
  50199. * @hidden
  50200. * This is reserved for the inspector.
  50201. * Defines the material debug mode.
  50202. * It helps seeing only some components of the material while troubleshooting.
  50203. */
  50204. debugMode: number;
  50205. /**
  50206. * @hidden
  50207. * This is reserved for the inspector.
  50208. * Specify from where on screen the debug mode should start.
  50209. * The value goes from -1 (full screen) to 1 (not visible)
  50210. * It helps with side by side comparison against the final render
  50211. * This defaults to -1
  50212. */
  50213. private debugLimit;
  50214. /**
  50215. * @hidden
  50216. * This is reserved for the inspector.
  50217. * As the default viewing range might not be enough (if the ambient is really small for instance)
  50218. * You can use the factor to better multiply the final value.
  50219. */
  50220. private debugFactor;
  50221. /**
  50222. * Defines the clear coat layer parameters for the material.
  50223. */
  50224. readonly clearCoat: PBRClearCoatConfiguration;
  50225. /**
  50226. * Defines the anisotropic parameters for the material.
  50227. */
  50228. readonly anisotropy: PBRAnisotropicConfiguration;
  50229. /**
  50230. * Defines the BRDF parameters for the material.
  50231. */
  50232. readonly brdf: PBRBRDFConfiguration;
  50233. /**
  50234. * Defines the Sheen parameters for the material.
  50235. */
  50236. readonly sheen: PBRSheenConfiguration;
  50237. /**
  50238. * Defines the SubSurface parameters for the material.
  50239. */
  50240. readonly subSurface: PBRSubSurfaceConfiguration;
  50241. /**
  50242. * Custom callback helping to override the default shader used in the material.
  50243. */
  50244. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  50245. protected _rebuildInParallel: boolean;
  50246. /**
  50247. * Instantiates a new PBRMaterial instance.
  50248. *
  50249. * @param name The material name
  50250. * @param scene The scene the material will be use in.
  50251. */
  50252. constructor(name: string, scene: Scene);
  50253. /**
  50254. * Gets a boolean indicating that current material needs to register RTT
  50255. */
  50256. get hasRenderTargetTextures(): boolean;
  50257. /**
  50258. * Gets the name of the material class.
  50259. */
  50260. getClassName(): string;
  50261. /**
  50262. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  50263. */
  50264. get useLogarithmicDepth(): boolean;
  50265. /**
  50266. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  50267. */
  50268. set useLogarithmicDepth(value: boolean);
  50269. /**
  50270. * Gets the current transparency mode.
  50271. */
  50272. get transparencyMode(): Nullable<number>;
  50273. /**
  50274. * Sets the transparency mode of the material.
  50275. *
  50276. * | Value | Type | Description |
  50277. * | ----- | ----------------------------------- | ----------- |
  50278. * | 0 | OPAQUE | |
  50279. * | 1 | ALPHATEST | |
  50280. * | 2 | ALPHABLEND | |
  50281. * | 3 | ALPHATESTANDBLEND | |
  50282. *
  50283. */
  50284. set transparencyMode(value: Nullable<number>);
  50285. /**
  50286. * Returns true if alpha blending should be disabled.
  50287. */
  50288. private get _disableAlphaBlending();
  50289. /**
  50290. * Specifies whether or not this material should be rendered in alpha blend mode.
  50291. */
  50292. needAlphaBlending(): boolean;
  50293. /**
  50294. * Specifies if the mesh will require alpha blending.
  50295. * @param mesh - BJS mesh.
  50296. */
  50297. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  50298. /**
  50299. * Specifies whether or not this material should be rendered in alpha test mode.
  50300. */
  50301. needAlphaTesting(): boolean;
  50302. /**
  50303. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  50304. */
  50305. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  50306. /**
  50307. * Gets the texture used for the alpha test.
  50308. */
  50309. getAlphaTestTexture(): Nullable<BaseTexture>;
  50310. /**
  50311. * Specifies that the submesh is ready to be used.
  50312. * @param mesh - BJS mesh.
  50313. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  50314. * @param useInstances - Specifies that instances should be used.
  50315. * @returns - boolean indicating that the submesh is ready or not.
  50316. */
  50317. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  50318. /**
  50319. * Specifies if the material uses metallic roughness workflow.
  50320. * @returns boolean specifiying if the material uses metallic roughness workflow.
  50321. */
  50322. isMetallicWorkflow(): boolean;
  50323. private _prepareEffect;
  50324. private _prepareDefines;
  50325. /**
  50326. * Force shader compilation
  50327. */
  50328. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  50329. /**
  50330. * Initializes the uniform buffer layout for the shader.
  50331. */
  50332. buildUniformLayout(): void;
  50333. /**
  50334. * Unbinds the material from the mesh
  50335. */
  50336. unbind(): void;
  50337. /**
  50338. * Binds the submesh data.
  50339. * @param world - The world matrix.
  50340. * @param mesh - The BJS mesh.
  50341. * @param subMesh - A submesh of the BJS mesh.
  50342. */
  50343. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  50344. /**
  50345. * Returns the animatable textures.
  50346. * @returns - Array of animatable textures.
  50347. */
  50348. getAnimatables(): IAnimatable[];
  50349. /**
  50350. * Returns the texture used for reflections.
  50351. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  50352. */
  50353. private _getReflectionTexture;
  50354. /**
  50355. * Returns an array of the actively used textures.
  50356. * @returns - Array of BaseTextures
  50357. */
  50358. getActiveTextures(): BaseTexture[];
  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. * Disposes the resources of the material.
  50367. * @param forceDisposeEffect - Forces the disposal of effects.
  50368. * @param forceDisposeTextures - Forces the disposal of all textures.
  50369. */
  50370. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  50371. }
  50372. }
  50373. declare module BABYLON {
  50374. /**
  50375. * The Physically based material of BJS.
  50376. *
  50377. * This offers the main features of a standard PBR material.
  50378. * For more information, please refer to the documentation :
  50379. * https://doc.babylonjs.com/how_to/physically_based_rendering
  50380. */
  50381. export class PBRMaterial extends PBRBaseMaterial {
  50382. /**
  50383. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  50384. */
  50385. static readonly PBRMATERIAL_OPAQUE: number;
  50386. /**
  50387. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  50388. */
  50389. static readonly PBRMATERIAL_ALPHATEST: number;
  50390. /**
  50391. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50392. */
  50393. static readonly PBRMATERIAL_ALPHABLEND: number;
  50394. /**
  50395. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50396. * They are also discarded below the alpha cutoff threshold to improve performances.
  50397. */
  50398. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  50399. /**
  50400. * Defines the default value of how much AO map is occluding the analytical lights
  50401. * (point spot...).
  50402. */
  50403. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  50404. /**
  50405. * Intensity of the direct lights e.g. the four lights available in your scene.
  50406. * This impacts both the direct diffuse and specular highlights.
  50407. */
  50408. directIntensity: number;
  50409. /**
  50410. * Intensity of the emissive part of the material.
  50411. * This helps controlling the emissive effect without modifying the emissive color.
  50412. */
  50413. emissiveIntensity: number;
  50414. /**
  50415. * Intensity of the environment e.g. how much the environment will light the object
  50416. * either through harmonics for rough material or through the refelction for shiny ones.
  50417. */
  50418. environmentIntensity: number;
  50419. /**
  50420. * This is a special control allowing the reduction of the specular highlights coming from the
  50421. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  50422. */
  50423. specularIntensity: number;
  50424. /**
  50425. * Debug Control allowing disabling the bump map on this material.
  50426. */
  50427. disableBumpMap: boolean;
  50428. /**
  50429. * AKA Diffuse Texture in standard nomenclature.
  50430. */
  50431. albedoTexture: BaseTexture;
  50432. /**
  50433. * AKA Occlusion Texture in other nomenclature.
  50434. */
  50435. ambientTexture: BaseTexture;
  50436. /**
  50437. * AKA Occlusion Texture Intensity in other nomenclature.
  50438. */
  50439. ambientTextureStrength: number;
  50440. /**
  50441. * Defines how much the AO map is occluding the analytical lights (point spot...).
  50442. * 1 means it completely occludes it
  50443. * 0 mean it has no impact
  50444. */
  50445. ambientTextureImpactOnAnalyticalLights: number;
  50446. /**
  50447. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  50448. */
  50449. opacityTexture: BaseTexture;
  50450. /**
  50451. * Stores the reflection values in a texture.
  50452. */
  50453. reflectionTexture: Nullable<BaseTexture>;
  50454. /**
  50455. * Stores the emissive values in a texture.
  50456. */
  50457. emissiveTexture: BaseTexture;
  50458. /**
  50459. * AKA Specular texture in other nomenclature.
  50460. */
  50461. reflectivityTexture: BaseTexture;
  50462. /**
  50463. * Used to switch from specular/glossiness to metallic/roughness workflow.
  50464. */
  50465. metallicTexture: BaseTexture;
  50466. /**
  50467. * Specifies the metallic scalar of the metallic/roughness workflow.
  50468. * Can also be used to scale the metalness values of the metallic texture.
  50469. */
  50470. metallic: Nullable<number>;
  50471. /**
  50472. * Specifies the roughness scalar of the metallic/roughness workflow.
  50473. * Can also be used to scale the roughness values of the metallic texture.
  50474. */
  50475. roughness: Nullable<number>;
  50476. /**
  50477. * Specifies the an F0 factor to help configuring the material F0.
  50478. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  50479. * to 0.5 the previously hard coded value stays the same.
  50480. * Can also be used to scale the F0 values of the metallic texture.
  50481. */
  50482. metallicF0Factor: number;
  50483. /**
  50484. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  50485. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  50486. * your expectation as it multiplies with the texture data.
  50487. */
  50488. useMetallicF0FactorFromMetallicTexture: boolean;
  50489. /**
  50490. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  50491. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  50492. */
  50493. microSurfaceTexture: BaseTexture;
  50494. /**
  50495. * Stores surface normal data used to displace a mesh in a texture.
  50496. */
  50497. bumpTexture: BaseTexture;
  50498. /**
  50499. * Stores the pre-calculated light information of a mesh in a texture.
  50500. */
  50501. lightmapTexture: BaseTexture;
  50502. /**
  50503. * Stores the refracted light information in a texture.
  50504. */
  50505. get refractionTexture(): Nullable<BaseTexture>;
  50506. set refractionTexture(value: Nullable<BaseTexture>);
  50507. /**
  50508. * The color of a material in ambient lighting.
  50509. */
  50510. ambientColor: Color3;
  50511. /**
  50512. * AKA Diffuse Color in other nomenclature.
  50513. */
  50514. albedoColor: Color3;
  50515. /**
  50516. * AKA Specular Color in other nomenclature.
  50517. */
  50518. reflectivityColor: Color3;
  50519. /**
  50520. * The color reflected from the material.
  50521. */
  50522. reflectionColor: Color3;
  50523. /**
  50524. * The color emitted from the material.
  50525. */
  50526. emissiveColor: Color3;
  50527. /**
  50528. * AKA Glossiness in other nomenclature.
  50529. */
  50530. microSurface: number;
  50531. /**
  50532. * source material index of refraction (IOR)' / 'destination material IOR.
  50533. */
  50534. get indexOfRefraction(): number;
  50535. set indexOfRefraction(value: number);
  50536. /**
  50537. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  50538. */
  50539. get invertRefractionY(): boolean;
  50540. set invertRefractionY(value: boolean);
  50541. /**
  50542. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  50543. * Materials half opaque for instance using refraction could benefit from this control.
  50544. */
  50545. get linkRefractionWithTransparency(): boolean;
  50546. set linkRefractionWithTransparency(value: boolean);
  50547. /**
  50548. * If true, the light map contains occlusion information instead of lighting info.
  50549. */
  50550. useLightmapAsShadowmap: boolean;
  50551. /**
  50552. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  50553. */
  50554. useAlphaFromAlbedoTexture: boolean;
  50555. /**
  50556. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  50557. */
  50558. forceAlphaTest: boolean;
  50559. /**
  50560. * Defines the alpha limits in alpha test mode.
  50561. */
  50562. alphaCutOff: number;
  50563. /**
  50564. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  50565. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  50566. */
  50567. useSpecularOverAlpha: boolean;
  50568. /**
  50569. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  50570. */
  50571. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  50572. /**
  50573. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  50574. */
  50575. useRoughnessFromMetallicTextureAlpha: boolean;
  50576. /**
  50577. * Specifies if the metallic texture contains the roughness information in its green channel.
  50578. */
  50579. useRoughnessFromMetallicTextureGreen: boolean;
  50580. /**
  50581. * Specifies if the metallic texture contains the metallness information in its blue channel.
  50582. */
  50583. useMetallnessFromMetallicTextureBlue: boolean;
  50584. /**
  50585. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  50586. */
  50587. useAmbientOcclusionFromMetallicTextureRed: boolean;
  50588. /**
  50589. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  50590. */
  50591. useAmbientInGrayScale: boolean;
  50592. /**
  50593. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  50594. * The material will try to infer what glossiness each pixel should be.
  50595. */
  50596. useAutoMicroSurfaceFromReflectivityMap: boolean;
  50597. /**
  50598. * BJS is using an harcoded light falloff based on a manually sets up range.
  50599. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  50600. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  50601. */
  50602. get usePhysicalLightFalloff(): boolean;
  50603. /**
  50604. * BJS is using an harcoded light falloff based on a manually sets up range.
  50605. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  50606. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  50607. */
  50608. set usePhysicalLightFalloff(value: boolean);
  50609. /**
  50610. * In order to support the falloff compatibility with gltf, a special mode has been added
  50611. * to reproduce the gltf light falloff.
  50612. */
  50613. get useGLTFLightFalloff(): boolean;
  50614. /**
  50615. * In order to support the falloff compatibility with gltf, a special mode has been added
  50616. * to reproduce the gltf light falloff.
  50617. */
  50618. set useGLTFLightFalloff(value: boolean);
  50619. /**
  50620. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  50621. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  50622. */
  50623. useRadianceOverAlpha: boolean;
  50624. /**
  50625. * Allows using an object space normal map (instead of tangent space).
  50626. */
  50627. useObjectSpaceNormalMap: boolean;
  50628. /**
  50629. * Allows using the bump map in parallax mode.
  50630. */
  50631. useParallax: boolean;
  50632. /**
  50633. * Allows using the bump map in parallax occlusion mode.
  50634. */
  50635. useParallaxOcclusion: boolean;
  50636. /**
  50637. * Controls the scale bias of the parallax mode.
  50638. */
  50639. parallaxScaleBias: number;
  50640. /**
  50641. * If sets to true, disables all the lights affecting the material.
  50642. */
  50643. disableLighting: boolean;
  50644. /**
  50645. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  50646. */
  50647. forceIrradianceInFragment: boolean;
  50648. /**
  50649. * Number of Simultaneous lights allowed on the material.
  50650. */
  50651. maxSimultaneousLights: number;
  50652. /**
  50653. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  50654. */
  50655. invertNormalMapX: boolean;
  50656. /**
  50657. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  50658. */
  50659. invertNormalMapY: boolean;
  50660. /**
  50661. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  50662. */
  50663. twoSidedLighting: boolean;
  50664. /**
  50665. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50666. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  50667. */
  50668. useAlphaFresnel: boolean;
  50669. /**
  50670. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50671. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  50672. */
  50673. useLinearAlphaFresnel: boolean;
  50674. /**
  50675. * Let user defines the brdf lookup texture used for IBL.
  50676. * A default 8bit version is embedded but you could point at :
  50677. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  50678. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  50679. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  50680. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  50681. */
  50682. environmentBRDFTexture: Nullable<BaseTexture>;
  50683. /**
  50684. * Force normal to face away from face.
  50685. */
  50686. forceNormalForward: boolean;
  50687. /**
  50688. * Enables specular anti aliasing in the PBR shader.
  50689. * It will both interacts on the Geometry for analytical and IBL lighting.
  50690. * It also prefilter the roughness map based on the bump values.
  50691. */
  50692. enableSpecularAntiAliasing: boolean;
  50693. /**
  50694. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  50695. * makes the reflect vector face the model (under horizon).
  50696. */
  50697. useHorizonOcclusion: boolean;
  50698. /**
  50699. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  50700. * too much the area relying on ambient texture to define their ambient occlusion.
  50701. */
  50702. useRadianceOcclusion: boolean;
  50703. /**
  50704. * If set to true, no lighting calculations will be applied.
  50705. */
  50706. unlit: boolean;
  50707. /**
  50708. * Gets the image processing configuration used either in this material.
  50709. */
  50710. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  50711. /**
  50712. * Sets the Default image processing configuration used either in the this material.
  50713. *
  50714. * If sets to null, the scene one is in use.
  50715. */
  50716. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  50717. /**
  50718. * Gets wether the color curves effect is enabled.
  50719. */
  50720. get cameraColorCurvesEnabled(): boolean;
  50721. /**
  50722. * Sets wether the color curves effect is enabled.
  50723. */
  50724. set cameraColorCurvesEnabled(value: boolean);
  50725. /**
  50726. * Gets wether the color grading effect is enabled.
  50727. */
  50728. get cameraColorGradingEnabled(): boolean;
  50729. /**
  50730. * Gets wether the color grading effect is enabled.
  50731. */
  50732. set cameraColorGradingEnabled(value: boolean);
  50733. /**
  50734. * Gets wether tonemapping is enabled or not.
  50735. */
  50736. get cameraToneMappingEnabled(): boolean;
  50737. /**
  50738. * Sets wether tonemapping is enabled or not
  50739. */
  50740. set cameraToneMappingEnabled(value: boolean);
  50741. /**
  50742. * The camera exposure used on this material.
  50743. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  50744. * This corresponds to a photographic exposure.
  50745. */
  50746. get cameraExposure(): number;
  50747. /**
  50748. * The camera exposure used on this material.
  50749. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  50750. * This corresponds to a photographic exposure.
  50751. */
  50752. set cameraExposure(value: number);
  50753. /**
  50754. * Gets The camera contrast used on this material.
  50755. */
  50756. get cameraContrast(): number;
  50757. /**
  50758. * Sets The camera contrast used on this material.
  50759. */
  50760. set cameraContrast(value: number);
  50761. /**
  50762. * Gets the Color Grading 2D Lookup Texture.
  50763. */
  50764. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  50765. /**
  50766. * Sets the Color Grading 2D Lookup Texture.
  50767. */
  50768. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  50769. /**
  50770. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  50771. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  50772. * 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;
  50773. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  50774. */
  50775. get cameraColorCurves(): Nullable<ColorCurves>;
  50776. /**
  50777. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  50778. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  50779. * 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;
  50780. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  50781. */
  50782. set cameraColorCurves(value: Nullable<ColorCurves>);
  50783. /**
  50784. * Instantiates a new PBRMaterial instance.
  50785. *
  50786. * @param name The material name
  50787. * @param scene The scene the material will be use in.
  50788. */
  50789. constructor(name: string, scene: Scene);
  50790. /**
  50791. * Returns the name of this material class.
  50792. */
  50793. getClassName(): string;
  50794. /**
  50795. * Makes a duplicate of the current material.
  50796. * @param name - name to use for the new material.
  50797. */
  50798. clone(name: string): PBRMaterial;
  50799. /**
  50800. * Serializes this PBR Material.
  50801. * @returns - An object with the serialized material.
  50802. */
  50803. serialize(): any;
  50804. /**
  50805. * Parses a PBR Material from a serialized object.
  50806. * @param source - Serialized object.
  50807. * @param scene - BJS scene instance.
  50808. * @param rootUrl - url for the scene object
  50809. * @returns - PBRMaterial
  50810. */
  50811. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  50812. }
  50813. }
  50814. declare module BABYLON {
  50815. /**
  50816. * Direct draw surface info
  50817. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  50818. */
  50819. export interface DDSInfo {
  50820. /**
  50821. * Width of the texture
  50822. */
  50823. width: number;
  50824. /**
  50825. * Width of the texture
  50826. */
  50827. height: number;
  50828. /**
  50829. * Number of Mipmaps for the texture
  50830. * @see https://en.wikipedia.org/wiki/Mipmap
  50831. */
  50832. mipmapCount: number;
  50833. /**
  50834. * If the textures format is a known fourCC format
  50835. * @see https://www.fourcc.org/
  50836. */
  50837. isFourCC: boolean;
  50838. /**
  50839. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  50840. */
  50841. isRGB: boolean;
  50842. /**
  50843. * If the texture is a lumincance format
  50844. */
  50845. isLuminance: boolean;
  50846. /**
  50847. * If this is a cube texture
  50848. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  50849. */
  50850. isCube: boolean;
  50851. /**
  50852. * If the texture is a compressed format eg. FOURCC_DXT1
  50853. */
  50854. isCompressed: boolean;
  50855. /**
  50856. * The dxgiFormat of the texture
  50857. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  50858. */
  50859. dxgiFormat: number;
  50860. /**
  50861. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  50862. */
  50863. textureType: number;
  50864. /**
  50865. * Sphericle polynomial created for the dds texture
  50866. */
  50867. sphericalPolynomial?: SphericalPolynomial;
  50868. }
  50869. /**
  50870. * Class used to provide DDS decompression tools
  50871. */
  50872. export class DDSTools {
  50873. /**
  50874. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  50875. */
  50876. static StoreLODInAlphaChannel: boolean;
  50877. /**
  50878. * Gets DDS information from an array buffer
  50879. * @param arrayBuffer defines the array buffer to read data from
  50880. * @returns the DDS information
  50881. */
  50882. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  50883. private static _FloatView;
  50884. private static _Int32View;
  50885. private static _ToHalfFloat;
  50886. private static _FromHalfFloat;
  50887. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  50888. private static _GetHalfFloatRGBAArrayBuffer;
  50889. private static _GetFloatRGBAArrayBuffer;
  50890. private static _GetFloatAsUIntRGBAArrayBuffer;
  50891. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  50892. private static _GetRGBAArrayBuffer;
  50893. private static _ExtractLongWordOrder;
  50894. private static _GetRGBArrayBuffer;
  50895. private static _GetLuminanceArrayBuffer;
  50896. /**
  50897. * Uploads DDS Levels to a Babylon Texture
  50898. * @hidden
  50899. */
  50900. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  50901. }
  50902. interface ThinEngine {
  50903. /**
  50904. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  50905. * @param rootUrl defines the url where the file to load is located
  50906. * @param scene defines the current scene
  50907. * @param lodScale defines scale to apply to the mip map selection
  50908. * @param lodOffset defines offset to apply to the mip map selection
  50909. * @param onLoad defines an optional callback raised when the texture is loaded
  50910. * @param onError defines an optional callback raised if there is an issue to load the texture
  50911. * @param format defines the format of the data
  50912. * @param forcedExtension defines the extension to use to pick the right loader
  50913. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  50914. * @returns the cube texture as an InternalTexture
  50915. */
  50916. 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;
  50917. }
  50918. }
  50919. declare module BABYLON {
  50920. /**
  50921. * Implementation of the DDS Texture Loader.
  50922. * @hidden
  50923. */
  50924. export class _DDSTextureLoader implements IInternalTextureLoader {
  50925. /**
  50926. * Defines wether the loader supports cascade loading the different faces.
  50927. */
  50928. readonly supportCascades: boolean;
  50929. /**
  50930. * This returns if the loader support the current file information.
  50931. * @param extension defines the file extension of the file being loaded
  50932. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50933. * @param fallback defines the fallback internal texture if any
  50934. * @param isBase64 defines whether the texture is encoded as a base64
  50935. * @param isBuffer defines whether the texture data are stored as a buffer
  50936. * @returns true if the loader can load the specified file
  50937. */
  50938. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50939. /**
  50940. * Transform the url before loading if required.
  50941. * @param rootUrl the url of the texture
  50942. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50943. * @returns the transformed texture
  50944. */
  50945. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50946. /**
  50947. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50948. * @param rootUrl the url of the texture
  50949. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50950. * @returns the fallback texture
  50951. */
  50952. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50953. /**
  50954. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50955. * @param data contains the texture data
  50956. * @param texture defines the BabylonJS internal texture
  50957. * @param createPolynomials will be true if polynomials have been requested
  50958. * @param onLoad defines the callback to trigger once the texture is ready
  50959. * @param onError defines the callback to trigger in case of error
  50960. */
  50961. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50962. /**
  50963. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50964. * @param data contains the texture data
  50965. * @param texture defines the BabylonJS internal texture
  50966. * @param callback defines the method to call once ready to upload
  50967. */
  50968. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  50969. }
  50970. }
  50971. declare module BABYLON {
  50972. /**
  50973. * Implementation of the ENV Texture Loader.
  50974. * @hidden
  50975. */
  50976. export class _ENVTextureLoader implements IInternalTextureLoader {
  50977. /**
  50978. * Defines wether the loader supports cascade loading the different faces.
  50979. */
  50980. readonly supportCascades: boolean;
  50981. /**
  50982. * This returns if the loader support the current file information.
  50983. * @param extension defines the file extension of the file being loaded
  50984. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50985. * @param fallback defines the fallback internal texture if any
  50986. * @param isBase64 defines whether the texture is encoded as a base64
  50987. * @param isBuffer defines whether the texture data are stored as a buffer
  50988. * @returns true if the loader can load the specified file
  50989. */
  50990. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50991. /**
  50992. * Transform the url before loading if required.
  50993. * @param rootUrl the url of the texture
  50994. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50995. * @returns the transformed texture
  50996. */
  50997. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50998. /**
  50999. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51000. * @param rootUrl the url of the texture
  51001. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51002. * @returns the fallback texture
  51003. */
  51004. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51005. /**
  51006. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51007. * @param data contains the texture data
  51008. * @param texture defines the BabylonJS internal texture
  51009. * @param createPolynomials will be true if polynomials have been requested
  51010. * @param onLoad defines the callback to trigger once the texture is ready
  51011. * @param onError defines the callback to trigger in case of error
  51012. */
  51013. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51014. /**
  51015. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51016. * @param data contains the texture data
  51017. * @param texture defines the BabylonJS internal texture
  51018. * @param callback defines the method to call once ready to upload
  51019. */
  51020. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51021. }
  51022. }
  51023. declare module BABYLON {
  51024. /**
  51025. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  51026. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  51027. */
  51028. export class KhronosTextureContainer {
  51029. /** contents of the KTX container file */
  51030. arrayBuffer: any;
  51031. private static HEADER_LEN;
  51032. private static COMPRESSED_2D;
  51033. private static COMPRESSED_3D;
  51034. private static TEX_2D;
  51035. private static TEX_3D;
  51036. /**
  51037. * Gets the openGL type
  51038. */
  51039. glType: number;
  51040. /**
  51041. * Gets the openGL type size
  51042. */
  51043. glTypeSize: number;
  51044. /**
  51045. * Gets the openGL format
  51046. */
  51047. glFormat: number;
  51048. /**
  51049. * Gets the openGL internal format
  51050. */
  51051. glInternalFormat: number;
  51052. /**
  51053. * Gets the base internal format
  51054. */
  51055. glBaseInternalFormat: number;
  51056. /**
  51057. * Gets image width in pixel
  51058. */
  51059. pixelWidth: number;
  51060. /**
  51061. * Gets image height in pixel
  51062. */
  51063. pixelHeight: number;
  51064. /**
  51065. * Gets image depth in pixels
  51066. */
  51067. pixelDepth: number;
  51068. /**
  51069. * Gets the number of array elements
  51070. */
  51071. numberOfArrayElements: number;
  51072. /**
  51073. * Gets the number of faces
  51074. */
  51075. numberOfFaces: number;
  51076. /**
  51077. * Gets the number of mipmap levels
  51078. */
  51079. numberOfMipmapLevels: number;
  51080. /**
  51081. * Gets the bytes of key value data
  51082. */
  51083. bytesOfKeyValueData: number;
  51084. /**
  51085. * Gets the load type
  51086. */
  51087. loadType: number;
  51088. /**
  51089. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  51090. */
  51091. isInvalid: boolean;
  51092. /**
  51093. * Creates a new KhronosTextureContainer
  51094. * @param arrayBuffer contents of the KTX container file
  51095. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  51096. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  51097. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  51098. */
  51099. constructor(
  51100. /** contents of the KTX container file */
  51101. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  51102. /**
  51103. * Uploads KTX content to a Babylon Texture.
  51104. * It is assumed that the texture has already been created & is currently bound
  51105. * @hidden
  51106. */
  51107. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  51108. private _upload2DCompressedLevels;
  51109. }
  51110. }
  51111. declare module BABYLON {
  51112. /**
  51113. * Implementation of the KTX Texture Loader.
  51114. * @hidden
  51115. */
  51116. export class _KTXTextureLoader implements IInternalTextureLoader {
  51117. /**
  51118. * Defines wether the loader supports cascade loading the different faces.
  51119. */
  51120. readonly supportCascades: boolean;
  51121. /**
  51122. * This returns if the loader support the current file information.
  51123. * @param extension defines the file extension of the file being loaded
  51124. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51125. * @param fallback defines the fallback internal texture if any
  51126. * @param isBase64 defines whether the texture is encoded as a base64
  51127. * @param isBuffer defines whether the texture data are stored as a buffer
  51128. * @returns true if the loader can load the specified file
  51129. */
  51130. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51131. /**
  51132. * Transform the url before loading if required.
  51133. * @param rootUrl the url of the texture
  51134. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51135. * @returns the transformed texture
  51136. */
  51137. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51138. /**
  51139. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51140. * @param rootUrl the url of the texture
  51141. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51142. * @returns the fallback texture
  51143. */
  51144. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51145. /**
  51146. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51147. * @param data contains the texture data
  51148. * @param texture defines the BabylonJS internal texture
  51149. * @param createPolynomials will be true if polynomials have been requested
  51150. * @param onLoad defines the callback to trigger once the texture is ready
  51151. * @param onError defines the callback to trigger in case of error
  51152. */
  51153. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51154. /**
  51155. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51156. * @param data contains the texture data
  51157. * @param texture defines the BabylonJS internal texture
  51158. * @param callback defines the method to call once ready to upload
  51159. */
  51160. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  51161. }
  51162. }
  51163. declare module BABYLON {
  51164. /** @hidden */
  51165. export var _forceSceneHelpersToBundle: boolean;
  51166. interface Scene {
  51167. /**
  51168. * Creates a default light for the scene.
  51169. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  51170. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  51171. */
  51172. createDefaultLight(replace?: boolean): void;
  51173. /**
  51174. * Creates a default camera for the scene.
  51175. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  51176. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  51177. * @param replace has default false, when true replaces the active camera in the scene
  51178. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  51179. */
  51180. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  51181. /**
  51182. * Creates a default camera and a default light.
  51183. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  51184. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  51185. * @param replace has the default false, when true replaces the active camera/light in the scene
  51186. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  51187. */
  51188. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  51189. /**
  51190. * Creates a new sky box
  51191. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  51192. * @param environmentTexture defines the texture to use as environment texture
  51193. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  51194. * @param scale defines the overall scale of the skybox
  51195. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  51196. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  51197. * @returns a new mesh holding the sky box
  51198. */
  51199. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  51200. /**
  51201. * Creates a new environment
  51202. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  51203. * @param options defines the options you can use to configure the environment
  51204. * @returns the new EnvironmentHelper
  51205. */
  51206. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  51207. /**
  51208. * Creates a new VREXperienceHelper
  51209. * @see http://doc.babylonjs.com/how_to/webvr_helper
  51210. * @param webVROptions defines the options used to create the new VREXperienceHelper
  51211. * @returns a new VREXperienceHelper
  51212. */
  51213. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  51214. /**
  51215. * Creates a new WebXRDefaultExperience
  51216. * @see http://doc.babylonjs.com/how_to/webxr
  51217. * @param options experience options
  51218. * @returns a promise for a new WebXRDefaultExperience
  51219. */
  51220. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  51221. }
  51222. }
  51223. declare module BABYLON {
  51224. /**
  51225. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  51226. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  51227. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  51228. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  51229. */
  51230. export class VideoDome extends TransformNode {
  51231. /**
  51232. * Define the video source as a Monoscopic panoramic 360 video.
  51233. */
  51234. static readonly MODE_MONOSCOPIC: number;
  51235. /**
  51236. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  51237. */
  51238. static readonly MODE_TOPBOTTOM: number;
  51239. /**
  51240. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  51241. */
  51242. static readonly MODE_SIDEBYSIDE: number;
  51243. private _halfDome;
  51244. private _useDirectMapping;
  51245. /**
  51246. * The video texture being displayed on the sphere
  51247. */
  51248. protected _videoTexture: VideoTexture;
  51249. /**
  51250. * Gets the video texture being displayed on the sphere
  51251. */
  51252. get videoTexture(): VideoTexture;
  51253. /**
  51254. * The skybox material
  51255. */
  51256. protected _material: BackgroundMaterial;
  51257. /**
  51258. * The surface used for the skybox
  51259. */
  51260. protected _mesh: Mesh;
  51261. /**
  51262. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  51263. */
  51264. private _halfDomeMask;
  51265. /**
  51266. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  51267. * Also see the options.resolution property.
  51268. */
  51269. get fovMultiplier(): number;
  51270. set fovMultiplier(value: number);
  51271. private _videoMode;
  51272. /**
  51273. * Gets or set the current video mode for the video. It can be:
  51274. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  51275. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  51276. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  51277. */
  51278. get videoMode(): number;
  51279. set videoMode(value: number);
  51280. /**
  51281. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  51282. *
  51283. */
  51284. get halfDome(): boolean;
  51285. /**
  51286. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  51287. */
  51288. set halfDome(enabled: boolean);
  51289. /**
  51290. * Oberserver used in Stereoscopic VR Mode.
  51291. */
  51292. private _onBeforeCameraRenderObserver;
  51293. /**
  51294. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  51295. * @param name Element's name, child elements will append suffixes for their own names.
  51296. * @param urlsOrVideo defines the url(s) or the video element to use
  51297. * @param options An object containing optional or exposed sub element properties
  51298. */
  51299. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  51300. resolution?: number;
  51301. clickToPlay?: boolean;
  51302. autoPlay?: boolean;
  51303. loop?: boolean;
  51304. size?: number;
  51305. poster?: string;
  51306. faceForward?: boolean;
  51307. useDirectMapping?: boolean;
  51308. halfDomeMode?: boolean;
  51309. }, scene: Scene);
  51310. private _changeVideoMode;
  51311. /**
  51312. * Releases resources associated with this node.
  51313. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  51314. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  51315. */
  51316. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  51317. }
  51318. }
  51319. declare module BABYLON {
  51320. /**
  51321. * This class can be used to get instrumentation data from a Babylon engine
  51322. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  51323. */
  51324. export class EngineInstrumentation implements IDisposable {
  51325. /**
  51326. * Define the instrumented engine.
  51327. */
  51328. engine: Engine;
  51329. private _captureGPUFrameTime;
  51330. private _gpuFrameTimeToken;
  51331. private _gpuFrameTime;
  51332. private _captureShaderCompilationTime;
  51333. private _shaderCompilationTime;
  51334. private _onBeginFrameObserver;
  51335. private _onEndFrameObserver;
  51336. private _onBeforeShaderCompilationObserver;
  51337. private _onAfterShaderCompilationObserver;
  51338. /**
  51339. * Gets the perf counter used for GPU frame time
  51340. */
  51341. get gpuFrameTimeCounter(): PerfCounter;
  51342. /**
  51343. * Gets the GPU frame time capture status
  51344. */
  51345. get captureGPUFrameTime(): boolean;
  51346. /**
  51347. * Enable or disable the GPU frame time capture
  51348. */
  51349. set captureGPUFrameTime(value: boolean);
  51350. /**
  51351. * Gets the perf counter used for shader compilation time
  51352. */
  51353. get shaderCompilationTimeCounter(): PerfCounter;
  51354. /**
  51355. * Gets the shader compilation time capture status
  51356. */
  51357. get captureShaderCompilationTime(): boolean;
  51358. /**
  51359. * Enable or disable the shader compilation time capture
  51360. */
  51361. set captureShaderCompilationTime(value: boolean);
  51362. /**
  51363. * Instantiates a new engine instrumentation.
  51364. * This class can be used to get instrumentation data from a Babylon engine
  51365. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  51366. * @param engine Defines the engine to instrument
  51367. */
  51368. constructor(
  51369. /**
  51370. * Define the instrumented engine.
  51371. */
  51372. engine: Engine);
  51373. /**
  51374. * Dispose and release associated resources.
  51375. */
  51376. dispose(): void;
  51377. }
  51378. }
  51379. declare module BABYLON {
  51380. /**
  51381. * This class can be used to get instrumentation data from a Babylon engine
  51382. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  51383. */
  51384. export class SceneInstrumentation implements IDisposable {
  51385. /**
  51386. * Defines the scene to instrument
  51387. */
  51388. scene: Scene;
  51389. private _captureActiveMeshesEvaluationTime;
  51390. private _activeMeshesEvaluationTime;
  51391. private _captureRenderTargetsRenderTime;
  51392. private _renderTargetsRenderTime;
  51393. private _captureFrameTime;
  51394. private _frameTime;
  51395. private _captureRenderTime;
  51396. private _renderTime;
  51397. private _captureInterFrameTime;
  51398. private _interFrameTime;
  51399. private _captureParticlesRenderTime;
  51400. private _particlesRenderTime;
  51401. private _captureSpritesRenderTime;
  51402. private _spritesRenderTime;
  51403. private _capturePhysicsTime;
  51404. private _physicsTime;
  51405. private _captureAnimationsTime;
  51406. private _animationsTime;
  51407. private _captureCameraRenderTime;
  51408. private _cameraRenderTime;
  51409. private _onBeforeActiveMeshesEvaluationObserver;
  51410. private _onAfterActiveMeshesEvaluationObserver;
  51411. private _onBeforeRenderTargetsRenderObserver;
  51412. private _onAfterRenderTargetsRenderObserver;
  51413. private _onAfterRenderObserver;
  51414. private _onBeforeDrawPhaseObserver;
  51415. private _onAfterDrawPhaseObserver;
  51416. private _onBeforeAnimationsObserver;
  51417. private _onBeforeParticlesRenderingObserver;
  51418. private _onAfterParticlesRenderingObserver;
  51419. private _onBeforeSpritesRenderingObserver;
  51420. private _onAfterSpritesRenderingObserver;
  51421. private _onBeforePhysicsObserver;
  51422. private _onAfterPhysicsObserver;
  51423. private _onAfterAnimationsObserver;
  51424. private _onBeforeCameraRenderObserver;
  51425. private _onAfterCameraRenderObserver;
  51426. /**
  51427. * Gets the perf counter used for active meshes evaluation time
  51428. */
  51429. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  51430. /**
  51431. * Gets the active meshes evaluation time capture status
  51432. */
  51433. get captureActiveMeshesEvaluationTime(): boolean;
  51434. /**
  51435. * Enable or disable the active meshes evaluation time capture
  51436. */
  51437. set captureActiveMeshesEvaluationTime(value: boolean);
  51438. /**
  51439. * Gets the perf counter used for render targets render time
  51440. */
  51441. get renderTargetsRenderTimeCounter(): PerfCounter;
  51442. /**
  51443. * Gets the render targets render time capture status
  51444. */
  51445. get captureRenderTargetsRenderTime(): boolean;
  51446. /**
  51447. * Enable or disable the render targets render time capture
  51448. */
  51449. set captureRenderTargetsRenderTime(value: boolean);
  51450. /**
  51451. * Gets the perf counter used for particles render time
  51452. */
  51453. get particlesRenderTimeCounter(): PerfCounter;
  51454. /**
  51455. * Gets the particles render time capture status
  51456. */
  51457. get captureParticlesRenderTime(): boolean;
  51458. /**
  51459. * Enable or disable the particles render time capture
  51460. */
  51461. set captureParticlesRenderTime(value: boolean);
  51462. /**
  51463. * Gets the perf counter used for sprites render time
  51464. */
  51465. get spritesRenderTimeCounter(): PerfCounter;
  51466. /**
  51467. * Gets the sprites render time capture status
  51468. */
  51469. get captureSpritesRenderTime(): boolean;
  51470. /**
  51471. * Enable or disable the sprites render time capture
  51472. */
  51473. set captureSpritesRenderTime(value: boolean);
  51474. /**
  51475. * Gets the perf counter used for physics time
  51476. */
  51477. get physicsTimeCounter(): PerfCounter;
  51478. /**
  51479. * Gets the physics time capture status
  51480. */
  51481. get capturePhysicsTime(): boolean;
  51482. /**
  51483. * Enable or disable the physics time capture
  51484. */
  51485. set capturePhysicsTime(value: boolean);
  51486. /**
  51487. * Gets the perf counter used for animations time
  51488. */
  51489. get animationsTimeCounter(): PerfCounter;
  51490. /**
  51491. * Gets the animations time capture status
  51492. */
  51493. get captureAnimationsTime(): boolean;
  51494. /**
  51495. * Enable or disable the animations time capture
  51496. */
  51497. set captureAnimationsTime(value: boolean);
  51498. /**
  51499. * Gets the perf counter used for frame time capture
  51500. */
  51501. get frameTimeCounter(): PerfCounter;
  51502. /**
  51503. * Gets the frame time capture status
  51504. */
  51505. get captureFrameTime(): boolean;
  51506. /**
  51507. * Enable or disable the frame time capture
  51508. */
  51509. set captureFrameTime(value: boolean);
  51510. /**
  51511. * Gets the perf counter used for inter-frames time capture
  51512. */
  51513. get interFrameTimeCounter(): PerfCounter;
  51514. /**
  51515. * Gets the inter-frames time capture status
  51516. */
  51517. get captureInterFrameTime(): boolean;
  51518. /**
  51519. * Enable or disable the inter-frames time capture
  51520. */
  51521. set captureInterFrameTime(value: boolean);
  51522. /**
  51523. * Gets the perf counter used for render time capture
  51524. */
  51525. get renderTimeCounter(): PerfCounter;
  51526. /**
  51527. * Gets the render time capture status
  51528. */
  51529. get captureRenderTime(): boolean;
  51530. /**
  51531. * Enable or disable the render time capture
  51532. */
  51533. set captureRenderTime(value: boolean);
  51534. /**
  51535. * Gets the perf counter used for camera render time capture
  51536. */
  51537. get cameraRenderTimeCounter(): PerfCounter;
  51538. /**
  51539. * Gets the camera render time capture status
  51540. */
  51541. get captureCameraRenderTime(): boolean;
  51542. /**
  51543. * Enable or disable the camera render time capture
  51544. */
  51545. set captureCameraRenderTime(value: boolean);
  51546. /**
  51547. * Gets the perf counter used for draw calls
  51548. */
  51549. get drawCallsCounter(): PerfCounter;
  51550. /**
  51551. * Instantiates a new scene instrumentation.
  51552. * This class can be used to get instrumentation data from a Babylon engine
  51553. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  51554. * @param scene Defines the scene to instrument
  51555. */
  51556. constructor(
  51557. /**
  51558. * Defines the scene to instrument
  51559. */
  51560. scene: Scene);
  51561. /**
  51562. * Dispose and release associated resources.
  51563. */
  51564. dispose(): void;
  51565. }
  51566. }
  51567. declare module BABYLON {
  51568. /** @hidden */
  51569. export var glowMapGenerationPixelShader: {
  51570. name: string;
  51571. shader: string;
  51572. };
  51573. }
  51574. declare module BABYLON {
  51575. /** @hidden */
  51576. export var glowMapGenerationVertexShader: {
  51577. name: string;
  51578. shader: string;
  51579. };
  51580. }
  51581. declare module BABYLON {
  51582. /**
  51583. * Effect layer options. This helps customizing the behaviour
  51584. * of the effect layer.
  51585. */
  51586. export interface IEffectLayerOptions {
  51587. /**
  51588. * Multiplication factor apply to the canvas size to compute the render target size
  51589. * used to generated the objects (the smaller the faster).
  51590. */
  51591. mainTextureRatio: number;
  51592. /**
  51593. * Enforces a fixed size texture to ensure effect stability across devices.
  51594. */
  51595. mainTextureFixedSize?: number;
  51596. /**
  51597. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  51598. */
  51599. alphaBlendingMode: number;
  51600. /**
  51601. * The camera attached to the layer.
  51602. */
  51603. camera: Nullable<Camera>;
  51604. /**
  51605. * The rendering group to draw the layer in.
  51606. */
  51607. renderingGroupId: number;
  51608. }
  51609. /**
  51610. * The effect layer Helps adding post process effect blended with the main pass.
  51611. *
  51612. * This can be for instance use to generate glow or higlight effects on the scene.
  51613. *
  51614. * The effect layer class can not be used directly and is intented to inherited from to be
  51615. * customized per effects.
  51616. */
  51617. export abstract class EffectLayer {
  51618. private _vertexBuffers;
  51619. private _indexBuffer;
  51620. private _cachedDefines;
  51621. private _effectLayerMapGenerationEffect;
  51622. private _effectLayerOptions;
  51623. private _mergeEffect;
  51624. protected _scene: Scene;
  51625. protected _engine: Engine;
  51626. protected _maxSize: number;
  51627. protected _mainTextureDesiredSize: ISize;
  51628. protected _mainTexture: RenderTargetTexture;
  51629. protected _shouldRender: boolean;
  51630. protected _postProcesses: PostProcess[];
  51631. protected _textures: BaseTexture[];
  51632. protected _emissiveTextureAndColor: {
  51633. texture: Nullable<BaseTexture>;
  51634. color: Color4;
  51635. };
  51636. /**
  51637. * The name of the layer
  51638. */
  51639. name: string;
  51640. /**
  51641. * The clear color of the texture used to generate the glow map.
  51642. */
  51643. neutralColor: Color4;
  51644. /**
  51645. * Specifies wether the highlight layer is enabled or not.
  51646. */
  51647. isEnabled: boolean;
  51648. /**
  51649. * Gets the camera attached to the layer.
  51650. */
  51651. get camera(): Nullable<Camera>;
  51652. /**
  51653. * Gets the rendering group id the layer should render in.
  51654. */
  51655. get renderingGroupId(): number;
  51656. set renderingGroupId(renderingGroupId: number);
  51657. /**
  51658. * An event triggered when the effect layer has been disposed.
  51659. */
  51660. onDisposeObservable: Observable<EffectLayer>;
  51661. /**
  51662. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  51663. */
  51664. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  51665. /**
  51666. * An event triggered when the generated texture is being merged in the scene.
  51667. */
  51668. onBeforeComposeObservable: Observable<EffectLayer>;
  51669. /**
  51670. * An event triggered when the mesh is rendered into the effect render target.
  51671. */
  51672. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  51673. /**
  51674. * An event triggered after the mesh has been rendered into the effect render target.
  51675. */
  51676. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  51677. /**
  51678. * An event triggered when the generated texture has been merged in the scene.
  51679. */
  51680. onAfterComposeObservable: Observable<EffectLayer>;
  51681. /**
  51682. * An event triggered when the efffect layer changes its size.
  51683. */
  51684. onSizeChangedObservable: Observable<EffectLayer>;
  51685. /** @hidden */
  51686. static _SceneComponentInitialization: (scene: Scene) => void;
  51687. /**
  51688. * Instantiates a new effect Layer and references it in the scene.
  51689. * @param name The name of the layer
  51690. * @param scene The scene to use the layer in
  51691. */
  51692. constructor(
  51693. /** The Friendly of the effect in the scene */
  51694. name: string, scene: Scene);
  51695. /**
  51696. * Get the effect name of the layer.
  51697. * @return The effect name
  51698. */
  51699. abstract getEffectName(): string;
  51700. /**
  51701. * Checks for the readiness of the element composing the layer.
  51702. * @param subMesh the mesh to check for
  51703. * @param useInstances specify wether or not to use instances to render the mesh
  51704. * @return true if ready otherwise, false
  51705. */
  51706. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51707. /**
  51708. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  51709. * @returns true if the effect requires stencil during the main canvas render pass.
  51710. */
  51711. abstract needStencil(): boolean;
  51712. /**
  51713. * Create the merge effect. This is the shader use to blit the information back
  51714. * to the main canvas at the end of the scene rendering.
  51715. * @returns The effect containing the shader used to merge the effect on the main canvas
  51716. */
  51717. protected abstract _createMergeEffect(): Effect;
  51718. /**
  51719. * Creates the render target textures and post processes used in the effect layer.
  51720. */
  51721. protected abstract _createTextureAndPostProcesses(): void;
  51722. /**
  51723. * Implementation specific of rendering the generating effect on the main canvas.
  51724. * @param effect The effect used to render through
  51725. */
  51726. protected abstract _internalRender(effect: Effect): void;
  51727. /**
  51728. * Sets the required values for both the emissive texture and and the main color.
  51729. */
  51730. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  51731. /**
  51732. * Free any resources and references associated to a mesh.
  51733. * Internal use
  51734. * @param mesh The mesh to free.
  51735. */
  51736. abstract _disposeMesh(mesh: Mesh): void;
  51737. /**
  51738. * Serializes this layer (Glow or Highlight for example)
  51739. * @returns a serialized layer object
  51740. */
  51741. abstract serialize?(): any;
  51742. /**
  51743. * Initializes the effect layer with the required options.
  51744. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  51745. */
  51746. protected _init(options: Partial<IEffectLayerOptions>): void;
  51747. /**
  51748. * Generates the index buffer of the full screen quad blending to the main canvas.
  51749. */
  51750. private _generateIndexBuffer;
  51751. /**
  51752. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  51753. */
  51754. private _generateVertexBuffer;
  51755. /**
  51756. * Sets the main texture desired size which is the closest power of two
  51757. * of the engine canvas size.
  51758. */
  51759. private _setMainTextureSize;
  51760. /**
  51761. * Creates the main texture for the effect layer.
  51762. */
  51763. protected _createMainTexture(): void;
  51764. /**
  51765. * Adds specific effects defines.
  51766. * @param defines The defines to add specifics to.
  51767. */
  51768. protected _addCustomEffectDefines(defines: string[]): void;
  51769. /**
  51770. * Checks for the readiness of the element composing the layer.
  51771. * @param subMesh the mesh to check for
  51772. * @param useInstances specify wether or not to use instances to render the mesh
  51773. * @param emissiveTexture the associated emissive texture used to generate the glow
  51774. * @return true if ready otherwise, false
  51775. */
  51776. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  51777. /**
  51778. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  51779. */
  51780. render(): void;
  51781. /**
  51782. * Determine if a given mesh will be used in the current effect.
  51783. * @param mesh mesh to test
  51784. * @returns true if the mesh will be used
  51785. */
  51786. hasMesh(mesh: AbstractMesh): boolean;
  51787. /**
  51788. * Returns true if the layer contains information to display, otherwise false.
  51789. * @returns true if the glow layer should be rendered
  51790. */
  51791. shouldRender(): boolean;
  51792. /**
  51793. * Returns true if the mesh should render, otherwise false.
  51794. * @param mesh The mesh to render
  51795. * @returns true if it should render otherwise false
  51796. */
  51797. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  51798. /**
  51799. * Returns true if the mesh can be rendered, otherwise false.
  51800. * @param mesh The mesh to render
  51801. * @param material The material used on the mesh
  51802. * @returns true if it can be rendered otherwise false
  51803. */
  51804. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  51805. /**
  51806. * Returns true if the mesh should render, otherwise false.
  51807. * @param mesh The mesh to render
  51808. * @returns true if it should render otherwise false
  51809. */
  51810. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  51811. /**
  51812. * Renders the submesh passed in parameter to the generation map.
  51813. */
  51814. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  51815. /**
  51816. * Defines wether the current material of the mesh should be use to render the effect.
  51817. * @param mesh defines the current mesh to render
  51818. */
  51819. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  51820. /**
  51821. * Rebuild the required buffers.
  51822. * @hidden Internal use only.
  51823. */
  51824. _rebuild(): void;
  51825. /**
  51826. * Dispose only the render target textures and post process.
  51827. */
  51828. private _disposeTextureAndPostProcesses;
  51829. /**
  51830. * Dispose the highlight layer and free resources.
  51831. */
  51832. dispose(): void;
  51833. /**
  51834. * Gets the class name of the effect layer
  51835. * @returns the string with the class name of the effect layer
  51836. */
  51837. getClassName(): string;
  51838. /**
  51839. * Creates an effect layer from parsed effect layer data
  51840. * @param parsedEffectLayer defines effect layer data
  51841. * @param scene defines the current scene
  51842. * @param rootUrl defines the root URL containing the effect layer information
  51843. * @returns a parsed effect Layer
  51844. */
  51845. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  51846. }
  51847. }
  51848. declare module BABYLON {
  51849. interface AbstractScene {
  51850. /**
  51851. * The list of effect layers (highlights/glow) added to the scene
  51852. * @see http://doc.babylonjs.com/how_to/highlight_layer
  51853. * @see http://doc.babylonjs.com/how_to/glow_layer
  51854. */
  51855. effectLayers: Array<EffectLayer>;
  51856. /**
  51857. * Removes the given effect layer from this scene.
  51858. * @param toRemove defines the effect layer to remove
  51859. * @returns the index of the removed effect layer
  51860. */
  51861. removeEffectLayer(toRemove: EffectLayer): number;
  51862. /**
  51863. * Adds the given effect layer to this scene
  51864. * @param newEffectLayer defines the effect layer to add
  51865. */
  51866. addEffectLayer(newEffectLayer: EffectLayer): void;
  51867. }
  51868. /**
  51869. * Defines the layer scene component responsible to manage any effect layers
  51870. * in a given scene.
  51871. */
  51872. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  51873. /**
  51874. * The component name helpfull to identify the component in the list of scene components.
  51875. */
  51876. readonly name: string;
  51877. /**
  51878. * The scene the component belongs to.
  51879. */
  51880. scene: Scene;
  51881. private _engine;
  51882. private _renderEffects;
  51883. private _needStencil;
  51884. private _previousStencilState;
  51885. /**
  51886. * Creates a new instance of the component for the given scene
  51887. * @param scene Defines the scene to register the component in
  51888. */
  51889. constructor(scene: Scene);
  51890. /**
  51891. * Registers the component in a given scene
  51892. */
  51893. register(): void;
  51894. /**
  51895. * Rebuilds the elements related to this component in case of
  51896. * context lost for instance.
  51897. */
  51898. rebuild(): void;
  51899. /**
  51900. * Serializes the component data to the specified json object
  51901. * @param serializationObject The object to serialize to
  51902. */
  51903. serialize(serializationObject: any): void;
  51904. /**
  51905. * Adds all the elements from the container to the scene
  51906. * @param container the container holding the elements
  51907. */
  51908. addFromContainer(container: AbstractScene): void;
  51909. /**
  51910. * Removes all the elements in the container from the scene
  51911. * @param container contains the elements to remove
  51912. * @param dispose if the removed element should be disposed (default: false)
  51913. */
  51914. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51915. /**
  51916. * Disposes the component and the associated ressources.
  51917. */
  51918. dispose(): void;
  51919. private _isReadyForMesh;
  51920. private _renderMainTexture;
  51921. private _setStencil;
  51922. private _setStencilBack;
  51923. private _draw;
  51924. private _drawCamera;
  51925. private _drawRenderingGroup;
  51926. }
  51927. }
  51928. declare module BABYLON {
  51929. /** @hidden */
  51930. export var glowMapMergePixelShader: {
  51931. name: string;
  51932. shader: string;
  51933. };
  51934. }
  51935. declare module BABYLON {
  51936. /** @hidden */
  51937. export var glowMapMergeVertexShader: {
  51938. name: string;
  51939. shader: string;
  51940. };
  51941. }
  51942. declare module BABYLON {
  51943. interface AbstractScene {
  51944. /**
  51945. * Return a the first highlight layer of the scene with a given name.
  51946. * @param name The name of the highlight layer to look for.
  51947. * @return The highlight layer if found otherwise null.
  51948. */
  51949. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  51950. }
  51951. /**
  51952. * Glow layer options. This helps customizing the behaviour
  51953. * of the glow layer.
  51954. */
  51955. export interface IGlowLayerOptions {
  51956. /**
  51957. * Multiplication factor apply to the canvas size to compute the render target size
  51958. * used to generated the glowing objects (the smaller the faster).
  51959. */
  51960. mainTextureRatio: number;
  51961. /**
  51962. * Enforces a fixed size texture to ensure resize independant blur.
  51963. */
  51964. mainTextureFixedSize?: number;
  51965. /**
  51966. * How big is the kernel of the blur texture.
  51967. */
  51968. blurKernelSize: number;
  51969. /**
  51970. * The camera attached to the layer.
  51971. */
  51972. camera: Nullable<Camera>;
  51973. /**
  51974. * Enable MSAA by chosing the number of samples.
  51975. */
  51976. mainTextureSamples?: number;
  51977. /**
  51978. * The rendering group to draw the layer in.
  51979. */
  51980. renderingGroupId: number;
  51981. }
  51982. /**
  51983. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  51984. *
  51985. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  51986. *
  51987. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  51988. */
  51989. export class GlowLayer extends EffectLayer {
  51990. /**
  51991. * Effect Name of the layer.
  51992. */
  51993. static readonly EffectName: string;
  51994. /**
  51995. * The default blur kernel size used for the glow.
  51996. */
  51997. static DefaultBlurKernelSize: number;
  51998. /**
  51999. * The default texture size ratio used for the glow.
  52000. */
  52001. static DefaultTextureRatio: number;
  52002. /**
  52003. * Sets the kernel size of the blur.
  52004. */
  52005. set blurKernelSize(value: number);
  52006. /**
  52007. * Gets the kernel size of the blur.
  52008. */
  52009. get blurKernelSize(): number;
  52010. /**
  52011. * Sets the glow intensity.
  52012. */
  52013. set intensity(value: number);
  52014. /**
  52015. * Gets the glow intensity.
  52016. */
  52017. get intensity(): number;
  52018. private _options;
  52019. private _intensity;
  52020. private _horizontalBlurPostprocess1;
  52021. private _verticalBlurPostprocess1;
  52022. private _horizontalBlurPostprocess2;
  52023. private _verticalBlurPostprocess2;
  52024. private _blurTexture1;
  52025. private _blurTexture2;
  52026. private _postProcesses1;
  52027. private _postProcesses2;
  52028. private _includedOnlyMeshes;
  52029. private _excludedMeshes;
  52030. private _meshesUsingTheirOwnMaterials;
  52031. /**
  52032. * Callback used to let the user override the color selection on a per mesh basis
  52033. */
  52034. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  52035. /**
  52036. * Callback used to let the user override the texture selection on a per mesh basis
  52037. */
  52038. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  52039. /**
  52040. * Instantiates a new glow Layer and references it to the scene.
  52041. * @param name The name of the layer
  52042. * @param scene The scene to use the layer in
  52043. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  52044. */
  52045. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  52046. /**
  52047. * Get the effect name of the layer.
  52048. * @return The effect name
  52049. */
  52050. getEffectName(): string;
  52051. /**
  52052. * Create the merge effect. This is the shader use to blit the information back
  52053. * to the main canvas at the end of the scene rendering.
  52054. */
  52055. protected _createMergeEffect(): Effect;
  52056. /**
  52057. * Creates the render target textures and post processes used in the glow layer.
  52058. */
  52059. protected _createTextureAndPostProcesses(): void;
  52060. /**
  52061. * Checks for the readiness of the element composing the layer.
  52062. * @param subMesh the mesh to check for
  52063. * @param useInstances specify wether or not to use instances to render the mesh
  52064. * @param emissiveTexture the associated emissive texture used to generate the glow
  52065. * @return true if ready otherwise, false
  52066. */
  52067. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52068. /**
  52069. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  52070. */
  52071. needStencil(): boolean;
  52072. /**
  52073. * Returns true if the mesh can be rendered, otherwise false.
  52074. * @param mesh The mesh to render
  52075. * @param material The material used on the mesh
  52076. * @returns true if it can be rendered otherwise false
  52077. */
  52078. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  52079. /**
  52080. * Implementation specific of rendering the generating effect on the main canvas.
  52081. * @param effect The effect used to render through
  52082. */
  52083. protected _internalRender(effect: Effect): void;
  52084. /**
  52085. * Sets the required values for both the emissive texture and and the main color.
  52086. */
  52087. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  52088. /**
  52089. * Returns true if the mesh should render, otherwise false.
  52090. * @param mesh The mesh to render
  52091. * @returns true if it should render otherwise false
  52092. */
  52093. protected _shouldRenderMesh(mesh: Mesh): boolean;
  52094. /**
  52095. * Adds specific effects defines.
  52096. * @param defines The defines to add specifics to.
  52097. */
  52098. protected _addCustomEffectDefines(defines: string[]): void;
  52099. /**
  52100. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  52101. * @param mesh The mesh to exclude from the glow layer
  52102. */
  52103. addExcludedMesh(mesh: Mesh): void;
  52104. /**
  52105. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  52106. * @param mesh The mesh to remove
  52107. */
  52108. removeExcludedMesh(mesh: Mesh): void;
  52109. /**
  52110. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  52111. * @param mesh The mesh to include in the glow layer
  52112. */
  52113. addIncludedOnlyMesh(mesh: Mesh): void;
  52114. /**
  52115. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  52116. * @param mesh The mesh to remove
  52117. */
  52118. removeIncludedOnlyMesh(mesh: Mesh): void;
  52119. /**
  52120. * Determine if a given mesh will be used in the glow layer
  52121. * @param mesh The mesh to test
  52122. * @returns true if the mesh will be highlighted by the current glow layer
  52123. */
  52124. hasMesh(mesh: AbstractMesh): boolean;
  52125. /**
  52126. * Defines wether the current material of the mesh should be use to render the effect.
  52127. * @param mesh defines the current mesh to render
  52128. */
  52129. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  52130. /**
  52131. * Add a mesh to be rendered through its own material and not with emissive only.
  52132. * @param mesh The mesh for which we need to use its material
  52133. */
  52134. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  52135. /**
  52136. * Remove a mesh from being rendered through its own material and not with emissive only.
  52137. * @param mesh The mesh for which we need to not use its material
  52138. */
  52139. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  52140. /**
  52141. * Free any resources and references associated to a mesh.
  52142. * Internal use
  52143. * @param mesh The mesh to free.
  52144. * @hidden
  52145. */
  52146. _disposeMesh(mesh: Mesh): void;
  52147. /**
  52148. * Gets the class name of the effect layer
  52149. * @returns the string with the class name of the effect layer
  52150. */
  52151. getClassName(): string;
  52152. /**
  52153. * Serializes this glow layer
  52154. * @returns a serialized glow layer object
  52155. */
  52156. serialize(): any;
  52157. /**
  52158. * Creates a Glow Layer from parsed glow layer data
  52159. * @param parsedGlowLayer defines glow layer data
  52160. * @param scene defines the current scene
  52161. * @param rootUrl defines the root URL containing the glow layer information
  52162. * @returns a parsed Glow Layer
  52163. */
  52164. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  52165. }
  52166. }
  52167. declare module BABYLON {
  52168. /** @hidden */
  52169. export var glowBlurPostProcessPixelShader: {
  52170. name: string;
  52171. shader: string;
  52172. };
  52173. }
  52174. declare module BABYLON {
  52175. interface AbstractScene {
  52176. /**
  52177. * Return a the first highlight layer of the scene with a given name.
  52178. * @param name The name of the highlight layer to look for.
  52179. * @return The highlight layer if found otherwise null.
  52180. */
  52181. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  52182. }
  52183. /**
  52184. * Highlight layer options. This helps customizing the behaviour
  52185. * of the highlight layer.
  52186. */
  52187. export interface IHighlightLayerOptions {
  52188. /**
  52189. * Multiplication factor apply to the canvas size to compute the render target size
  52190. * used to generated the glowing objects (the smaller the faster).
  52191. */
  52192. mainTextureRatio: number;
  52193. /**
  52194. * Enforces a fixed size texture to ensure resize independant blur.
  52195. */
  52196. mainTextureFixedSize?: number;
  52197. /**
  52198. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  52199. * of the picture to blur (the smaller the faster).
  52200. */
  52201. blurTextureSizeRatio: number;
  52202. /**
  52203. * How big in texel of the blur texture is the vertical blur.
  52204. */
  52205. blurVerticalSize: number;
  52206. /**
  52207. * How big in texel of the blur texture is the horizontal blur.
  52208. */
  52209. blurHorizontalSize: number;
  52210. /**
  52211. * Alpha blending mode used to apply the blur. Default is combine.
  52212. */
  52213. alphaBlendingMode: number;
  52214. /**
  52215. * The camera attached to the layer.
  52216. */
  52217. camera: Nullable<Camera>;
  52218. /**
  52219. * Should we display highlight as a solid stroke?
  52220. */
  52221. isStroke?: boolean;
  52222. /**
  52223. * The rendering group to draw the layer in.
  52224. */
  52225. renderingGroupId: number;
  52226. }
  52227. /**
  52228. * The highlight layer Helps adding a glow effect around a mesh.
  52229. *
  52230. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  52231. * glowy meshes to your scene.
  52232. *
  52233. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  52234. */
  52235. export class HighlightLayer extends EffectLayer {
  52236. name: string;
  52237. /**
  52238. * Effect Name of the highlight layer.
  52239. */
  52240. static readonly EffectName: string;
  52241. /**
  52242. * The neutral color used during the preparation of the glow effect.
  52243. * This is black by default as the blend operation is a blend operation.
  52244. */
  52245. static NeutralColor: Color4;
  52246. /**
  52247. * Stencil value used for glowing meshes.
  52248. */
  52249. static GlowingMeshStencilReference: number;
  52250. /**
  52251. * Stencil value used for the other meshes in the scene.
  52252. */
  52253. static NormalMeshStencilReference: number;
  52254. /**
  52255. * Specifies whether or not the inner glow is ACTIVE in the layer.
  52256. */
  52257. innerGlow: boolean;
  52258. /**
  52259. * Specifies whether or not the outer glow is ACTIVE in the layer.
  52260. */
  52261. outerGlow: boolean;
  52262. /**
  52263. * Specifies the horizontal size of the blur.
  52264. */
  52265. set blurHorizontalSize(value: number);
  52266. /**
  52267. * Specifies the vertical size of the blur.
  52268. */
  52269. set blurVerticalSize(value: number);
  52270. /**
  52271. * Gets the horizontal size of the blur.
  52272. */
  52273. get blurHorizontalSize(): number;
  52274. /**
  52275. * Gets the vertical size of the blur.
  52276. */
  52277. get blurVerticalSize(): number;
  52278. /**
  52279. * An event triggered when the highlight layer is being blurred.
  52280. */
  52281. onBeforeBlurObservable: Observable<HighlightLayer>;
  52282. /**
  52283. * An event triggered when the highlight layer has been blurred.
  52284. */
  52285. onAfterBlurObservable: Observable<HighlightLayer>;
  52286. private _instanceGlowingMeshStencilReference;
  52287. private _options;
  52288. private _downSamplePostprocess;
  52289. private _horizontalBlurPostprocess;
  52290. private _verticalBlurPostprocess;
  52291. private _blurTexture;
  52292. private _meshes;
  52293. private _excludedMeshes;
  52294. /**
  52295. * Instantiates a new highlight Layer and references it to the scene..
  52296. * @param name The name of the layer
  52297. * @param scene The scene to use the layer in
  52298. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  52299. */
  52300. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  52301. /**
  52302. * Get the effect name of the layer.
  52303. * @return The effect name
  52304. */
  52305. getEffectName(): string;
  52306. /**
  52307. * Create the merge effect. This is the shader use to blit the information back
  52308. * to the main canvas at the end of the scene rendering.
  52309. */
  52310. protected _createMergeEffect(): Effect;
  52311. /**
  52312. * Creates the render target textures and post processes used in the highlight layer.
  52313. */
  52314. protected _createTextureAndPostProcesses(): void;
  52315. /**
  52316. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  52317. */
  52318. needStencil(): boolean;
  52319. /**
  52320. * Checks for the readiness of the element composing the layer.
  52321. * @param subMesh the mesh to check for
  52322. * @param useInstances specify wether or not to use instances to render the mesh
  52323. * @param emissiveTexture the associated emissive texture used to generate the glow
  52324. * @return true if ready otherwise, false
  52325. */
  52326. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52327. /**
  52328. * Implementation specific of rendering the generating effect on the main canvas.
  52329. * @param effect The effect used to render through
  52330. */
  52331. protected _internalRender(effect: Effect): void;
  52332. /**
  52333. * Returns true if the layer contains information to display, otherwise false.
  52334. */
  52335. shouldRender(): boolean;
  52336. /**
  52337. * Returns true if the mesh should render, otherwise false.
  52338. * @param mesh The mesh to render
  52339. * @returns true if it should render otherwise false
  52340. */
  52341. protected _shouldRenderMesh(mesh: Mesh): boolean;
  52342. /**
  52343. * Sets the required values for both the emissive texture and and the main color.
  52344. */
  52345. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  52346. /**
  52347. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  52348. * @param mesh The mesh to exclude from the highlight layer
  52349. */
  52350. addExcludedMesh(mesh: Mesh): void;
  52351. /**
  52352. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  52353. * @param mesh The mesh to highlight
  52354. */
  52355. removeExcludedMesh(mesh: Mesh): void;
  52356. /**
  52357. * Determine if a given mesh will be highlighted by the current HighlightLayer
  52358. * @param mesh mesh to test
  52359. * @returns true if the mesh will be highlighted by the current HighlightLayer
  52360. */
  52361. hasMesh(mesh: AbstractMesh): boolean;
  52362. /**
  52363. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  52364. * @param mesh The mesh to highlight
  52365. * @param color The color of the highlight
  52366. * @param glowEmissiveOnly Extract the glow from the emissive texture
  52367. */
  52368. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  52369. /**
  52370. * Remove a mesh from the highlight layer in order to make it stop glowing.
  52371. * @param mesh The mesh to highlight
  52372. */
  52373. removeMesh(mesh: Mesh): void;
  52374. /**
  52375. * Force the stencil to the normal expected value for none glowing parts
  52376. */
  52377. private _defaultStencilReference;
  52378. /**
  52379. * Free any resources and references associated to a mesh.
  52380. * Internal use
  52381. * @param mesh The mesh to free.
  52382. * @hidden
  52383. */
  52384. _disposeMesh(mesh: Mesh): void;
  52385. /**
  52386. * Dispose the highlight layer and free resources.
  52387. */
  52388. dispose(): void;
  52389. /**
  52390. * Gets the class name of the effect layer
  52391. * @returns the string with the class name of the effect layer
  52392. */
  52393. getClassName(): string;
  52394. /**
  52395. * Serializes this Highlight layer
  52396. * @returns a serialized Highlight layer object
  52397. */
  52398. serialize(): any;
  52399. /**
  52400. * Creates a Highlight layer from parsed Highlight layer data
  52401. * @param parsedHightlightLayer defines the Highlight layer data
  52402. * @param scene defines the current scene
  52403. * @param rootUrl defines the root URL containing the Highlight layer information
  52404. * @returns a parsed Highlight layer
  52405. */
  52406. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  52407. }
  52408. }
  52409. declare module BABYLON {
  52410. interface AbstractScene {
  52411. /**
  52412. * The list of layers (background and foreground) of the scene
  52413. */
  52414. layers: Array<Layer>;
  52415. }
  52416. /**
  52417. * Defines the layer scene component responsible to manage any layers
  52418. * in a given scene.
  52419. */
  52420. export class LayerSceneComponent implements ISceneComponent {
  52421. /**
  52422. * The component name helpfull to identify the component in the list of scene components.
  52423. */
  52424. readonly name: string;
  52425. /**
  52426. * The scene the component belongs to.
  52427. */
  52428. scene: Scene;
  52429. private _engine;
  52430. /**
  52431. * Creates a new instance of the component for the given scene
  52432. * @param scene Defines the scene to register the component in
  52433. */
  52434. constructor(scene: Scene);
  52435. /**
  52436. * Registers the component in a given scene
  52437. */
  52438. register(): void;
  52439. /**
  52440. * Rebuilds the elements related to this component in case of
  52441. * context lost for instance.
  52442. */
  52443. rebuild(): void;
  52444. /**
  52445. * Disposes the component and the associated ressources.
  52446. */
  52447. dispose(): void;
  52448. private _draw;
  52449. private _drawCameraPredicate;
  52450. private _drawCameraBackground;
  52451. private _drawCameraForeground;
  52452. private _drawRenderTargetPredicate;
  52453. private _drawRenderTargetBackground;
  52454. private _drawRenderTargetForeground;
  52455. /**
  52456. * Adds all the elements from the container to the scene
  52457. * @param container the container holding the elements
  52458. */
  52459. addFromContainer(container: AbstractScene): void;
  52460. /**
  52461. * Removes all the elements in the container from the scene
  52462. * @param container contains the elements to remove
  52463. * @param dispose if the removed element should be disposed (default: false)
  52464. */
  52465. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52466. }
  52467. }
  52468. declare module BABYLON {
  52469. /** @hidden */
  52470. export var layerPixelShader: {
  52471. name: string;
  52472. shader: string;
  52473. };
  52474. }
  52475. declare module BABYLON {
  52476. /** @hidden */
  52477. export var layerVertexShader: {
  52478. name: string;
  52479. shader: string;
  52480. };
  52481. }
  52482. declare module BABYLON {
  52483. /**
  52484. * This represents a full screen 2d layer.
  52485. * This can be useful to display a picture in the background of your scene for instance.
  52486. * @see https://www.babylonjs-playground.com/#08A2BS#1
  52487. */
  52488. export class Layer {
  52489. /**
  52490. * Define the name of the layer.
  52491. */
  52492. name: string;
  52493. /**
  52494. * Define the texture the layer should display.
  52495. */
  52496. texture: Nullable<Texture>;
  52497. /**
  52498. * Is the layer in background or foreground.
  52499. */
  52500. isBackground: boolean;
  52501. /**
  52502. * Define the color of the layer (instead of texture).
  52503. */
  52504. color: Color4;
  52505. /**
  52506. * Define the scale of the layer in order to zoom in out of the texture.
  52507. */
  52508. scale: Vector2;
  52509. /**
  52510. * Define an offset for the layer in order to shift the texture.
  52511. */
  52512. offset: Vector2;
  52513. /**
  52514. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  52515. */
  52516. alphaBlendingMode: number;
  52517. /**
  52518. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  52519. * Alpha test will not mix with the background color in case of transparency.
  52520. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  52521. */
  52522. alphaTest: boolean;
  52523. /**
  52524. * Define a mask to restrict the layer to only some of the scene cameras.
  52525. */
  52526. layerMask: number;
  52527. /**
  52528. * Define the list of render target the layer is visible into.
  52529. */
  52530. renderTargetTextures: RenderTargetTexture[];
  52531. /**
  52532. * Define if the layer is only used in renderTarget or if it also
  52533. * renders in the main frame buffer of the canvas.
  52534. */
  52535. renderOnlyInRenderTargetTextures: boolean;
  52536. private _scene;
  52537. private _vertexBuffers;
  52538. private _indexBuffer;
  52539. private _effect;
  52540. private _previousDefines;
  52541. /**
  52542. * An event triggered when the layer is disposed.
  52543. */
  52544. onDisposeObservable: Observable<Layer>;
  52545. private _onDisposeObserver;
  52546. /**
  52547. * Back compatibility with callback before the onDisposeObservable existed.
  52548. * The set callback will be triggered when the layer has been disposed.
  52549. */
  52550. set onDispose(callback: () => void);
  52551. /**
  52552. * An event triggered before rendering the scene
  52553. */
  52554. onBeforeRenderObservable: Observable<Layer>;
  52555. private _onBeforeRenderObserver;
  52556. /**
  52557. * Back compatibility with callback before the onBeforeRenderObservable existed.
  52558. * The set callback will be triggered just before rendering the layer.
  52559. */
  52560. set onBeforeRender(callback: () => void);
  52561. /**
  52562. * An event triggered after rendering the scene
  52563. */
  52564. onAfterRenderObservable: Observable<Layer>;
  52565. private _onAfterRenderObserver;
  52566. /**
  52567. * Back compatibility with callback before the onAfterRenderObservable existed.
  52568. * The set callback will be triggered just after rendering the layer.
  52569. */
  52570. set onAfterRender(callback: () => void);
  52571. /**
  52572. * Instantiates a new layer.
  52573. * This represents a full screen 2d layer.
  52574. * This can be useful to display a picture in the background of your scene for instance.
  52575. * @see https://www.babylonjs-playground.com/#08A2BS#1
  52576. * @param name Define the name of the layer in the scene
  52577. * @param imgUrl Define the url of the texture to display in the layer
  52578. * @param scene Define the scene the layer belongs to
  52579. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  52580. * @param color Defines a color for the layer
  52581. */
  52582. constructor(
  52583. /**
  52584. * Define the name of the layer.
  52585. */
  52586. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  52587. private _createIndexBuffer;
  52588. /** @hidden */
  52589. _rebuild(): void;
  52590. /**
  52591. * Renders the layer in the scene.
  52592. */
  52593. render(): void;
  52594. /**
  52595. * Disposes and releases the associated ressources.
  52596. */
  52597. dispose(): void;
  52598. }
  52599. }
  52600. declare module BABYLON {
  52601. /** @hidden */
  52602. export var lensFlarePixelShader: {
  52603. name: string;
  52604. shader: string;
  52605. };
  52606. }
  52607. declare module BABYLON {
  52608. /** @hidden */
  52609. export var lensFlareVertexShader: {
  52610. name: string;
  52611. shader: string;
  52612. };
  52613. }
  52614. declare module BABYLON {
  52615. /**
  52616. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  52617. * It is usually composed of several `lensFlare`.
  52618. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52619. */
  52620. export class LensFlareSystem {
  52621. /**
  52622. * Define the name of the lens flare system
  52623. */
  52624. name: string;
  52625. /**
  52626. * List of lens flares used in this system.
  52627. */
  52628. lensFlares: LensFlare[];
  52629. /**
  52630. * Define a limit from the border the lens flare can be visible.
  52631. */
  52632. borderLimit: number;
  52633. /**
  52634. * Define a viewport border we do not want to see the lens flare in.
  52635. */
  52636. viewportBorder: number;
  52637. /**
  52638. * Define a predicate which could limit the list of meshes able to occlude the effect.
  52639. */
  52640. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  52641. /**
  52642. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  52643. */
  52644. layerMask: number;
  52645. /**
  52646. * Define the id of the lens flare system in the scene.
  52647. * (equal to name by default)
  52648. */
  52649. id: string;
  52650. private _scene;
  52651. private _emitter;
  52652. private _vertexBuffers;
  52653. private _indexBuffer;
  52654. private _effect;
  52655. private _positionX;
  52656. private _positionY;
  52657. private _isEnabled;
  52658. /** @hidden */
  52659. static _SceneComponentInitialization: (scene: Scene) => void;
  52660. /**
  52661. * Instantiates a lens flare system.
  52662. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  52663. * It is usually composed of several `lensFlare`.
  52664. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52665. * @param name Define the name of the lens flare system in the scene
  52666. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  52667. * @param scene Define the scene the lens flare system belongs to
  52668. */
  52669. constructor(
  52670. /**
  52671. * Define the name of the lens flare system
  52672. */
  52673. name: string, emitter: any, scene: Scene);
  52674. /**
  52675. * Define if the lens flare system is enabled.
  52676. */
  52677. get isEnabled(): boolean;
  52678. set isEnabled(value: boolean);
  52679. /**
  52680. * Get the scene the effects belongs to.
  52681. * @returns the scene holding the lens flare system
  52682. */
  52683. getScene(): Scene;
  52684. /**
  52685. * Get the emitter of the lens flare system.
  52686. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  52687. * @returns the emitter of the lens flare system
  52688. */
  52689. getEmitter(): any;
  52690. /**
  52691. * Set the emitter of the lens flare system.
  52692. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  52693. * @param newEmitter Define the new emitter of the system
  52694. */
  52695. setEmitter(newEmitter: any): void;
  52696. /**
  52697. * Get the lens flare system emitter position.
  52698. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  52699. * @returns the position
  52700. */
  52701. getEmitterPosition(): Vector3;
  52702. /**
  52703. * @hidden
  52704. */
  52705. computeEffectivePosition(globalViewport: Viewport): boolean;
  52706. /** @hidden */
  52707. _isVisible(): boolean;
  52708. /**
  52709. * @hidden
  52710. */
  52711. render(): boolean;
  52712. /**
  52713. * Dispose and release the lens flare with its associated resources.
  52714. */
  52715. dispose(): void;
  52716. /**
  52717. * Parse a lens flare system from a JSON repressentation
  52718. * @param parsedLensFlareSystem Define the JSON to parse
  52719. * @param scene Define the scene the parsed system should be instantiated in
  52720. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  52721. * @returns the parsed system
  52722. */
  52723. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  52724. /**
  52725. * Serialize the current Lens Flare System into a JSON representation.
  52726. * @returns the serialized JSON
  52727. */
  52728. serialize(): any;
  52729. }
  52730. }
  52731. declare module BABYLON {
  52732. /**
  52733. * This represents one of the lens effect in a `lensFlareSystem`.
  52734. * It controls one of the indiviual texture used in the effect.
  52735. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52736. */
  52737. export class LensFlare {
  52738. /**
  52739. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  52740. */
  52741. size: number;
  52742. /**
  52743. * 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.
  52744. */
  52745. position: number;
  52746. /**
  52747. * Define the lens color.
  52748. */
  52749. color: Color3;
  52750. /**
  52751. * Define the lens texture.
  52752. */
  52753. texture: Nullable<Texture>;
  52754. /**
  52755. * Define the alpha mode to render this particular lens.
  52756. */
  52757. alphaMode: number;
  52758. private _system;
  52759. /**
  52760. * Creates a new Lens Flare.
  52761. * This represents one of the lens effect in a `lensFlareSystem`.
  52762. * It controls one of the indiviual texture used in the effect.
  52763. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52764. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  52765. * @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.
  52766. * @param color Define the lens color
  52767. * @param imgUrl Define the lens texture url
  52768. * @param system Define the `lensFlareSystem` this flare is part of
  52769. * @returns The newly created Lens Flare
  52770. */
  52771. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  52772. /**
  52773. * Instantiates a new Lens Flare.
  52774. * This represents one of the lens effect in a `lensFlareSystem`.
  52775. * It controls one of the indiviual texture used in the effect.
  52776. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52777. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  52778. * @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.
  52779. * @param color Define the lens color
  52780. * @param imgUrl Define the lens texture url
  52781. * @param system Define the `lensFlareSystem` this flare is part of
  52782. */
  52783. constructor(
  52784. /**
  52785. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  52786. */
  52787. size: number,
  52788. /**
  52789. * 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.
  52790. */
  52791. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  52792. /**
  52793. * Dispose and release the lens flare with its associated resources.
  52794. */
  52795. dispose(): void;
  52796. }
  52797. }
  52798. declare module BABYLON {
  52799. interface AbstractScene {
  52800. /**
  52801. * The list of lens flare system added to the scene
  52802. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52803. */
  52804. lensFlareSystems: Array<LensFlareSystem>;
  52805. /**
  52806. * Removes the given lens flare system from this scene.
  52807. * @param toRemove The lens flare system to remove
  52808. * @returns The index of the removed lens flare system
  52809. */
  52810. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  52811. /**
  52812. * Adds the given lens flare system to this scene
  52813. * @param newLensFlareSystem The lens flare system to add
  52814. */
  52815. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  52816. /**
  52817. * Gets a lens flare system using its name
  52818. * @param name defines the name to look for
  52819. * @returns the lens flare system or null if not found
  52820. */
  52821. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  52822. /**
  52823. * Gets a lens flare system using its id
  52824. * @param id defines the id to look for
  52825. * @returns the lens flare system or null if not found
  52826. */
  52827. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  52828. }
  52829. /**
  52830. * Defines the lens flare scene component responsible to manage any lens flares
  52831. * in a given scene.
  52832. */
  52833. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  52834. /**
  52835. * The component name helpfull to identify the component in the list of scene components.
  52836. */
  52837. readonly name: string;
  52838. /**
  52839. * The scene the component belongs to.
  52840. */
  52841. scene: Scene;
  52842. /**
  52843. * Creates a new instance of the component for the given scene
  52844. * @param scene Defines the scene to register the component in
  52845. */
  52846. constructor(scene: Scene);
  52847. /**
  52848. * Registers the component in a given scene
  52849. */
  52850. register(): void;
  52851. /**
  52852. * Rebuilds the elements related to this component in case of
  52853. * context lost for instance.
  52854. */
  52855. rebuild(): void;
  52856. /**
  52857. * Adds all the elements from the container to the scene
  52858. * @param container the container holding the elements
  52859. */
  52860. addFromContainer(container: AbstractScene): void;
  52861. /**
  52862. * Removes all the elements in the container from the scene
  52863. * @param container contains the elements to remove
  52864. * @param dispose if the removed element should be disposed (default: false)
  52865. */
  52866. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52867. /**
  52868. * Serializes the component data to the specified json object
  52869. * @param serializationObject The object to serialize to
  52870. */
  52871. serialize(serializationObject: any): void;
  52872. /**
  52873. * Disposes the component and the associated ressources.
  52874. */
  52875. dispose(): void;
  52876. private _draw;
  52877. }
  52878. }
  52879. declare module BABYLON {
  52880. /**
  52881. * Defines the shadow generator component responsible to manage any shadow generators
  52882. * in a given scene.
  52883. */
  52884. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  52885. /**
  52886. * The component name helpfull to identify the component in the list of scene components.
  52887. */
  52888. readonly name: string;
  52889. /**
  52890. * The scene the component belongs to.
  52891. */
  52892. scene: Scene;
  52893. /**
  52894. * Creates a new instance of the component for the given scene
  52895. * @param scene Defines the scene to register the component in
  52896. */
  52897. constructor(scene: Scene);
  52898. /**
  52899. * Registers the component in a given scene
  52900. */
  52901. register(): void;
  52902. /**
  52903. * Rebuilds the elements related to this component in case of
  52904. * context lost for instance.
  52905. */
  52906. rebuild(): void;
  52907. /**
  52908. * Serializes the component data to the specified json object
  52909. * @param serializationObject The object to serialize to
  52910. */
  52911. serialize(serializationObject: any): void;
  52912. /**
  52913. * Adds all the elements from the container to the scene
  52914. * @param container the container holding the elements
  52915. */
  52916. addFromContainer(container: AbstractScene): void;
  52917. /**
  52918. * Removes all the elements in the container from the scene
  52919. * @param container contains the elements to remove
  52920. * @param dispose if the removed element should be disposed (default: false)
  52921. */
  52922. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52923. /**
  52924. * Rebuilds the elements related to this component in case of
  52925. * context lost for instance.
  52926. */
  52927. dispose(): void;
  52928. private _gatherRenderTargets;
  52929. }
  52930. }
  52931. declare module BABYLON {
  52932. /**
  52933. * A point light is a light defined by an unique point in world space.
  52934. * The light is emitted in every direction from this point.
  52935. * A good example of a point light is a standard light bulb.
  52936. * Documentation: https://doc.babylonjs.com/babylon101/lights
  52937. */
  52938. export class PointLight extends ShadowLight {
  52939. private _shadowAngle;
  52940. /**
  52941. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52942. * This specifies what angle the shadow will use to be created.
  52943. *
  52944. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  52945. */
  52946. get shadowAngle(): number;
  52947. /**
  52948. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52949. * This specifies what angle the shadow will use to be created.
  52950. *
  52951. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  52952. */
  52953. set shadowAngle(value: number);
  52954. /**
  52955. * Gets the direction if it has been set.
  52956. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52957. */
  52958. get direction(): Vector3;
  52959. /**
  52960. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52961. */
  52962. set direction(value: Vector3);
  52963. /**
  52964. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  52965. * A PointLight emits the light in every direction.
  52966. * It can cast shadows.
  52967. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  52968. * ```javascript
  52969. * var pointLight = new PointLight("pl", camera.position, scene);
  52970. * ```
  52971. * Documentation : https://doc.babylonjs.com/babylon101/lights
  52972. * @param name The light friendly name
  52973. * @param position The position of the point light in the scene
  52974. * @param scene The scene the lights belongs to
  52975. */
  52976. constructor(name: string, position: Vector3, scene: Scene);
  52977. /**
  52978. * Returns the string "PointLight"
  52979. * @returns the class name
  52980. */
  52981. getClassName(): string;
  52982. /**
  52983. * Returns the integer 0.
  52984. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  52985. */
  52986. getTypeID(): number;
  52987. /**
  52988. * Specifies wether or not the shadowmap should be a cube texture.
  52989. * @returns true if the shadowmap needs to be a cube texture.
  52990. */
  52991. needCube(): boolean;
  52992. /**
  52993. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  52994. * @param faceIndex The index of the face we are computed the direction to generate shadow
  52995. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  52996. */
  52997. getShadowDirection(faceIndex?: number): Vector3;
  52998. /**
  52999. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  53000. * - fov = PI / 2
  53001. * - aspect ratio : 1.0
  53002. * - z-near and far equal to the active camera minZ and maxZ.
  53003. * Returns the PointLight.
  53004. */
  53005. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  53006. protected _buildUniformLayout(): void;
  53007. /**
  53008. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  53009. * @param effect The effect to update
  53010. * @param lightIndex The index of the light in the effect to update
  53011. * @returns The point light
  53012. */
  53013. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  53014. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  53015. /**
  53016. * Prepares the list of defines specific to the light type.
  53017. * @param defines the list of defines
  53018. * @param lightIndex defines the index of the light for the effect
  53019. */
  53020. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  53021. }
  53022. }
  53023. declare module BABYLON {
  53024. /**
  53025. * Header information of HDR texture files.
  53026. */
  53027. export interface HDRInfo {
  53028. /**
  53029. * The height of the texture in pixels.
  53030. */
  53031. height: number;
  53032. /**
  53033. * The width of the texture in pixels.
  53034. */
  53035. width: number;
  53036. /**
  53037. * The index of the beginning of the data in the binary file.
  53038. */
  53039. dataPosition: number;
  53040. }
  53041. /**
  53042. * This groups tools to convert HDR texture to native colors array.
  53043. */
  53044. export class HDRTools {
  53045. private static Ldexp;
  53046. private static Rgbe2float;
  53047. private static readStringLine;
  53048. /**
  53049. * Reads header information from an RGBE texture stored in a native array.
  53050. * More information on this format are available here:
  53051. * https://en.wikipedia.org/wiki/RGBE_image_format
  53052. *
  53053. * @param uint8array The binary file stored in native array.
  53054. * @return The header information.
  53055. */
  53056. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  53057. /**
  53058. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  53059. * This RGBE texture needs to store the information as a panorama.
  53060. *
  53061. * More information on this format are available here:
  53062. * https://en.wikipedia.org/wiki/RGBE_image_format
  53063. *
  53064. * @param buffer The binary file stored in an array buffer.
  53065. * @param size The expected size of the extracted cubemap.
  53066. * @return The Cube Map information.
  53067. */
  53068. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  53069. /**
  53070. * Returns the pixels data extracted from an RGBE texture.
  53071. * This pixels will be stored left to right up to down in the R G B order in one array.
  53072. *
  53073. * More information on this format are available here:
  53074. * https://en.wikipedia.org/wiki/RGBE_image_format
  53075. *
  53076. * @param uint8array The binary file stored in an array buffer.
  53077. * @param hdrInfo The header information of the file.
  53078. * @return The pixels data in RGB right to left up to down order.
  53079. */
  53080. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  53081. private static RGBE_ReadPixels_RLE;
  53082. }
  53083. }
  53084. declare module BABYLON {
  53085. /**
  53086. * This represents a texture coming from an HDR input.
  53087. *
  53088. * The only supported format is currently panorama picture stored in RGBE format.
  53089. * Example of such files can be found on HDRLib: http://hdrlib.com/
  53090. */
  53091. export class HDRCubeTexture extends BaseTexture {
  53092. private static _facesMapping;
  53093. private _generateHarmonics;
  53094. private _noMipmap;
  53095. private _textureMatrix;
  53096. private _size;
  53097. private _onLoad;
  53098. private _onError;
  53099. /**
  53100. * The texture URL.
  53101. */
  53102. url: string;
  53103. /**
  53104. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  53105. */
  53106. coordinatesMode: number;
  53107. protected _isBlocking: boolean;
  53108. /**
  53109. * Sets wether or not the texture is blocking during loading.
  53110. */
  53111. set isBlocking(value: boolean);
  53112. /**
  53113. * Gets wether or not the texture is blocking during loading.
  53114. */
  53115. get isBlocking(): boolean;
  53116. protected _rotationY: number;
  53117. /**
  53118. * Sets texture matrix rotation angle around Y axis in radians.
  53119. */
  53120. set rotationY(value: number);
  53121. /**
  53122. * Gets texture matrix rotation angle around Y axis radians.
  53123. */
  53124. get rotationY(): number;
  53125. /**
  53126. * Gets or sets the center of the bounding box associated with the cube texture
  53127. * It must define where the camera used to render the texture was set
  53128. */
  53129. boundingBoxPosition: Vector3;
  53130. private _boundingBoxSize;
  53131. /**
  53132. * Gets or sets the size of the bounding box associated with the cube texture
  53133. * When defined, the cubemap will switch to local mode
  53134. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  53135. * @example https://www.babylonjs-playground.com/#RNASML
  53136. */
  53137. set boundingBoxSize(value: Vector3);
  53138. get boundingBoxSize(): Vector3;
  53139. /**
  53140. * Instantiates an HDRTexture from the following parameters.
  53141. *
  53142. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  53143. * @param scene The scene the texture will be used in
  53144. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  53145. * @param noMipmap Forces to not generate the mipmap if true
  53146. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  53147. * @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)
  53148. * @param reserved Reserved flag for internal use.
  53149. */
  53150. 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>);
  53151. /**
  53152. * Get the current class name of the texture useful for serialization or dynamic coding.
  53153. * @returns "HDRCubeTexture"
  53154. */
  53155. getClassName(): string;
  53156. /**
  53157. * Occurs when the file is raw .hdr file.
  53158. */
  53159. private loadTexture;
  53160. clone(): HDRCubeTexture;
  53161. delayLoad(): void;
  53162. /**
  53163. * Get the texture reflection matrix used to rotate/transform the reflection.
  53164. * @returns the reflection matrix
  53165. */
  53166. getReflectionTextureMatrix(): Matrix;
  53167. /**
  53168. * Set the texture reflection matrix used to rotate/transform the reflection.
  53169. * @param value Define the reflection matrix to set
  53170. */
  53171. setReflectionTextureMatrix(value: Matrix): void;
  53172. /**
  53173. * Parses a JSON representation of an HDR Texture in order to create the texture
  53174. * @param parsedTexture Define the JSON representation
  53175. * @param scene Define the scene the texture should be created in
  53176. * @param rootUrl Define the root url in case we need to load relative dependencies
  53177. * @returns the newly created texture after parsing
  53178. */
  53179. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  53180. serialize(): any;
  53181. }
  53182. }
  53183. declare module BABYLON {
  53184. /**
  53185. * Class used to control physics engine
  53186. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  53187. */
  53188. export class PhysicsEngine implements IPhysicsEngine {
  53189. private _physicsPlugin;
  53190. /**
  53191. * Global value used to control the smallest number supported by the simulation
  53192. */
  53193. static Epsilon: number;
  53194. private _impostors;
  53195. private _joints;
  53196. private _subTimeStep;
  53197. /**
  53198. * Gets the gravity vector used by the simulation
  53199. */
  53200. gravity: Vector3;
  53201. /**
  53202. * Factory used to create the default physics plugin.
  53203. * @returns The default physics plugin
  53204. */
  53205. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  53206. /**
  53207. * Creates a new Physics Engine
  53208. * @param gravity defines the gravity vector used by the simulation
  53209. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  53210. */
  53211. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  53212. /**
  53213. * Sets the gravity vector used by the simulation
  53214. * @param gravity defines the gravity vector to use
  53215. */
  53216. setGravity(gravity: Vector3): void;
  53217. /**
  53218. * Set the time step of the physics engine.
  53219. * Default is 1/60.
  53220. * To slow it down, enter 1/600 for example.
  53221. * To speed it up, 1/30
  53222. * @param newTimeStep defines the new timestep to apply to this world.
  53223. */
  53224. setTimeStep(newTimeStep?: number): void;
  53225. /**
  53226. * Get the time step of the physics engine.
  53227. * @returns the current time step
  53228. */
  53229. getTimeStep(): number;
  53230. /**
  53231. * Set the sub time step of the physics engine.
  53232. * Default is 0 meaning there is no sub steps
  53233. * To increase physics resolution precision, set a small value (like 1 ms)
  53234. * @param subTimeStep defines the new sub timestep used for physics resolution.
  53235. */
  53236. setSubTimeStep(subTimeStep?: number): void;
  53237. /**
  53238. * Get the sub time step of the physics engine.
  53239. * @returns the current sub time step
  53240. */
  53241. getSubTimeStep(): number;
  53242. /**
  53243. * Release all resources
  53244. */
  53245. dispose(): void;
  53246. /**
  53247. * Gets the name of the current physics plugin
  53248. * @returns the name of the plugin
  53249. */
  53250. getPhysicsPluginName(): string;
  53251. /**
  53252. * Adding a new impostor for the impostor tracking.
  53253. * This will be done by the impostor itself.
  53254. * @param impostor the impostor to add
  53255. */
  53256. addImpostor(impostor: PhysicsImpostor): void;
  53257. /**
  53258. * Remove an impostor from the engine.
  53259. * This impostor and its mesh will not longer be updated by the physics engine.
  53260. * @param impostor the impostor to remove
  53261. */
  53262. removeImpostor(impostor: PhysicsImpostor): void;
  53263. /**
  53264. * Add a joint to the physics engine
  53265. * @param mainImpostor defines the main impostor to which the joint is added.
  53266. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  53267. * @param joint defines the joint that will connect both impostors.
  53268. */
  53269. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  53270. /**
  53271. * Removes a joint from the simulation
  53272. * @param mainImpostor defines the impostor used with the joint
  53273. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  53274. * @param joint defines the joint to remove
  53275. */
  53276. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  53277. /**
  53278. * Called by the scene. No need to call it.
  53279. * @param delta defines the timespam between frames
  53280. */
  53281. _step(delta: number): void;
  53282. /**
  53283. * Gets the current plugin used to run the simulation
  53284. * @returns current plugin
  53285. */
  53286. getPhysicsPlugin(): IPhysicsEnginePlugin;
  53287. /**
  53288. * Gets the list of physic impostors
  53289. * @returns an array of PhysicsImpostor
  53290. */
  53291. getImpostors(): Array<PhysicsImpostor>;
  53292. /**
  53293. * Gets the impostor for a physics enabled object
  53294. * @param object defines the object impersonated by the impostor
  53295. * @returns the PhysicsImpostor or null if not found
  53296. */
  53297. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  53298. /**
  53299. * Gets the impostor for a physics body object
  53300. * @param body defines physics body used by the impostor
  53301. * @returns the PhysicsImpostor or null if not found
  53302. */
  53303. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  53304. /**
  53305. * Does a raycast in the physics world
  53306. * @param from when should the ray start?
  53307. * @param to when should the ray end?
  53308. * @returns PhysicsRaycastResult
  53309. */
  53310. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53311. }
  53312. }
  53313. declare module BABYLON {
  53314. /** @hidden */
  53315. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  53316. private _useDeltaForWorldStep;
  53317. world: any;
  53318. name: string;
  53319. private _physicsMaterials;
  53320. private _fixedTimeStep;
  53321. private _cannonRaycastResult;
  53322. private _raycastResult;
  53323. private _physicsBodysToRemoveAfterStep;
  53324. BJSCANNON: any;
  53325. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  53326. setGravity(gravity: Vector3): void;
  53327. setTimeStep(timeStep: number): void;
  53328. getTimeStep(): number;
  53329. executeStep(delta: number): void;
  53330. private _removeMarkedPhysicsBodiesFromWorld;
  53331. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53332. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53333. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53334. private _processChildMeshes;
  53335. removePhysicsBody(impostor: PhysicsImpostor): void;
  53336. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53337. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53338. private _addMaterial;
  53339. private _checkWithEpsilon;
  53340. private _createShape;
  53341. private _createHeightmap;
  53342. private _minus90X;
  53343. private _plus90X;
  53344. private _tmpPosition;
  53345. private _tmpDeltaPosition;
  53346. private _tmpUnityRotation;
  53347. private _updatePhysicsBodyTransformation;
  53348. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53349. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53350. isSupported(): boolean;
  53351. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53352. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53353. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53354. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53355. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53356. getBodyMass(impostor: PhysicsImpostor): number;
  53357. getBodyFriction(impostor: PhysicsImpostor): number;
  53358. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53359. getBodyRestitution(impostor: PhysicsImpostor): number;
  53360. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53361. sleepBody(impostor: PhysicsImpostor): void;
  53362. wakeUpBody(impostor: PhysicsImpostor): void;
  53363. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  53364. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  53365. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  53366. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  53367. getRadius(impostor: PhysicsImpostor): number;
  53368. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  53369. dispose(): void;
  53370. private _extendNamespace;
  53371. /**
  53372. * Does a raycast in the physics world
  53373. * @param from when should the ray start?
  53374. * @param to when should the ray end?
  53375. * @returns PhysicsRaycastResult
  53376. */
  53377. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53378. }
  53379. }
  53380. declare module BABYLON {
  53381. /** @hidden */
  53382. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  53383. world: any;
  53384. name: string;
  53385. BJSOIMO: any;
  53386. private _raycastResult;
  53387. constructor(iterations?: number, oimoInjection?: any);
  53388. setGravity(gravity: Vector3): void;
  53389. setTimeStep(timeStep: number): void;
  53390. getTimeStep(): number;
  53391. private _tmpImpostorsArray;
  53392. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  53393. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53394. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53395. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53396. private _tmpPositionVector;
  53397. removePhysicsBody(impostor: PhysicsImpostor): void;
  53398. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53399. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53400. isSupported(): boolean;
  53401. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53402. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53403. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53404. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53405. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53406. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53407. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53408. getBodyMass(impostor: PhysicsImpostor): number;
  53409. getBodyFriction(impostor: PhysicsImpostor): number;
  53410. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53411. getBodyRestitution(impostor: PhysicsImpostor): number;
  53412. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53413. sleepBody(impostor: PhysicsImpostor): void;
  53414. wakeUpBody(impostor: PhysicsImpostor): void;
  53415. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  53416. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  53417. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  53418. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  53419. getRadius(impostor: PhysicsImpostor): number;
  53420. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  53421. dispose(): void;
  53422. /**
  53423. * Does a raycast in the physics world
  53424. * @param from when should the ray start?
  53425. * @param to when should the ray end?
  53426. * @returns PhysicsRaycastResult
  53427. */
  53428. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53429. }
  53430. }
  53431. declare module BABYLON {
  53432. /**
  53433. * Class containing static functions to help procedurally build meshes
  53434. */
  53435. export class RibbonBuilder {
  53436. /**
  53437. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  53438. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  53439. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  53440. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  53441. * * 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
  53442. * * 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
  53443. * * 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
  53444. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53445. * * 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
  53446. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53447. * * 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
  53448. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  53449. * * 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
  53450. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  53451. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53452. * @param name defines the name of the mesh
  53453. * @param options defines the options used to create the mesh
  53454. * @param scene defines the hosting scene
  53455. * @returns the ribbon mesh
  53456. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  53457. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53458. */
  53459. static CreateRibbon(name: string, options: {
  53460. pathArray: Vector3[][];
  53461. closeArray?: boolean;
  53462. closePath?: boolean;
  53463. offset?: number;
  53464. updatable?: boolean;
  53465. sideOrientation?: number;
  53466. frontUVs?: Vector4;
  53467. backUVs?: Vector4;
  53468. instance?: Mesh;
  53469. invertUV?: boolean;
  53470. uvs?: Vector2[];
  53471. colors?: Color4[];
  53472. }, scene?: Nullable<Scene>): Mesh;
  53473. }
  53474. }
  53475. declare module BABYLON {
  53476. /**
  53477. * Class containing static functions to help procedurally build meshes
  53478. */
  53479. export class ShapeBuilder {
  53480. /**
  53481. * 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.
  53482. * * 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.
  53483. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53484. * * 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.
  53485. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  53486. * * 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
  53487. * * 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
  53488. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  53489. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53490. * * 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
  53491. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  53492. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53493. * @param name defines the name of the mesh
  53494. * @param options defines the options used to create the mesh
  53495. * @param scene defines the hosting scene
  53496. * @returns the extruded shape mesh
  53497. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53498. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53499. */
  53500. static ExtrudeShape(name: string, options: {
  53501. shape: Vector3[];
  53502. path: Vector3[];
  53503. scale?: number;
  53504. rotation?: number;
  53505. cap?: number;
  53506. updatable?: boolean;
  53507. sideOrientation?: number;
  53508. frontUVs?: Vector4;
  53509. backUVs?: Vector4;
  53510. instance?: Mesh;
  53511. invertUV?: boolean;
  53512. }, scene?: Nullable<Scene>): Mesh;
  53513. /**
  53514. * Creates an custom extruded shape mesh.
  53515. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  53516. * * 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.
  53517. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53518. * * 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
  53519. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  53520. * * 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
  53521. * * It must returns a float value that will be the scale value applied to the shape on each path point
  53522. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  53523. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  53524. * * 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
  53525. * * 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
  53526. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  53527. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53528. * * 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
  53529. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53530. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53531. * @param name defines the name of the mesh
  53532. * @param options defines the options used to create the mesh
  53533. * @param scene defines the hosting scene
  53534. * @returns the custom extruded shape mesh
  53535. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  53536. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53537. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53538. */
  53539. static ExtrudeShapeCustom(name: string, options: {
  53540. shape: Vector3[];
  53541. path: Vector3[];
  53542. scaleFunction?: any;
  53543. rotationFunction?: any;
  53544. ribbonCloseArray?: boolean;
  53545. ribbonClosePath?: boolean;
  53546. cap?: number;
  53547. updatable?: boolean;
  53548. sideOrientation?: number;
  53549. frontUVs?: Vector4;
  53550. backUVs?: Vector4;
  53551. instance?: Mesh;
  53552. invertUV?: boolean;
  53553. }, scene?: Nullable<Scene>): Mesh;
  53554. private static _ExtrudeShapeGeneric;
  53555. }
  53556. }
  53557. declare module BABYLON {
  53558. /**
  53559. * AmmoJS Physics plugin
  53560. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  53561. * @see https://github.com/kripken/ammo.js/
  53562. */
  53563. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  53564. private _useDeltaForWorldStep;
  53565. /**
  53566. * Reference to the Ammo library
  53567. */
  53568. bjsAMMO: any;
  53569. /**
  53570. * Created ammoJS world which physics bodies are added to
  53571. */
  53572. world: any;
  53573. /**
  53574. * Name of the plugin
  53575. */
  53576. name: string;
  53577. private _timeStep;
  53578. private _fixedTimeStep;
  53579. private _maxSteps;
  53580. private _tmpQuaternion;
  53581. private _tmpAmmoTransform;
  53582. private _tmpAmmoQuaternion;
  53583. private _tmpAmmoConcreteContactResultCallback;
  53584. private _collisionConfiguration;
  53585. private _dispatcher;
  53586. private _overlappingPairCache;
  53587. private _solver;
  53588. private _softBodySolver;
  53589. private _tmpAmmoVectorA;
  53590. private _tmpAmmoVectorB;
  53591. private _tmpAmmoVectorC;
  53592. private _tmpAmmoVectorD;
  53593. private _tmpContactCallbackResult;
  53594. private _tmpAmmoVectorRCA;
  53595. private _tmpAmmoVectorRCB;
  53596. private _raycastResult;
  53597. private static readonly DISABLE_COLLISION_FLAG;
  53598. private static readonly KINEMATIC_FLAG;
  53599. private static readonly DISABLE_DEACTIVATION_FLAG;
  53600. /**
  53601. * Initializes the ammoJS plugin
  53602. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  53603. * @param ammoInjection can be used to inject your own ammo reference
  53604. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  53605. */
  53606. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  53607. /**
  53608. * Sets the gravity of the physics world (m/(s^2))
  53609. * @param gravity Gravity to set
  53610. */
  53611. setGravity(gravity: Vector3): void;
  53612. /**
  53613. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  53614. * @param timeStep timestep to use in seconds
  53615. */
  53616. setTimeStep(timeStep: number): void;
  53617. /**
  53618. * 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)
  53619. * @param fixedTimeStep fixedTimeStep to use in seconds
  53620. */
  53621. setFixedTimeStep(fixedTimeStep: number): void;
  53622. /**
  53623. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  53624. * @param maxSteps the maximum number of steps by the physics engine per frame
  53625. */
  53626. setMaxSteps(maxSteps: number): void;
  53627. /**
  53628. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  53629. * @returns the current timestep in seconds
  53630. */
  53631. getTimeStep(): number;
  53632. /**
  53633. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  53634. */
  53635. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  53636. private _isImpostorInContact;
  53637. private _isImpostorPairInContact;
  53638. private _stepSimulation;
  53639. /**
  53640. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  53641. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  53642. * After the step the babylon meshes are set to the position of the physics imposters
  53643. * @param delta amount of time to step forward
  53644. * @param impostors array of imposters to update before/after the step
  53645. */
  53646. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  53647. /**
  53648. * Update babylon mesh to match physics world object
  53649. * @param impostor imposter to match
  53650. */
  53651. private _afterSoftStep;
  53652. /**
  53653. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  53654. * @param impostor imposter to match
  53655. */
  53656. private _ropeStep;
  53657. /**
  53658. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  53659. * @param impostor imposter to match
  53660. */
  53661. private _softbodyOrClothStep;
  53662. private _tmpVector;
  53663. private _tmpMatrix;
  53664. /**
  53665. * Applies an impulse on the imposter
  53666. * @param impostor imposter to apply impulse to
  53667. * @param force amount of force to be applied to the imposter
  53668. * @param contactPoint the location to apply the impulse on the imposter
  53669. */
  53670. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53671. /**
  53672. * Applies a force on the imposter
  53673. * @param impostor imposter to apply force
  53674. * @param force amount of force to be applied to the imposter
  53675. * @param contactPoint the location to apply the force on the imposter
  53676. */
  53677. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53678. /**
  53679. * Creates a physics body using the plugin
  53680. * @param impostor the imposter to create the physics body on
  53681. */
  53682. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53683. /**
  53684. * Removes the physics body from the imposter and disposes of the body's memory
  53685. * @param impostor imposter to remove the physics body from
  53686. */
  53687. removePhysicsBody(impostor: PhysicsImpostor): void;
  53688. /**
  53689. * Generates a joint
  53690. * @param impostorJoint the imposter joint to create the joint with
  53691. */
  53692. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53693. /**
  53694. * Removes a joint
  53695. * @param impostorJoint the imposter joint to remove the joint from
  53696. */
  53697. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53698. private _addMeshVerts;
  53699. /**
  53700. * Initialise the soft body vertices to match its object's (mesh) vertices
  53701. * Softbody vertices (nodes) are in world space and to match this
  53702. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  53703. * @param impostor to create the softbody for
  53704. */
  53705. private _softVertexData;
  53706. /**
  53707. * Create an impostor's soft body
  53708. * @param impostor to create the softbody for
  53709. */
  53710. private _createSoftbody;
  53711. /**
  53712. * Create cloth for an impostor
  53713. * @param impostor to create the softbody for
  53714. */
  53715. private _createCloth;
  53716. /**
  53717. * Create rope for an impostor
  53718. * @param impostor to create the softbody for
  53719. */
  53720. private _createRope;
  53721. /**
  53722. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  53723. * @param impostor to create the custom physics shape for
  53724. */
  53725. private _createCustom;
  53726. private _addHullVerts;
  53727. private _createShape;
  53728. /**
  53729. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  53730. * @param impostor imposter containing the physics body and babylon object
  53731. */
  53732. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53733. /**
  53734. * Sets the babylon object's position/rotation from the physics body's position/rotation
  53735. * @param impostor imposter containing the physics body and babylon object
  53736. * @param newPosition new position
  53737. * @param newRotation new rotation
  53738. */
  53739. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53740. /**
  53741. * If this plugin is supported
  53742. * @returns true if its supported
  53743. */
  53744. isSupported(): boolean;
  53745. /**
  53746. * Sets the linear velocity of the physics body
  53747. * @param impostor imposter to set the velocity on
  53748. * @param velocity velocity to set
  53749. */
  53750. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53751. /**
  53752. * Sets the angular velocity of the physics body
  53753. * @param impostor imposter to set the velocity on
  53754. * @param velocity velocity to set
  53755. */
  53756. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53757. /**
  53758. * gets the linear velocity
  53759. * @param impostor imposter to get linear velocity from
  53760. * @returns linear velocity
  53761. */
  53762. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53763. /**
  53764. * gets the angular velocity
  53765. * @param impostor imposter to get angular velocity from
  53766. * @returns angular velocity
  53767. */
  53768. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53769. /**
  53770. * Sets the mass of physics body
  53771. * @param impostor imposter to set the mass on
  53772. * @param mass mass to set
  53773. */
  53774. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53775. /**
  53776. * Gets the mass of the physics body
  53777. * @param impostor imposter to get the mass from
  53778. * @returns mass
  53779. */
  53780. getBodyMass(impostor: PhysicsImpostor): number;
  53781. /**
  53782. * Gets friction of the impostor
  53783. * @param impostor impostor to get friction from
  53784. * @returns friction value
  53785. */
  53786. getBodyFriction(impostor: PhysicsImpostor): number;
  53787. /**
  53788. * Sets friction of the impostor
  53789. * @param impostor impostor to set friction on
  53790. * @param friction friction value
  53791. */
  53792. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53793. /**
  53794. * Gets restitution of the impostor
  53795. * @param impostor impostor to get restitution from
  53796. * @returns restitution value
  53797. */
  53798. getBodyRestitution(impostor: PhysicsImpostor): number;
  53799. /**
  53800. * Sets resitution of the impostor
  53801. * @param impostor impostor to set resitution on
  53802. * @param restitution resitution value
  53803. */
  53804. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53805. /**
  53806. * Gets pressure inside the impostor
  53807. * @param impostor impostor to get pressure from
  53808. * @returns pressure value
  53809. */
  53810. getBodyPressure(impostor: PhysicsImpostor): number;
  53811. /**
  53812. * Sets pressure inside a soft body impostor
  53813. * Cloth and rope must remain 0 pressure
  53814. * @param impostor impostor to set pressure on
  53815. * @param pressure pressure value
  53816. */
  53817. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  53818. /**
  53819. * Gets stiffness of the impostor
  53820. * @param impostor impostor to get stiffness from
  53821. * @returns pressure value
  53822. */
  53823. getBodyStiffness(impostor: PhysicsImpostor): number;
  53824. /**
  53825. * Sets stiffness of the impostor
  53826. * @param impostor impostor to set stiffness on
  53827. * @param stiffness stiffness value from 0 to 1
  53828. */
  53829. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  53830. /**
  53831. * Gets velocityIterations of the impostor
  53832. * @param impostor impostor to get velocity iterations from
  53833. * @returns velocityIterations value
  53834. */
  53835. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  53836. /**
  53837. * Sets velocityIterations of the impostor
  53838. * @param impostor impostor to set velocity iterations on
  53839. * @param velocityIterations velocityIterations value
  53840. */
  53841. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  53842. /**
  53843. * Gets positionIterations of the impostor
  53844. * @param impostor impostor to get position iterations from
  53845. * @returns positionIterations value
  53846. */
  53847. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  53848. /**
  53849. * Sets positionIterations of the impostor
  53850. * @param impostor impostor to set position on
  53851. * @param positionIterations positionIterations value
  53852. */
  53853. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  53854. /**
  53855. * Append an anchor to a cloth object
  53856. * @param impostor is the cloth impostor to add anchor to
  53857. * @param otherImpostor is the rigid impostor to anchor to
  53858. * @param width ratio across width from 0 to 1
  53859. * @param height ratio up height from 0 to 1
  53860. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  53861. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  53862. */
  53863. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  53864. /**
  53865. * Append an hook to a rope object
  53866. * @param impostor is the rope impostor to add hook to
  53867. * @param otherImpostor is the rigid impostor to hook to
  53868. * @param length ratio along the rope from 0 to 1
  53869. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  53870. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  53871. */
  53872. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  53873. /**
  53874. * Sleeps the physics body and stops it from being active
  53875. * @param impostor impostor to sleep
  53876. */
  53877. sleepBody(impostor: PhysicsImpostor): void;
  53878. /**
  53879. * Activates the physics body
  53880. * @param impostor impostor to activate
  53881. */
  53882. wakeUpBody(impostor: PhysicsImpostor): void;
  53883. /**
  53884. * Updates the distance parameters of the joint
  53885. * @param joint joint to update
  53886. * @param maxDistance maximum distance of the joint
  53887. * @param minDistance minimum distance of the joint
  53888. */
  53889. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  53890. /**
  53891. * Sets a motor on the joint
  53892. * @param joint joint to set motor on
  53893. * @param speed speed of the motor
  53894. * @param maxForce maximum force of the motor
  53895. * @param motorIndex index of the motor
  53896. */
  53897. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  53898. /**
  53899. * Sets the motors limit
  53900. * @param joint joint to set limit on
  53901. * @param upperLimit upper limit
  53902. * @param lowerLimit lower limit
  53903. */
  53904. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  53905. /**
  53906. * Syncs the position and rotation of a mesh with the impostor
  53907. * @param mesh mesh to sync
  53908. * @param impostor impostor to update the mesh with
  53909. */
  53910. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  53911. /**
  53912. * Gets the radius of the impostor
  53913. * @param impostor impostor to get radius from
  53914. * @returns the radius
  53915. */
  53916. getRadius(impostor: PhysicsImpostor): number;
  53917. /**
  53918. * Gets the box size of the impostor
  53919. * @param impostor impostor to get box size from
  53920. * @param result the resulting box size
  53921. */
  53922. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  53923. /**
  53924. * Disposes of the impostor
  53925. */
  53926. dispose(): void;
  53927. /**
  53928. * Does a raycast in the physics world
  53929. * @param from when should the ray start?
  53930. * @param to when should the ray end?
  53931. * @returns PhysicsRaycastResult
  53932. */
  53933. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53934. }
  53935. }
  53936. declare module BABYLON {
  53937. interface AbstractScene {
  53938. /**
  53939. * The list of reflection probes added to the scene
  53940. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  53941. */
  53942. reflectionProbes: Array<ReflectionProbe>;
  53943. /**
  53944. * Removes the given reflection probe from this scene.
  53945. * @param toRemove The reflection probe to remove
  53946. * @returns The index of the removed reflection probe
  53947. */
  53948. removeReflectionProbe(toRemove: ReflectionProbe): number;
  53949. /**
  53950. * Adds the given reflection probe to this scene.
  53951. * @param newReflectionProbe The reflection probe to add
  53952. */
  53953. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  53954. }
  53955. /**
  53956. * Class used to generate realtime reflection / refraction cube textures
  53957. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  53958. */
  53959. export class ReflectionProbe {
  53960. /** defines the name of the probe */
  53961. name: string;
  53962. private _scene;
  53963. private _renderTargetTexture;
  53964. private _projectionMatrix;
  53965. private _viewMatrix;
  53966. private _target;
  53967. private _add;
  53968. private _attachedMesh;
  53969. private _invertYAxis;
  53970. /** Gets or sets probe position (center of the cube map) */
  53971. position: Vector3;
  53972. /**
  53973. * Creates a new reflection probe
  53974. * @param name defines the name of the probe
  53975. * @param size defines the texture resolution (for each face)
  53976. * @param scene defines the hosting scene
  53977. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  53978. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  53979. */
  53980. constructor(
  53981. /** defines the name of the probe */
  53982. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  53983. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  53984. get samples(): number;
  53985. set samples(value: number);
  53986. /** Gets or sets the refresh rate to use (on every frame by default) */
  53987. get refreshRate(): number;
  53988. set refreshRate(value: number);
  53989. /**
  53990. * Gets the hosting scene
  53991. * @returns a Scene
  53992. */
  53993. getScene(): Scene;
  53994. /** Gets the internal CubeTexture used to render to */
  53995. get cubeTexture(): RenderTargetTexture;
  53996. /** Gets the list of meshes to render */
  53997. get renderList(): Nullable<AbstractMesh[]>;
  53998. /**
  53999. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  54000. * @param mesh defines the mesh to attach to
  54001. */
  54002. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  54003. /**
  54004. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  54005. * @param renderingGroupId The rendering group id corresponding to its index
  54006. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  54007. */
  54008. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  54009. /**
  54010. * Clean all associated resources
  54011. */
  54012. dispose(): void;
  54013. /**
  54014. * Converts the reflection probe information to a readable string for debug purpose.
  54015. * @param fullDetails Supports for multiple levels of logging within scene loading
  54016. * @returns the human readable reflection probe info
  54017. */
  54018. toString(fullDetails?: boolean): string;
  54019. /**
  54020. * Get the class name of the relfection probe.
  54021. * @returns "ReflectionProbe"
  54022. */
  54023. getClassName(): string;
  54024. /**
  54025. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  54026. * @returns The JSON representation of the texture
  54027. */
  54028. serialize(): any;
  54029. /**
  54030. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  54031. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  54032. * @param scene Define the scene the parsed reflection probe should be instantiated in
  54033. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  54034. * @returns The parsed reflection probe if successful
  54035. */
  54036. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  54037. }
  54038. }
  54039. declare module BABYLON {
  54040. /** @hidden */
  54041. export var _BabylonLoaderRegistered: boolean;
  54042. /**
  54043. * Helps setting up some configuration for the babylon file loader.
  54044. */
  54045. export class BabylonFileLoaderConfiguration {
  54046. /**
  54047. * The loader does not allow injecting custom physix engine into the plugins.
  54048. * Unfortunately in ES6, we need to manually inject them into the plugin.
  54049. * So you could set this variable to your engine import to make it work.
  54050. */
  54051. static LoaderInjectedPhysicsEngine: any;
  54052. }
  54053. }
  54054. declare module BABYLON {
  54055. /**
  54056. * The Physically based simple base material of BJS.
  54057. *
  54058. * This enables better naming and convention enforcements on top of the pbrMaterial.
  54059. * It is used as the base class for both the specGloss and metalRough conventions.
  54060. */
  54061. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  54062. /**
  54063. * Number of Simultaneous lights allowed on the material.
  54064. */
  54065. maxSimultaneousLights: number;
  54066. /**
  54067. * If sets to true, disables all the lights affecting the material.
  54068. */
  54069. disableLighting: boolean;
  54070. /**
  54071. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  54072. */
  54073. environmentTexture: BaseTexture;
  54074. /**
  54075. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  54076. */
  54077. invertNormalMapX: boolean;
  54078. /**
  54079. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  54080. */
  54081. invertNormalMapY: boolean;
  54082. /**
  54083. * Normal map used in the model.
  54084. */
  54085. normalTexture: BaseTexture;
  54086. /**
  54087. * Emissivie color used to self-illuminate the model.
  54088. */
  54089. emissiveColor: Color3;
  54090. /**
  54091. * Emissivie texture used to self-illuminate the model.
  54092. */
  54093. emissiveTexture: BaseTexture;
  54094. /**
  54095. * Occlusion Channel Strenght.
  54096. */
  54097. occlusionStrength: number;
  54098. /**
  54099. * Occlusion Texture of the material (adding extra occlusion effects).
  54100. */
  54101. occlusionTexture: BaseTexture;
  54102. /**
  54103. * Defines the alpha limits in alpha test mode.
  54104. */
  54105. alphaCutOff: number;
  54106. /**
  54107. * Gets the current double sided mode.
  54108. */
  54109. get doubleSided(): boolean;
  54110. /**
  54111. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  54112. */
  54113. set doubleSided(value: boolean);
  54114. /**
  54115. * Stores the pre-calculated light information of a mesh in a texture.
  54116. */
  54117. lightmapTexture: BaseTexture;
  54118. /**
  54119. * If true, the light map contains occlusion information instead of lighting info.
  54120. */
  54121. useLightmapAsShadowmap: boolean;
  54122. /**
  54123. * Instantiates a new PBRMaterial instance.
  54124. *
  54125. * @param name The material name
  54126. * @param scene The scene the material will be use in.
  54127. */
  54128. constructor(name: string, scene: Scene);
  54129. getClassName(): string;
  54130. }
  54131. }
  54132. declare module BABYLON {
  54133. /**
  54134. * The PBR material of BJS following the metal roughness convention.
  54135. *
  54136. * This fits to the PBR convention in the GLTF definition:
  54137. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  54138. */
  54139. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  54140. /**
  54141. * The base color has two different interpretations depending on the value of metalness.
  54142. * When the material is a metal, the base color is the specific measured reflectance value
  54143. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  54144. * of the material.
  54145. */
  54146. baseColor: Color3;
  54147. /**
  54148. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  54149. * well as opacity information in the alpha channel.
  54150. */
  54151. baseTexture: BaseTexture;
  54152. /**
  54153. * Specifies the metallic scalar value of the material.
  54154. * Can also be used to scale the metalness values of the metallic texture.
  54155. */
  54156. metallic: number;
  54157. /**
  54158. * Specifies the roughness scalar value of the material.
  54159. * Can also be used to scale the roughness values of the metallic texture.
  54160. */
  54161. roughness: number;
  54162. /**
  54163. * Texture containing both the metallic value in the B channel and the
  54164. * roughness value in the G channel to keep better precision.
  54165. */
  54166. metallicRoughnessTexture: BaseTexture;
  54167. /**
  54168. * Instantiates a new PBRMetalRoughnessMaterial instance.
  54169. *
  54170. * @param name The material name
  54171. * @param scene The scene the material will be use in.
  54172. */
  54173. constructor(name: string, scene: Scene);
  54174. /**
  54175. * Return the currrent class name of the material.
  54176. */
  54177. getClassName(): string;
  54178. /**
  54179. * Makes a duplicate of the current material.
  54180. * @param name - name to use for the new material.
  54181. */
  54182. clone(name: string): PBRMetallicRoughnessMaterial;
  54183. /**
  54184. * Serialize the material to a parsable JSON object.
  54185. */
  54186. serialize(): any;
  54187. /**
  54188. * Parses a JSON object correponding to the serialize function.
  54189. */
  54190. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  54191. }
  54192. }
  54193. declare module BABYLON {
  54194. /**
  54195. * The PBR material of BJS following the specular glossiness convention.
  54196. *
  54197. * This fits to the PBR convention in the GLTF definition:
  54198. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  54199. */
  54200. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  54201. /**
  54202. * Specifies the diffuse color of the material.
  54203. */
  54204. diffuseColor: Color3;
  54205. /**
  54206. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  54207. * channel.
  54208. */
  54209. diffuseTexture: BaseTexture;
  54210. /**
  54211. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  54212. */
  54213. specularColor: Color3;
  54214. /**
  54215. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  54216. */
  54217. glossiness: number;
  54218. /**
  54219. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  54220. */
  54221. specularGlossinessTexture: BaseTexture;
  54222. /**
  54223. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  54224. *
  54225. * @param name The material name
  54226. * @param scene The scene the material will be use in.
  54227. */
  54228. constructor(name: string, scene: Scene);
  54229. /**
  54230. * Return the currrent class name of the material.
  54231. */
  54232. getClassName(): string;
  54233. /**
  54234. * Makes a duplicate of the current material.
  54235. * @param name - name to use for the new material.
  54236. */
  54237. clone(name: string): PBRSpecularGlossinessMaterial;
  54238. /**
  54239. * Serialize the material to a parsable JSON object.
  54240. */
  54241. serialize(): any;
  54242. /**
  54243. * Parses a JSON object correponding to the serialize function.
  54244. */
  54245. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  54246. }
  54247. }
  54248. declare module BABYLON {
  54249. /**
  54250. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  54251. * It can help converting any input color in a desired output one. This can then be used to create effects
  54252. * from sepia, black and white to sixties or futuristic rendering...
  54253. *
  54254. * The only supported format is currently 3dl.
  54255. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  54256. */
  54257. export class ColorGradingTexture extends BaseTexture {
  54258. /**
  54259. * The current texture matrix. (will always be identity in color grading texture)
  54260. */
  54261. private _textureMatrix;
  54262. /**
  54263. * The texture URL.
  54264. */
  54265. url: string;
  54266. /**
  54267. * Empty line regex stored for GC.
  54268. */
  54269. private static _noneEmptyLineRegex;
  54270. private _engine;
  54271. /**
  54272. * Instantiates a ColorGradingTexture from the following parameters.
  54273. *
  54274. * @param url The location of the color gradind data (currently only supporting 3dl)
  54275. * @param scene The scene the texture will be used in
  54276. */
  54277. constructor(url: string, scene: Scene);
  54278. /**
  54279. * Returns the texture matrix used in most of the material.
  54280. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  54281. */
  54282. getTextureMatrix(): Matrix;
  54283. /**
  54284. * Occurs when the file being loaded is a .3dl LUT file.
  54285. */
  54286. private load3dlTexture;
  54287. /**
  54288. * Starts the loading process of the texture.
  54289. */
  54290. private loadTexture;
  54291. /**
  54292. * Clones the color gradind texture.
  54293. */
  54294. clone(): ColorGradingTexture;
  54295. /**
  54296. * Called during delayed load for textures.
  54297. */
  54298. delayLoad(): void;
  54299. /**
  54300. * Parses a color grading texture serialized by Babylon.
  54301. * @param parsedTexture The texture information being parsedTexture
  54302. * @param scene The scene to load the texture in
  54303. * @param rootUrl The root url of the data assets to load
  54304. * @return A color gradind texture
  54305. */
  54306. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  54307. /**
  54308. * Serializes the LUT texture to json format.
  54309. */
  54310. serialize(): any;
  54311. }
  54312. }
  54313. declare module BABYLON {
  54314. /**
  54315. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  54316. */
  54317. export class EquiRectangularCubeTexture extends BaseTexture {
  54318. /** The six faces of the cube. */
  54319. private static _FacesMapping;
  54320. private _noMipmap;
  54321. private _onLoad;
  54322. private _onError;
  54323. /** The size of the cubemap. */
  54324. private _size;
  54325. /** The buffer of the image. */
  54326. private _buffer;
  54327. /** The width of the input image. */
  54328. private _width;
  54329. /** The height of the input image. */
  54330. private _height;
  54331. /** The URL to the image. */
  54332. url: string;
  54333. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  54334. coordinatesMode: number;
  54335. /**
  54336. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  54337. * @param url The location of the image
  54338. * @param scene The scene the texture will be used in
  54339. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  54340. * @param noMipmap Forces to not generate the mipmap if true
  54341. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  54342. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  54343. * @param onLoad — defines a callback called when texture is loaded
  54344. * @param onError — defines a callback called if there is an error
  54345. */
  54346. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  54347. /**
  54348. * Load the image data, by putting the image on a canvas and extracting its buffer.
  54349. */
  54350. private loadImage;
  54351. /**
  54352. * Convert the image buffer into a cubemap and create a CubeTexture.
  54353. */
  54354. private loadTexture;
  54355. /**
  54356. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  54357. * @param buffer The ArrayBuffer that should be converted.
  54358. * @returns The buffer as Float32Array.
  54359. */
  54360. private getFloat32ArrayFromArrayBuffer;
  54361. /**
  54362. * Get the current class name of the texture useful for serialization or dynamic coding.
  54363. * @returns "EquiRectangularCubeTexture"
  54364. */
  54365. getClassName(): string;
  54366. /**
  54367. * Create a clone of the current EquiRectangularCubeTexture and return it.
  54368. * @returns A clone of the current EquiRectangularCubeTexture.
  54369. */
  54370. clone(): EquiRectangularCubeTexture;
  54371. }
  54372. }
  54373. declare module BABYLON {
  54374. /**
  54375. * Based on jsTGALoader - Javascript loader for TGA file
  54376. * By Vincent Thibault
  54377. * @see http://blog.robrowser.com/javascript-tga-loader.html
  54378. */
  54379. export class TGATools {
  54380. private static _TYPE_INDEXED;
  54381. private static _TYPE_RGB;
  54382. private static _TYPE_GREY;
  54383. private static _TYPE_RLE_INDEXED;
  54384. private static _TYPE_RLE_RGB;
  54385. private static _TYPE_RLE_GREY;
  54386. private static _ORIGIN_MASK;
  54387. private static _ORIGIN_SHIFT;
  54388. private static _ORIGIN_BL;
  54389. private static _ORIGIN_BR;
  54390. private static _ORIGIN_UL;
  54391. private static _ORIGIN_UR;
  54392. /**
  54393. * Gets the header of a TGA file
  54394. * @param data defines the TGA data
  54395. * @returns the header
  54396. */
  54397. static GetTGAHeader(data: Uint8Array): any;
  54398. /**
  54399. * Uploads TGA content to a Babylon Texture
  54400. * @hidden
  54401. */
  54402. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  54403. /** @hidden */
  54404. 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;
  54405. /** @hidden */
  54406. 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;
  54407. /** @hidden */
  54408. 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;
  54409. /** @hidden */
  54410. 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;
  54411. /** @hidden */
  54412. 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;
  54413. /** @hidden */
  54414. 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;
  54415. }
  54416. }
  54417. declare module BABYLON {
  54418. /**
  54419. * Implementation of the TGA Texture Loader.
  54420. * @hidden
  54421. */
  54422. export class _TGATextureLoader implements IInternalTextureLoader {
  54423. /**
  54424. * Defines wether the loader supports cascade loading the different faces.
  54425. */
  54426. readonly supportCascades: boolean;
  54427. /**
  54428. * This returns if the loader support the current file information.
  54429. * @param extension defines the file extension of the file being loaded
  54430. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54431. * @param fallback defines the fallback internal texture if any
  54432. * @param isBase64 defines whether the texture is encoded as a base64
  54433. * @param isBuffer defines whether the texture data are stored as a buffer
  54434. * @returns true if the loader can load the specified file
  54435. */
  54436. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54437. /**
  54438. * Transform the url before loading if required.
  54439. * @param rootUrl the url of the texture
  54440. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54441. * @returns the transformed texture
  54442. */
  54443. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54444. /**
  54445. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54446. * @param rootUrl the url of the texture
  54447. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54448. * @returns the fallback texture
  54449. */
  54450. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54451. /**
  54452. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  54453. * @param data contains the texture data
  54454. * @param texture defines the BabylonJS internal texture
  54455. * @param createPolynomials will be true if polynomials have been requested
  54456. * @param onLoad defines the callback to trigger once the texture is ready
  54457. * @param onError defines the callback to trigger in case of error
  54458. */
  54459. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54460. /**
  54461. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54462. * @param data contains the texture data
  54463. * @param texture defines the BabylonJS internal texture
  54464. * @param callback defines the method to call once ready to upload
  54465. */
  54466. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54467. }
  54468. }
  54469. declare module BABYLON {
  54470. /**
  54471. * Info about the .basis files
  54472. */
  54473. class BasisFileInfo {
  54474. /**
  54475. * If the file has alpha
  54476. */
  54477. hasAlpha: boolean;
  54478. /**
  54479. * Info about each image of the basis file
  54480. */
  54481. images: Array<{
  54482. levels: Array<{
  54483. width: number;
  54484. height: number;
  54485. transcodedPixels: ArrayBufferView;
  54486. }>;
  54487. }>;
  54488. }
  54489. /**
  54490. * Result of transcoding a basis file
  54491. */
  54492. class TranscodeResult {
  54493. /**
  54494. * Info about the .basis file
  54495. */
  54496. fileInfo: BasisFileInfo;
  54497. /**
  54498. * Format to use when loading the file
  54499. */
  54500. format: number;
  54501. }
  54502. /**
  54503. * Configuration options for the Basis transcoder
  54504. */
  54505. export class BasisTranscodeConfiguration {
  54506. /**
  54507. * Supported compression formats used to determine the supported output format of the transcoder
  54508. */
  54509. supportedCompressionFormats?: {
  54510. /**
  54511. * etc1 compression format
  54512. */
  54513. etc1?: boolean;
  54514. /**
  54515. * s3tc compression format
  54516. */
  54517. s3tc?: boolean;
  54518. /**
  54519. * pvrtc compression format
  54520. */
  54521. pvrtc?: boolean;
  54522. /**
  54523. * etc2 compression format
  54524. */
  54525. etc2?: boolean;
  54526. };
  54527. /**
  54528. * If mipmap levels should be loaded for transcoded images (Default: true)
  54529. */
  54530. loadMipmapLevels?: boolean;
  54531. /**
  54532. * Index of a single image to load (Default: all images)
  54533. */
  54534. loadSingleImage?: number;
  54535. }
  54536. /**
  54537. * Used to load .Basis files
  54538. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  54539. */
  54540. export class BasisTools {
  54541. private static _IgnoreSupportedFormats;
  54542. /**
  54543. * URL to use when loading the basis transcoder
  54544. */
  54545. static JSModuleURL: string;
  54546. /**
  54547. * URL to use when loading the wasm module for the transcoder
  54548. */
  54549. static WasmModuleURL: string;
  54550. /**
  54551. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  54552. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  54553. * @returns internal format corresponding to the Basis format
  54554. */
  54555. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  54556. private static _WorkerPromise;
  54557. private static _Worker;
  54558. private static _actionId;
  54559. private static _CreateWorkerAsync;
  54560. /**
  54561. * Transcodes a loaded image file to compressed pixel data
  54562. * @param imageData image data to transcode
  54563. * @param config configuration options for the transcoding
  54564. * @returns a promise resulting in the transcoded image
  54565. */
  54566. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  54567. /**
  54568. * Loads a texture from the transcode result
  54569. * @param texture texture load to
  54570. * @param transcodeResult the result of transcoding the basis file to load from
  54571. */
  54572. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  54573. }
  54574. }
  54575. declare module BABYLON {
  54576. /**
  54577. * Loader for .basis file format
  54578. */
  54579. export class _BasisTextureLoader implements IInternalTextureLoader {
  54580. /**
  54581. * Defines whether the loader supports cascade loading the different faces.
  54582. */
  54583. readonly supportCascades: boolean;
  54584. /**
  54585. * This returns if the loader support the current file information.
  54586. * @param extension defines the file extension of the file being loaded
  54587. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54588. * @param fallback defines the fallback internal texture if any
  54589. * @param isBase64 defines whether the texture is encoded as a base64
  54590. * @param isBuffer defines whether the texture data are stored as a buffer
  54591. * @returns true if the loader can load the specified file
  54592. */
  54593. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54594. /**
  54595. * Transform the url before loading if required.
  54596. * @param rootUrl the url of the texture
  54597. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54598. * @returns the transformed texture
  54599. */
  54600. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54601. /**
  54602. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54603. * @param rootUrl the url of the texture
  54604. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54605. * @returns the fallback texture
  54606. */
  54607. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54608. /**
  54609. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  54610. * @param data contains the texture data
  54611. * @param texture defines the BabylonJS internal texture
  54612. * @param createPolynomials will be true if polynomials have been requested
  54613. * @param onLoad defines the callback to trigger once the texture is ready
  54614. * @param onError defines the callback to trigger in case of error
  54615. */
  54616. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54617. /**
  54618. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54619. * @param data contains the texture data
  54620. * @param texture defines the BabylonJS internal texture
  54621. * @param callback defines the method to call once ready to upload
  54622. */
  54623. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54624. }
  54625. }
  54626. declare module BABYLON {
  54627. /**
  54628. * 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.
  54629. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  54630. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  54631. */
  54632. export class CustomProceduralTexture extends ProceduralTexture {
  54633. private _animate;
  54634. private _time;
  54635. private _config;
  54636. private _texturePath;
  54637. /**
  54638. * Instantiates a new Custom Procedural Texture.
  54639. * 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.
  54640. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  54641. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  54642. * @param name Define the name of the texture
  54643. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  54644. * @param size Define the size of the texture to create
  54645. * @param scene Define the scene the texture belongs to
  54646. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  54647. * @param generateMipMaps Define if the texture should creates mip maps or not
  54648. */
  54649. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  54650. private _loadJson;
  54651. /**
  54652. * Is the texture ready to be used ? (rendered at least once)
  54653. * @returns true if ready, otherwise, false.
  54654. */
  54655. isReady(): boolean;
  54656. /**
  54657. * Render the texture to its associated render target.
  54658. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  54659. */
  54660. render(useCameraPostProcess?: boolean): void;
  54661. /**
  54662. * Update the list of dependant textures samplers in the shader.
  54663. */
  54664. updateTextures(): void;
  54665. /**
  54666. * Update the uniform values of the procedural texture in the shader.
  54667. */
  54668. updateShaderUniforms(): void;
  54669. /**
  54670. * Define if the texture animates or not.
  54671. */
  54672. get animate(): boolean;
  54673. set animate(value: boolean);
  54674. }
  54675. }
  54676. declare module BABYLON {
  54677. /** @hidden */
  54678. export var noisePixelShader: {
  54679. name: string;
  54680. shader: string;
  54681. };
  54682. }
  54683. declare module BABYLON {
  54684. /**
  54685. * Class used to generate noise procedural textures
  54686. */
  54687. export class NoiseProceduralTexture extends ProceduralTexture {
  54688. private _time;
  54689. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  54690. brightness: number;
  54691. /** Defines the number of octaves to process */
  54692. octaves: number;
  54693. /** Defines the level of persistence (0.8 by default) */
  54694. persistence: number;
  54695. /** Gets or sets animation speed factor (default is 1) */
  54696. animationSpeedFactor: number;
  54697. /**
  54698. * Creates a new NoiseProceduralTexture
  54699. * @param name defines the name fo the texture
  54700. * @param size defines the size of the texture (default is 256)
  54701. * @param scene defines the hosting scene
  54702. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  54703. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  54704. */
  54705. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  54706. private _updateShaderUniforms;
  54707. protected _getDefines(): string;
  54708. /** Generate the current state of the procedural texture */
  54709. render(useCameraPostProcess?: boolean): void;
  54710. /**
  54711. * Serializes this noise procedural texture
  54712. * @returns a serialized noise procedural texture object
  54713. */
  54714. serialize(): any;
  54715. /**
  54716. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  54717. * @param parsedTexture defines parsed texture data
  54718. * @param scene defines the current scene
  54719. * @param rootUrl defines the root URL containing noise procedural texture information
  54720. * @returns a parsed NoiseProceduralTexture
  54721. */
  54722. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  54723. }
  54724. }
  54725. declare module BABYLON {
  54726. /**
  54727. * Raw cube texture where the raw buffers are passed in
  54728. */
  54729. export class RawCubeTexture extends CubeTexture {
  54730. /**
  54731. * Creates a cube texture where the raw buffers are passed in.
  54732. * @param scene defines the scene the texture is attached to
  54733. * @param data defines the array of data to use to create each face
  54734. * @param size defines the size of the textures
  54735. * @param format defines the format of the data
  54736. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  54737. * @param generateMipMaps defines if the engine should generate the mip levels
  54738. * @param invertY defines if data must be stored with Y axis inverted
  54739. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  54740. * @param compression defines the compression used (null by default)
  54741. */
  54742. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  54743. /**
  54744. * Updates the raw cube texture.
  54745. * @param data defines the data to store
  54746. * @param format defines the data format
  54747. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  54748. * @param invertY defines if data must be stored with Y axis inverted
  54749. * @param compression defines the compression used (null by default)
  54750. * @param level defines which level of the texture to update
  54751. */
  54752. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  54753. /**
  54754. * Updates a raw cube texture with RGBD encoded data.
  54755. * @param data defines the array of data [mipmap][face] to use to create each face
  54756. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  54757. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  54758. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  54759. * @returns a promsie that resolves when the operation is complete
  54760. */
  54761. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  54762. /**
  54763. * Clones the raw cube texture.
  54764. * @return a new cube texture
  54765. */
  54766. clone(): CubeTexture;
  54767. /** @hidden */
  54768. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  54769. }
  54770. }
  54771. declare module BABYLON {
  54772. /**
  54773. * Class used to store 3D textures containing user data
  54774. */
  54775. export class RawTexture3D extends Texture {
  54776. /** Gets or sets the texture format to use */
  54777. format: number;
  54778. private _engine;
  54779. /**
  54780. * Create a new RawTexture3D
  54781. * @param data defines the data of the texture
  54782. * @param width defines the width of the texture
  54783. * @param height defines the height of the texture
  54784. * @param depth defines the depth of the texture
  54785. * @param format defines the texture format to use
  54786. * @param scene defines the hosting scene
  54787. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  54788. * @param invertY defines if texture must be stored with Y axis inverted
  54789. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  54790. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  54791. */
  54792. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  54793. /** Gets or sets the texture format to use */
  54794. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  54795. /**
  54796. * Update the texture with new data
  54797. * @param data defines the data to store in the texture
  54798. */
  54799. update(data: ArrayBufferView): void;
  54800. }
  54801. }
  54802. declare module BABYLON {
  54803. /**
  54804. * Class used to store 2D array textures containing user data
  54805. */
  54806. export class RawTexture2DArray extends Texture {
  54807. /** Gets or sets the texture format to use */
  54808. format: number;
  54809. private _engine;
  54810. /**
  54811. * Create a new RawTexture2DArray
  54812. * @param data defines the data of the texture
  54813. * @param width defines the width of the texture
  54814. * @param height defines the height of the texture
  54815. * @param depth defines the number of layers of the texture
  54816. * @param format defines the texture format to use
  54817. * @param scene defines the hosting scene
  54818. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  54819. * @param invertY defines if texture must be stored with Y axis inverted
  54820. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  54821. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  54822. */
  54823. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  54824. /** Gets or sets the texture format to use */
  54825. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  54826. /**
  54827. * Update the texture with new data
  54828. * @param data defines the data to store in the texture
  54829. */
  54830. update(data: ArrayBufferView): void;
  54831. }
  54832. }
  54833. declare module BABYLON {
  54834. /**
  54835. * Creates a refraction texture used by refraction channel of the standard material.
  54836. * It is like a mirror but to see through a material.
  54837. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54838. */
  54839. export class RefractionTexture extends RenderTargetTexture {
  54840. /**
  54841. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  54842. * 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.
  54843. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54844. */
  54845. refractionPlane: Plane;
  54846. /**
  54847. * Define how deep under the surface we should see.
  54848. */
  54849. depth: number;
  54850. /**
  54851. * Creates a refraction texture used by refraction channel of the standard material.
  54852. * It is like a mirror but to see through a material.
  54853. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54854. * @param name Define the texture name
  54855. * @param size Define the size of the underlying texture
  54856. * @param scene Define the scene the refraction belongs to
  54857. * @param generateMipMaps Define if we need to generate mips level for the refraction
  54858. */
  54859. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  54860. /**
  54861. * Clone the refraction texture.
  54862. * @returns the cloned texture
  54863. */
  54864. clone(): RefractionTexture;
  54865. /**
  54866. * Serialize the texture to a JSON representation you could use in Parse later on
  54867. * @returns the serialized JSON representation
  54868. */
  54869. serialize(): any;
  54870. }
  54871. }
  54872. declare module BABYLON {
  54873. /**
  54874. * Defines the options related to the creation of an HtmlElementTexture
  54875. */
  54876. export interface IHtmlElementTextureOptions {
  54877. /**
  54878. * Defines wether mip maps should be created or not.
  54879. */
  54880. generateMipMaps?: boolean;
  54881. /**
  54882. * Defines the sampling mode of the texture.
  54883. */
  54884. samplingMode?: number;
  54885. /**
  54886. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  54887. */
  54888. engine: Nullable<ThinEngine>;
  54889. /**
  54890. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  54891. */
  54892. scene: Nullable<Scene>;
  54893. }
  54894. /**
  54895. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  54896. * To be as efficient as possible depending on your constraints nothing aside the first upload
  54897. * is automatically managed.
  54898. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  54899. * in your application.
  54900. *
  54901. * As the update is not automatic, you need to call them manually.
  54902. */
  54903. export class HtmlElementTexture extends BaseTexture {
  54904. /**
  54905. * The texture URL.
  54906. */
  54907. element: HTMLVideoElement | HTMLCanvasElement;
  54908. private static readonly DefaultOptions;
  54909. private _textureMatrix;
  54910. private _engine;
  54911. private _isVideo;
  54912. private _generateMipMaps;
  54913. private _samplingMode;
  54914. /**
  54915. * Instantiates a HtmlElementTexture from the following parameters.
  54916. *
  54917. * @param name Defines the name of the texture
  54918. * @param element Defines the video or canvas the texture is filled with
  54919. * @param options Defines the other none mandatory texture creation options
  54920. */
  54921. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  54922. private _createInternalTexture;
  54923. /**
  54924. * Returns the texture matrix used in most of the material.
  54925. */
  54926. getTextureMatrix(): Matrix;
  54927. /**
  54928. * Updates the content of the texture.
  54929. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  54930. */
  54931. update(invertY?: Nullable<boolean>): void;
  54932. }
  54933. }
  54934. declare module BABYLON {
  54935. /**
  54936. * Enum used to define the target of a block
  54937. */
  54938. export enum NodeMaterialBlockTargets {
  54939. /** Vertex shader */
  54940. Vertex = 1,
  54941. /** Fragment shader */
  54942. Fragment = 2,
  54943. /** Neutral */
  54944. Neutral = 4,
  54945. /** Vertex and Fragment */
  54946. VertexAndFragment = 3
  54947. }
  54948. }
  54949. declare module BABYLON {
  54950. /**
  54951. * Defines the kind of connection point for node based material
  54952. */
  54953. export enum NodeMaterialBlockConnectionPointTypes {
  54954. /** Float */
  54955. Float = 1,
  54956. /** Int */
  54957. Int = 2,
  54958. /** Vector2 */
  54959. Vector2 = 4,
  54960. /** Vector3 */
  54961. Vector3 = 8,
  54962. /** Vector4 */
  54963. Vector4 = 16,
  54964. /** Color3 */
  54965. Color3 = 32,
  54966. /** Color4 */
  54967. Color4 = 64,
  54968. /** Matrix */
  54969. Matrix = 128,
  54970. /** Detect type based on connection */
  54971. AutoDetect = 1024,
  54972. /** Output type that will be defined by input type */
  54973. BasedOnInput = 2048
  54974. }
  54975. }
  54976. declare module BABYLON {
  54977. /**
  54978. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  54979. */
  54980. export enum NodeMaterialBlockConnectionPointMode {
  54981. /** Value is an uniform */
  54982. Uniform = 0,
  54983. /** Value is a mesh attribute */
  54984. Attribute = 1,
  54985. /** Value is a varying between vertex and fragment shaders */
  54986. Varying = 2,
  54987. /** Mode is undefined */
  54988. Undefined = 3
  54989. }
  54990. }
  54991. declare module BABYLON {
  54992. /**
  54993. * Enum used to define system values e.g. values automatically provided by the system
  54994. */
  54995. export enum NodeMaterialSystemValues {
  54996. /** World */
  54997. World = 1,
  54998. /** View */
  54999. View = 2,
  55000. /** Projection */
  55001. Projection = 3,
  55002. /** ViewProjection */
  55003. ViewProjection = 4,
  55004. /** WorldView */
  55005. WorldView = 5,
  55006. /** WorldViewProjection */
  55007. WorldViewProjection = 6,
  55008. /** CameraPosition */
  55009. CameraPosition = 7,
  55010. /** Fog Color */
  55011. FogColor = 8,
  55012. /** Delta time */
  55013. DeltaTime = 9
  55014. }
  55015. }
  55016. declare module BABYLON {
  55017. /**
  55018. * Root class for all node material optimizers
  55019. */
  55020. export class NodeMaterialOptimizer {
  55021. /**
  55022. * Function used to optimize a NodeMaterial graph
  55023. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  55024. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  55025. */
  55026. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  55027. }
  55028. }
  55029. declare module BABYLON {
  55030. /**
  55031. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  55032. */
  55033. export class TransformBlock extends NodeMaterialBlock {
  55034. /**
  55035. * Defines the value to use to complement W value to transform it to a Vector4
  55036. */
  55037. complementW: number;
  55038. /**
  55039. * Defines the value to use to complement z value to transform it to a Vector4
  55040. */
  55041. complementZ: number;
  55042. /**
  55043. * Creates a new TransformBlock
  55044. * @param name defines the block name
  55045. */
  55046. constructor(name: string);
  55047. /**
  55048. * Gets the current class name
  55049. * @returns the class name
  55050. */
  55051. getClassName(): string;
  55052. /**
  55053. * Gets the vector input
  55054. */
  55055. get vector(): NodeMaterialConnectionPoint;
  55056. /**
  55057. * Gets the output component
  55058. */
  55059. get output(): NodeMaterialConnectionPoint;
  55060. /**
  55061. * Gets the matrix transform input
  55062. */
  55063. get transform(): NodeMaterialConnectionPoint;
  55064. protected _buildBlock(state: NodeMaterialBuildState): this;
  55065. serialize(): any;
  55066. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55067. protected _dumpPropertiesCode(): string;
  55068. }
  55069. }
  55070. declare module BABYLON {
  55071. /**
  55072. * Block used to output the vertex position
  55073. */
  55074. export class VertexOutputBlock extends NodeMaterialBlock {
  55075. /**
  55076. * Creates a new VertexOutputBlock
  55077. * @param name defines the block name
  55078. */
  55079. constructor(name: string);
  55080. /**
  55081. * Gets the current class name
  55082. * @returns the class name
  55083. */
  55084. getClassName(): string;
  55085. /**
  55086. * Gets the vector input component
  55087. */
  55088. get vector(): NodeMaterialConnectionPoint;
  55089. protected _buildBlock(state: NodeMaterialBuildState): this;
  55090. }
  55091. }
  55092. declare module BABYLON {
  55093. /**
  55094. * Block used to output the final color
  55095. */
  55096. export class FragmentOutputBlock extends NodeMaterialBlock {
  55097. /**
  55098. * Create a new FragmentOutputBlock
  55099. * @param name defines the block name
  55100. */
  55101. constructor(name: string);
  55102. /**
  55103. * Gets the current class name
  55104. * @returns the class name
  55105. */
  55106. getClassName(): string;
  55107. /**
  55108. * Gets the rgba input component
  55109. */
  55110. get rgba(): NodeMaterialConnectionPoint;
  55111. /**
  55112. * Gets the rgb input component
  55113. */
  55114. get rgb(): NodeMaterialConnectionPoint;
  55115. /**
  55116. * Gets the a input component
  55117. */
  55118. get a(): NodeMaterialConnectionPoint;
  55119. protected _buildBlock(state: NodeMaterialBuildState): this;
  55120. }
  55121. }
  55122. declare module BABYLON {
  55123. /**
  55124. * Block used to read a reflection texture from a sampler
  55125. */
  55126. export class ReflectionTextureBlock extends NodeMaterialBlock {
  55127. private _define3DName;
  55128. private _defineCubicName;
  55129. private _defineExplicitName;
  55130. private _defineProjectionName;
  55131. private _defineLocalCubicName;
  55132. private _defineSphericalName;
  55133. private _definePlanarName;
  55134. private _defineEquirectangularName;
  55135. private _defineMirroredEquirectangularFixedName;
  55136. private _defineEquirectangularFixedName;
  55137. private _defineSkyboxName;
  55138. private _cubeSamplerName;
  55139. private _2DSamplerName;
  55140. private _positionUVWName;
  55141. private _directionWName;
  55142. private _reflectionCoordsName;
  55143. private _reflection2DCoordsName;
  55144. private _reflectionColorName;
  55145. private _reflectionMatrixName;
  55146. /**
  55147. * Gets or sets the texture associated with the node
  55148. */
  55149. texture: Nullable<BaseTexture>;
  55150. /**
  55151. * Create a new TextureBlock
  55152. * @param name defines the block name
  55153. */
  55154. constructor(name: string);
  55155. /**
  55156. * Gets the current class name
  55157. * @returns the class name
  55158. */
  55159. getClassName(): string;
  55160. /**
  55161. * Gets the world position input component
  55162. */
  55163. get position(): NodeMaterialConnectionPoint;
  55164. /**
  55165. * Gets the world position input component
  55166. */
  55167. get worldPosition(): NodeMaterialConnectionPoint;
  55168. /**
  55169. * Gets the world normal input component
  55170. */
  55171. get worldNormal(): NodeMaterialConnectionPoint;
  55172. /**
  55173. * Gets the world input component
  55174. */
  55175. get world(): NodeMaterialConnectionPoint;
  55176. /**
  55177. * Gets the camera (or eye) position component
  55178. */
  55179. get cameraPosition(): NodeMaterialConnectionPoint;
  55180. /**
  55181. * Gets the view input component
  55182. */
  55183. get view(): NodeMaterialConnectionPoint;
  55184. /**
  55185. * Gets the rgb output component
  55186. */
  55187. get rgb(): NodeMaterialConnectionPoint;
  55188. /**
  55189. * Gets the r output component
  55190. */
  55191. get r(): NodeMaterialConnectionPoint;
  55192. /**
  55193. * Gets the g output component
  55194. */
  55195. get g(): NodeMaterialConnectionPoint;
  55196. /**
  55197. * Gets the b output component
  55198. */
  55199. get b(): NodeMaterialConnectionPoint;
  55200. autoConfigure(material: NodeMaterial): void;
  55201. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55202. isReady(): boolean;
  55203. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55204. private _injectVertexCode;
  55205. private _writeOutput;
  55206. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55207. protected _dumpPropertiesCode(): string;
  55208. serialize(): any;
  55209. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55210. }
  55211. }
  55212. declare module BABYLON {
  55213. /**
  55214. * Interface used to configure the node material editor
  55215. */
  55216. export interface INodeMaterialEditorOptions {
  55217. /** Define the URl to load node editor script */
  55218. editorURL?: string;
  55219. }
  55220. /** @hidden */
  55221. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  55222. /** BONES */
  55223. NUM_BONE_INFLUENCERS: number;
  55224. BonesPerMesh: number;
  55225. BONETEXTURE: boolean;
  55226. /** MORPH TARGETS */
  55227. MORPHTARGETS: boolean;
  55228. MORPHTARGETS_NORMAL: boolean;
  55229. MORPHTARGETS_TANGENT: boolean;
  55230. MORPHTARGETS_UV: boolean;
  55231. NUM_MORPH_INFLUENCERS: number;
  55232. /** IMAGE PROCESSING */
  55233. IMAGEPROCESSING: boolean;
  55234. VIGNETTE: boolean;
  55235. VIGNETTEBLENDMODEMULTIPLY: boolean;
  55236. VIGNETTEBLENDMODEOPAQUE: boolean;
  55237. TONEMAPPING: boolean;
  55238. TONEMAPPING_ACES: boolean;
  55239. CONTRAST: boolean;
  55240. EXPOSURE: boolean;
  55241. COLORCURVES: boolean;
  55242. COLORGRADING: boolean;
  55243. COLORGRADING3D: boolean;
  55244. SAMPLER3DGREENDEPTH: boolean;
  55245. SAMPLER3DBGRMAP: boolean;
  55246. IMAGEPROCESSINGPOSTPROCESS: boolean;
  55247. /** MISC. */
  55248. BUMPDIRECTUV: number;
  55249. constructor();
  55250. setValue(name: string, value: boolean): void;
  55251. }
  55252. /**
  55253. * Class used to configure NodeMaterial
  55254. */
  55255. export interface INodeMaterialOptions {
  55256. /**
  55257. * Defines if blocks should emit comments
  55258. */
  55259. emitComments: boolean;
  55260. }
  55261. /**
  55262. * Class used to create a node based material built by assembling shader blocks
  55263. */
  55264. export class NodeMaterial extends PushMaterial {
  55265. private static _BuildIdGenerator;
  55266. private _options;
  55267. private _vertexCompilationState;
  55268. private _fragmentCompilationState;
  55269. private _sharedData;
  55270. private _buildId;
  55271. private _buildWasSuccessful;
  55272. private _cachedWorldViewMatrix;
  55273. private _cachedWorldViewProjectionMatrix;
  55274. private _optimizers;
  55275. private _animationFrame;
  55276. /** Define the URl to load node editor script */
  55277. static EditorURL: string;
  55278. private BJSNODEMATERIALEDITOR;
  55279. /** Get the inspector from bundle or global */
  55280. private _getGlobalNodeMaterialEditor;
  55281. /**
  55282. * Gets or sets data used by visual editor
  55283. * @see https://nme.babylonjs.com
  55284. */
  55285. editorData: any;
  55286. /**
  55287. * 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)
  55288. */
  55289. ignoreAlpha: boolean;
  55290. /**
  55291. * Defines the maximum number of lights that can be used in the material
  55292. */
  55293. maxSimultaneousLights: number;
  55294. /**
  55295. * Observable raised when the material is built
  55296. */
  55297. onBuildObservable: Observable<NodeMaterial>;
  55298. /**
  55299. * Gets or sets the root nodes of the material vertex shader
  55300. */
  55301. _vertexOutputNodes: NodeMaterialBlock[];
  55302. /**
  55303. * Gets or sets the root nodes of the material fragment (pixel) shader
  55304. */
  55305. _fragmentOutputNodes: NodeMaterialBlock[];
  55306. /** Gets or sets options to control the node material overall behavior */
  55307. get options(): INodeMaterialOptions;
  55308. set options(options: INodeMaterialOptions);
  55309. /**
  55310. * Default configuration related to image processing available in the standard Material.
  55311. */
  55312. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  55313. /**
  55314. * Gets the image processing configuration used either in this material.
  55315. */
  55316. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  55317. /**
  55318. * Sets the Default image processing configuration used either in the this material.
  55319. *
  55320. * If sets to null, the scene one is in use.
  55321. */
  55322. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  55323. /**
  55324. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  55325. */
  55326. attachedBlocks: NodeMaterialBlock[];
  55327. /**
  55328. * Create a new node based material
  55329. * @param name defines the material name
  55330. * @param scene defines the hosting scene
  55331. * @param options defines creation option
  55332. */
  55333. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  55334. /**
  55335. * Gets the current class name of the material e.g. "NodeMaterial"
  55336. * @returns the class name
  55337. */
  55338. getClassName(): string;
  55339. /**
  55340. * Keep track of the image processing observer to allow dispose and replace.
  55341. */
  55342. private _imageProcessingObserver;
  55343. /**
  55344. * Attaches a new image processing configuration to the Standard Material.
  55345. * @param configuration
  55346. */
  55347. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  55348. /**
  55349. * Get a block by its name
  55350. * @param name defines the name of the block to retrieve
  55351. * @returns the required block or null if not found
  55352. */
  55353. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  55354. /**
  55355. * Get a block by its name
  55356. * @param predicate defines the predicate used to find the good candidate
  55357. * @returns the required block or null if not found
  55358. */
  55359. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  55360. /**
  55361. * Get an input block by its name
  55362. * @param predicate defines the predicate used to find the good candidate
  55363. * @returns the required input block or null if not found
  55364. */
  55365. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  55366. /**
  55367. * Gets the list of input blocks attached to this material
  55368. * @returns an array of InputBlocks
  55369. */
  55370. getInputBlocks(): InputBlock[];
  55371. /**
  55372. * Adds a new optimizer to the list of optimizers
  55373. * @param optimizer defines the optimizers to add
  55374. * @returns the current material
  55375. */
  55376. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  55377. /**
  55378. * Remove an optimizer from the list of optimizers
  55379. * @param optimizer defines the optimizers to remove
  55380. * @returns the current material
  55381. */
  55382. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  55383. /**
  55384. * Add a new block to the list of output nodes
  55385. * @param node defines the node to add
  55386. * @returns the current material
  55387. */
  55388. addOutputNode(node: NodeMaterialBlock): this;
  55389. /**
  55390. * Remove a block from the list of root nodes
  55391. * @param node defines the node to remove
  55392. * @returns the current material
  55393. */
  55394. removeOutputNode(node: NodeMaterialBlock): this;
  55395. private _addVertexOutputNode;
  55396. private _removeVertexOutputNode;
  55397. private _addFragmentOutputNode;
  55398. private _removeFragmentOutputNode;
  55399. /**
  55400. * Specifies if the material will require alpha blending
  55401. * @returns a boolean specifying if alpha blending is needed
  55402. */
  55403. needAlphaBlending(): boolean;
  55404. /**
  55405. * Specifies if this material should be rendered in alpha test mode
  55406. * @returns a boolean specifying if an alpha test is needed.
  55407. */
  55408. needAlphaTesting(): boolean;
  55409. private _initializeBlock;
  55410. private _resetDualBlocks;
  55411. /**
  55412. * Remove a block from the current node material
  55413. * @param block defines the block to remove
  55414. */
  55415. removeBlock(block: NodeMaterialBlock): void;
  55416. /**
  55417. * Build the material and generates the inner effect
  55418. * @param verbose defines if the build should log activity
  55419. */
  55420. build(verbose?: boolean): void;
  55421. /**
  55422. * Runs an otpimization phase to try to improve the shader code
  55423. */
  55424. optimize(): void;
  55425. private _prepareDefinesForAttributes;
  55426. /**
  55427. * Get if the submesh is ready to be used and all its information available.
  55428. * Child classes can use it to update shaders
  55429. * @param mesh defines the mesh to check
  55430. * @param subMesh defines which submesh to check
  55431. * @param useInstances specifies that instances should be used
  55432. * @returns a boolean indicating that the submesh is ready or not
  55433. */
  55434. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  55435. /**
  55436. * Get a string representing the shaders built by the current node graph
  55437. */
  55438. get compiledShaders(): string;
  55439. /**
  55440. * Binds the world matrix to the material
  55441. * @param world defines the world transformation matrix
  55442. */
  55443. bindOnlyWorldMatrix(world: Matrix): void;
  55444. /**
  55445. * Binds the submesh to this material by preparing the effect and shader to draw
  55446. * @param world defines the world transformation matrix
  55447. * @param mesh defines the mesh containing the submesh
  55448. * @param subMesh defines the submesh to bind the material to
  55449. */
  55450. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  55451. /**
  55452. * Gets the active textures from the material
  55453. * @returns an array of textures
  55454. */
  55455. getActiveTextures(): BaseTexture[];
  55456. /**
  55457. * Gets the list of texture blocks
  55458. * @returns an array of texture blocks
  55459. */
  55460. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  55461. /**
  55462. * Specifies if the material uses a texture
  55463. * @param texture defines the texture to check against the material
  55464. * @returns a boolean specifying if the material uses the texture
  55465. */
  55466. hasTexture(texture: BaseTexture): boolean;
  55467. /**
  55468. * Disposes the material
  55469. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  55470. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  55471. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  55472. */
  55473. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  55474. /** Creates the node editor window. */
  55475. private _createNodeEditor;
  55476. /**
  55477. * Launch the node material editor
  55478. * @param config Define the configuration of the editor
  55479. * @return a promise fulfilled when the node editor is visible
  55480. */
  55481. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  55482. /**
  55483. * Clear the current material
  55484. */
  55485. clear(): void;
  55486. /**
  55487. * Clear the current material and set it to a default state
  55488. */
  55489. setToDefault(): void;
  55490. /**
  55491. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  55492. * @param url defines the url to load from
  55493. * @returns a promise that will fullfil when the material is fully loaded
  55494. */
  55495. loadAsync(url: string): Promise<void>;
  55496. private _gatherBlocks;
  55497. /**
  55498. * Generate a string containing the code declaration required to create an equivalent of this material
  55499. * @returns a string
  55500. */
  55501. generateCode(): string;
  55502. /**
  55503. * Serializes this material in a JSON representation
  55504. * @returns the serialized material object
  55505. */
  55506. serialize(): any;
  55507. private _restoreConnections;
  55508. /**
  55509. * Clear the current graph and load a new one from a serialization object
  55510. * @param source defines the JSON representation of the material
  55511. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  55512. */
  55513. loadFromSerialization(source: any, rootUrl?: string): void;
  55514. /**
  55515. * Creates a node material from parsed material data
  55516. * @param source defines the JSON representation of the material
  55517. * @param scene defines the hosting scene
  55518. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  55519. * @returns a new node material
  55520. */
  55521. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  55522. /**
  55523. * Creates a new node material set to default basic configuration
  55524. * @param name defines the name of the material
  55525. * @param scene defines the hosting scene
  55526. * @returns a new NodeMaterial
  55527. */
  55528. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  55529. }
  55530. }
  55531. declare module BABYLON {
  55532. /**
  55533. * Block used to read a texture from a sampler
  55534. */
  55535. export class TextureBlock extends NodeMaterialBlock {
  55536. private _defineName;
  55537. private _linearDefineName;
  55538. private _tempTextureRead;
  55539. private _samplerName;
  55540. private _transformedUVName;
  55541. private _textureTransformName;
  55542. private _textureInfoName;
  55543. private _mainUVName;
  55544. private _mainUVDefineName;
  55545. /**
  55546. * Gets or sets the texture associated with the node
  55547. */
  55548. texture: Nullable<Texture>;
  55549. /**
  55550. * Create a new TextureBlock
  55551. * @param name defines the block name
  55552. */
  55553. constructor(name: string);
  55554. /**
  55555. * Gets the current class name
  55556. * @returns the class name
  55557. */
  55558. getClassName(): string;
  55559. /**
  55560. * Gets the uv input component
  55561. */
  55562. get uv(): NodeMaterialConnectionPoint;
  55563. /**
  55564. * Gets the rgba output component
  55565. */
  55566. get rgba(): NodeMaterialConnectionPoint;
  55567. /**
  55568. * Gets the rgb output component
  55569. */
  55570. get rgb(): NodeMaterialConnectionPoint;
  55571. /**
  55572. * Gets the r output component
  55573. */
  55574. get r(): NodeMaterialConnectionPoint;
  55575. /**
  55576. * Gets the g output component
  55577. */
  55578. get g(): NodeMaterialConnectionPoint;
  55579. /**
  55580. * Gets the b output component
  55581. */
  55582. get b(): NodeMaterialConnectionPoint;
  55583. /**
  55584. * Gets the a output component
  55585. */
  55586. get a(): NodeMaterialConnectionPoint;
  55587. get target(): NodeMaterialBlockTargets;
  55588. autoConfigure(material: NodeMaterial): void;
  55589. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55590. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55591. private _getTextureBase;
  55592. isReady(): boolean;
  55593. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55594. private get _isMixed();
  55595. private _injectVertexCode;
  55596. private _writeTextureRead;
  55597. private _writeOutput;
  55598. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55599. protected _dumpPropertiesCode(): string;
  55600. serialize(): any;
  55601. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55602. }
  55603. }
  55604. declare module BABYLON {
  55605. /**
  55606. * Class used to store shared data between 2 NodeMaterialBuildState
  55607. */
  55608. export class NodeMaterialBuildStateSharedData {
  55609. /**
  55610. * Gets the list of emitted varyings
  55611. */
  55612. temps: string[];
  55613. /**
  55614. * Gets the list of emitted varyings
  55615. */
  55616. varyings: string[];
  55617. /**
  55618. * Gets the varying declaration string
  55619. */
  55620. varyingDeclaration: string;
  55621. /**
  55622. * Input blocks
  55623. */
  55624. inputBlocks: InputBlock[];
  55625. /**
  55626. * Input blocks
  55627. */
  55628. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  55629. /**
  55630. * Bindable blocks (Blocks that need to set data to the effect)
  55631. */
  55632. bindableBlocks: NodeMaterialBlock[];
  55633. /**
  55634. * List of blocks that can provide a compilation fallback
  55635. */
  55636. blocksWithFallbacks: NodeMaterialBlock[];
  55637. /**
  55638. * List of blocks that can provide a define update
  55639. */
  55640. blocksWithDefines: NodeMaterialBlock[];
  55641. /**
  55642. * List of blocks that can provide a repeatable content
  55643. */
  55644. repeatableContentBlocks: NodeMaterialBlock[];
  55645. /**
  55646. * List of blocks that can provide a dynamic list of uniforms
  55647. */
  55648. dynamicUniformBlocks: NodeMaterialBlock[];
  55649. /**
  55650. * List of blocks that can block the isReady function for the material
  55651. */
  55652. blockingBlocks: NodeMaterialBlock[];
  55653. /**
  55654. * Gets the list of animated inputs
  55655. */
  55656. animatedInputs: InputBlock[];
  55657. /**
  55658. * Build Id used to avoid multiple recompilations
  55659. */
  55660. buildId: number;
  55661. /** List of emitted variables */
  55662. variableNames: {
  55663. [key: string]: number;
  55664. };
  55665. /** List of emitted defines */
  55666. defineNames: {
  55667. [key: string]: number;
  55668. };
  55669. /** Should emit comments? */
  55670. emitComments: boolean;
  55671. /** Emit build activity */
  55672. verbose: boolean;
  55673. /** Gets or sets the hosting scene */
  55674. scene: Scene;
  55675. /**
  55676. * Gets the compilation hints emitted at compilation time
  55677. */
  55678. hints: {
  55679. needWorldViewMatrix: boolean;
  55680. needWorldViewProjectionMatrix: boolean;
  55681. needAlphaBlending: boolean;
  55682. needAlphaTesting: boolean;
  55683. };
  55684. /**
  55685. * List of compilation checks
  55686. */
  55687. checks: {
  55688. emitVertex: boolean;
  55689. emitFragment: boolean;
  55690. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  55691. };
  55692. /** Creates a new shared data */
  55693. constructor();
  55694. /**
  55695. * Emits console errors and exceptions if there is a failing check
  55696. */
  55697. emitErrors(): void;
  55698. }
  55699. }
  55700. declare module BABYLON {
  55701. /**
  55702. * Class used to store node based material build state
  55703. */
  55704. export class NodeMaterialBuildState {
  55705. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  55706. supportUniformBuffers: boolean;
  55707. /**
  55708. * Gets the list of emitted attributes
  55709. */
  55710. attributes: string[];
  55711. /**
  55712. * Gets the list of emitted uniforms
  55713. */
  55714. uniforms: string[];
  55715. /**
  55716. * Gets the list of emitted constants
  55717. */
  55718. constants: string[];
  55719. /**
  55720. * Gets the list of emitted samplers
  55721. */
  55722. samplers: string[];
  55723. /**
  55724. * Gets the list of emitted functions
  55725. */
  55726. functions: {
  55727. [key: string]: string;
  55728. };
  55729. /**
  55730. * Gets the list of emitted extensions
  55731. */
  55732. extensions: {
  55733. [key: string]: string;
  55734. };
  55735. /**
  55736. * Gets the target of the compilation state
  55737. */
  55738. target: NodeMaterialBlockTargets;
  55739. /**
  55740. * Gets the list of emitted counters
  55741. */
  55742. counters: {
  55743. [key: string]: number;
  55744. };
  55745. /**
  55746. * Shared data between multiple NodeMaterialBuildState instances
  55747. */
  55748. sharedData: NodeMaterialBuildStateSharedData;
  55749. /** @hidden */
  55750. _vertexState: NodeMaterialBuildState;
  55751. /** @hidden */
  55752. _attributeDeclaration: string;
  55753. /** @hidden */
  55754. _uniformDeclaration: string;
  55755. /** @hidden */
  55756. _constantDeclaration: string;
  55757. /** @hidden */
  55758. _samplerDeclaration: string;
  55759. /** @hidden */
  55760. _varyingTransfer: string;
  55761. private _repeatableContentAnchorIndex;
  55762. /** @hidden */
  55763. _builtCompilationString: string;
  55764. /**
  55765. * Gets the emitted compilation strings
  55766. */
  55767. compilationString: string;
  55768. /**
  55769. * Finalize the compilation strings
  55770. * @param state defines the current compilation state
  55771. */
  55772. finalize(state: NodeMaterialBuildState): void;
  55773. /** @hidden */
  55774. get _repeatableContentAnchor(): string;
  55775. /** @hidden */
  55776. _getFreeVariableName(prefix: string): string;
  55777. /** @hidden */
  55778. _getFreeDefineName(prefix: string): string;
  55779. /** @hidden */
  55780. _excludeVariableName(name: string): void;
  55781. /** @hidden */
  55782. _emit2DSampler(name: string): void;
  55783. /** @hidden */
  55784. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  55785. /** @hidden */
  55786. _emitExtension(name: string, extension: string): void;
  55787. /** @hidden */
  55788. _emitFunction(name: string, code: string, comments: string): void;
  55789. /** @hidden */
  55790. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  55791. replaceStrings?: {
  55792. search: RegExp;
  55793. replace: string;
  55794. }[];
  55795. repeatKey?: string;
  55796. }): string;
  55797. /** @hidden */
  55798. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  55799. repeatKey?: string;
  55800. removeAttributes?: boolean;
  55801. removeUniforms?: boolean;
  55802. removeVaryings?: boolean;
  55803. removeIfDef?: boolean;
  55804. replaceStrings?: {
  55805. search: RegExp;
  55806. replace: string;
  55807. }[];
  55808. }, storeKey?: string): void;
  55809. /** @hidden */
  55810. _registerTempVariable(name: string): boolean;
  55811. /** @hidden */
  55812. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  55813. /** @hidden */
  55814. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  55815. /** @hidden */
  55816. _emitFloat(value: number): string;
  55817. }
  55818. }
  55819. declare module BABYLON {
  55820. /**
  55821. * Defines a block that can be used inside a node based material
  55822. */
  55823. export class NodeMaterialBlock {
  55824. private _buildId;
  55825. private _buildTarget;
  55826. private _target;
  55827. private _isFinalMerger;
  55828. private _isInput;
  55829. protected _isUnique: boolean;
  55830. /** @hidden */
  55831. _codeVariableName: string;
  55832. /** @hidden */
  55833. _inputs: NodeMaterialConnectionPoint[];
  55834. /** @hidden */
  55835. _outputs: NodeMaterialConnectionPoint[];
  55836. /** @hidden */
  55837. _preparationId: number;
  55838. /**
  55839. * Gets or sets the name of the block
  55840. */
  55841. name: string;
  55842. /**
  55843. * Gets or sets the unique id of the node
  55844. */
  55845. uniqueId: number;
  55846. /**
  55847. * Gets or sets the comments associated with this block
  55848. */
  55849. comments: string;
  55850. /**
  55851. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  55852. */
  55853. get isUnique(): boolean;
  55854. /**
  55855. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  55856. */
  55857. get isFinalMerger(): boolean;
  55858. /**
  55859. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  55860. */
  55861. get isInput(): boolean;
  55862. /**
  55863. * Gets or sets the build Id
  55864. */
  55865. get buildId(): number;
  55866. set buildId(value: number);
  55867. /**
  55868. * Gets or sets the target of the block
  55869. */
  55870. get target(): NodeMaterialBlockTargets;
  55871. set target(value: NodeMaterialBlockTargets);
  55872. /**
  55873. * Gets the list of input points
  55874. */
  55875. get inputs(): NodeMaterialConnectionPoint[];
  55876. /** Gets the list of output points */
  55877. get outputs(): NodeMaterialConnectionPoint[];
  55878. /**
  55879. * Find an input by its name
  55880. * @param name defines the name of the input to look for
  55881. * @returns the input or null if not found
  55882. */
  55883. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  55884. /**
  55885. * Find an output by its name
  55886. * @param name defines the name of the outputto look for
  55887. * @returns the output or null if not found
  55888. */
  55889. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  55890. /**
  55891. * Creates a new NodeMaterialBlock
  55892. * @param name defines the block name
  55893. * @param target defines the target of that block (Vertex by default)
  55894. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  55895. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  55896. */
  55897. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  55898. /**
  55899. * Initialize the block and prepare the context for build
  55900. * @param state defines the state that will be used for the build
  55901. */
  55902. initialize(state: NodeMaterialBuildState): void;
  55903. /**
  55904. * Bind data to effect. Will only be called for blocks with isBindable === true
  55905. * @param effect defines the effect to bind data to
  55906. * @param nodeMaterial defines the hosting NodeMaterial
  55907. * @param mesh defines the mesh that will be rendered
  55908. */
  55909. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55910. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  55911. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  55912. protected _writeFloat(value: number): string;
  55913. /**
  55914. * Gets the current class name e.g. "NodeMaterialBlock"
  55915. * @returns the class name
  55916. */
  55917. getClassName(): string;
  55918. /**
  55919. * Register a new input. Must be called inside a block constructor
  55920. * @param name defines the connection point name
  55921. * @param type defines the connection point type
  55922. * @param isOptional defines a boolean indicating that this input can be omitted
  55923. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  55924. * @returns the current block
  55925. */
  55926. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  55927. /**
  55928. * Register a new output. Must be called inside a block constructor
  55929. * @param name defines the connection point name
  55930. * @param type defines the connection point type
  55931. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  55932. * @returns the current block
  55933. */
  55934. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  55935. /**
  55936. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  55937. * @param forOutput defines an optional connection point to check compatibility with
  55938. * @returns the first available input or null
  55939. */
  55940. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  55941. /**
  55942. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  55943. * @param forBlock defines an optional block to check compatibility with
  55944. * @returns the first available input or null
  55945. */
  55946. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  55947. /**
  55948. * Gets the sibling of the given output
  55949. * @param current defines the current output
  55950. * @returns the next output in the list or null
  55951. */
  55952. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  55953. /**
  55954. * Connect current block with another block
  55955. * @param other defines the block to connect with
  55956. * @param options define the various options to help pick the right connections
  55957. * @returns the current block
  55958. */
  55959. connectTo(other: NodeMaterialBlock, options?: {
  55960. input?: string;
  55961. output?: string;
  55962. outputSwizzle?: string;
  55963. }): this | undefined;
  55964. protected _buildBlock(state: NodeMaterialBuildState): void;
  55965. /**
  55966. * Add uniforms, samplers and uniform buffers at compilation time
  55967. * @param state defines the state to update
  55968. * @param nodeMaterial defines the node material requesting the update
  55969. * @param defines defines the material defines to update
  55970. * @param uniformBuffers defines the list of uniform buffer names
  55971. */
  55972. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  55973. /**
  55974. * Add potential fallbacks if shader compilation fails
  55975. * @param mesh defines the mesh to be rendered
  55976. * @param fallbacks defines the current prioritized list of fallbacks
  55977. */
  55978. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  55979. /**
  55980. * Initialize defines for shader compilation
  55981. * @param mesh defines the mesh to be rendered
  55982. * @param nodeMaterial defines the node material requesting the update
  55983. * @param defines defines the material defines to update
  55984. * @param useInstances specifies that instances should be used
  55985. */
  55986. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55987. /**
  55988. * Update defines for shader compilation
  55989. * @param mesh defines the mesh to be rendered
  55990. * @param nodeMaterial defines the node material requesting the update
  55991. * @param defines defines the material defines to update
  55992. * @param useInstances specifies that instances should be used
  55993. */
  55994. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55995. /**
  55996. * Lets the block try to connect some inputs automatically
  55997. * @param material defines the hosting NodeMaterial
  55998. */
  55999. autoConfigure(material: NodeMaterial): void;
  56000. /**
  56001. * Function called when a block is declared as repeatable content generator
  56002. * @param vertexShaderState defines the current compilation state for the vertex shader
  56003. * @param fragmentShaderState defines the current compilation state for the fragment shader
  56004. * @param mesh defines the mesh to be rendered
  56005. * @param defines defines the material defines to update
  56006. */
  56007. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  56008. /**
  56009. * Checks if the block is ready
  56010. * @param mesh defines the mesh to be rendered
  56011. * @param nodeMaterial defines the node material requesting the update
  56012. * @param defines defines the material defines to update
  56013. * @param useInstances specifies that instances should be used
  56014. * @returns true if the block is ready
  56015. */
  56016. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  56017. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  56018. private _processBuild;
  56019. /**
  56020. * Compile the current node and generate the shader code
  56021. * @param state defines the current compilation state (uniforms, samplers, current string)
  56022. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  56023. * @returns true if already built
  56024. */
  56025. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  56026. protected _inputRename(name: string): string;
  56027. protected _outputRename(name: string): string;
  56028. protected _dumpPropertiesCode(): string;
  56029. /** @hidden */
  56030. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  56031. /** @hidden */
  56032. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  56033. /**
  56034. * Clone the current block to a new identical block
  56035. * @param scene defines the hosting scene
  56036. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  56037. * @returns a copy of the current block
  56038. */
  56039. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  56040. /**
  56041. * Serializes this block in a JSON representation
  56042. * @returns the serialized block object
  56043. */
  56044. serialize(): any;
  56045. /** @hidden */
  56046. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56047. /**
  56048. * Release resources
  56049. */
  56050. dispose(): void;
  56051. }
  56052. }
  56053. declare module BABYLON {
  56054. /**
  56055. * Enum defining the type of animations supported by InputBlock
  56056. */
  56057. export enum AnimatedInputBlockTypes {
  56058. /** No animation */
  56059. None = 0,
  56060. /** Time based animation. Will only work for floats */
  56061. Time = 1
  56062. }
  56063. }
  56064. declare module BABYLON {
  56065. /**
  56066. * Block used to expose an input value
  56067. */
  56068. export class InputBlock extends NodeMaterialBlock {
  56069. private _mode;
  56070. private _associatedVariableName;
  56071. private _storedValue;
  56072. private _valueCallback;
  56073. private _type;
  56074. private _animationType;
  56075. /** Gets or set a value used to limit the range of float values */
  56076. min: number;
  56077. /** Gets or set a value used to limit the range of float values */
  56078. max: number;
  56079. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  56080. matrixMode: number;
  56081. /** @hidden */
  56082. _systemValue: Nullable<NodeMaterialSystemValues>;
  56083. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  56084. visibleInInspector: boolean;
  56085. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  56086. isConstant: boolean;
  56087. /** Gets or sets the group to use to display this block in the Inspector */
  56088. groupInInspector: string;
  56089. /**
  56090. * Gets or sets the connection point type (default is float)
  56091. */
  56092. get type(): NodeMaterialBlockConnectionPointTypes;
  56093. /**
  56094. * Creates a new InputBlock
  56095. * @param name defines the block name
  56096. * @param target defines the target of that block (Vertex by default)
  56097. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  56098. */
  56099. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  56100. /**
  56101. * Gets the output component
  56102. */
  56103. get output(): NodeMaterialConnectionPoint;
  56104. /**
  56105. * Set the source of this connection point to a vertex attribute
  56106. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  56107. * @returns the current connection point
  56108. */
  56109. setAsAttribute(attributeName?: string): InputBlock;
  56110. /**
  56111. * Set the source of this connection point to a system value
  56112. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  56113. * @returns the current connection point
  56114. */
  56115. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  56116. /**
  56117. * Gets or sets the value of that point.
  56118. * Please note that this value will be ignored if valueCallback is defined
  56119. */
  56120. get value(): any;
  56121. set value(value: any);
  56122. /**
  56123. * Gets or sets a callback used to get the value of that point.
  56124. * Please note that setting this value will force the connection point to ignore the value property
  56125. */
  56126. get valueCallback(): () => any;
  56127. set valueCallback(value: () => any);
  56128. /**
  56129. * Gets or sets the associated variable name in the shader
  56130. */
  56131. get associatedVariableName(): string;
  56132. set associatedVariableName(value: string);
  56133. /** Gets or sets the type of animation applied to the input */
  56134. get animationType(): AnimatedInputBlockTypes;
  56135. set animationType(value: AnimatedInputBlockTypes);
  56136. /**
  56137. * Gets a boolean indicating that this connection point not defined yet
  56138. */
  56139. get isUndefined(): boolean;
  56140. /**
  56141. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  56142. * In this case the connection point name must be the name of the uniform to use.
  56143. * Can only be set on inputs
  56144. */
  56145. get isUniform(): boolean;
  56146. set isUniform(value: boolean);
  56147. /**
  56148. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  56149. * In this case the connection point name must be the name of the attribute to use
  56150. * Can only be set on inputs
  56151. */
  56152. get isAttribute(): boolean;
  56153. set isAttribute(value: boolean);
  56154. /**
  56155. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  56156. * Can only be set on exit points
  56157. */
  56158. get isVarying(): boolean;
  56159. set isVarying(value: boolean);
  56160. /**
  56161. * Gets a boolean indicating that the current connection point is a system value
  56162. */
  56163. get isSystemValue(): boolean;
  56164. /**
  56165. * Gets or sets the current well known value or null if not defined as a system value
  56166. */
  56167. get systemValue(): Nullable<NodeMaterialSystemValues>;
  56168. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  56169. /**
  56170. * Gets the current class name
  56171. * @returns the class name
  56172. */
  56173. getClassName(): string;
  56174. /**
  56175. * Animate the input if animationType !== None
  56176. * @param scene defines the rendering scene
  56177. */
  56178. animate(scene: Scene): void;
  56179. private _emitDefine;
  56180. initialize(state: NodeMaterialBuildState): void;
  56181. /**
  56182. * Set the input block to its default value (based on its type)
  56183. */
  56184. setDefaultValue(): void;
  56185. private _emitConstant;
  56186. private _emit;
  56187. /** @hidden */
  56188. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  56189. /** @hidden */
  56190. _transmit(effect: Effect, scene: Scene): void;
  56191. protected _buildBlock(state: NodeMaterialBuildState): void;
  56192. protected _dumpPropertiesCode(): string;
  56193. serialize(): any;
  56194. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56195. }
  56196. }
  56197. declare module BABYLON {
  56198. /**
  56199. * Enum used to define the compatibility state between two connection points
  56200. */
  56201. export enum NodeMaterialConnectionPointCompatibilityStates {
  56202. /** Points are compatibles */
  56203. Compatible = 0,
  56204. /** Points are incompatible because of their types */
  56205. TypeIncompatible = 1,
  56206. /** Points are incompatible because of their targets (vertex vs fragment) */
  56207. TargetIncompatible = 2
  56208. }
  56209. /**
  56210. * Defines the direction of a connection point
  56211. */
  56212. export enum NodeMaterialConnectionPointDirection {
  56213. /** Input */
  56214. Input = 0,
  56215. /** Output */
  56216. Output = 1
  56217. }
  56218. /**
  56219. * Defines a connection point for a block
  56220. */
  56221. export class NodeMaterialConnectionPoint {
  56222. /** @hidden */
  56223. _ownerBlock: NodeMaterialBlock;
  56224. /** @hidden */
  56225. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  56226. private _endpoints;
  56227. private _associatedVariableName;
  56228. private _direction;
  56229. /** @hidden */
  56230. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  56231. /** @hidden */
  56232. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  56233. private _type;
  56234. /** @hidden */
  56235. _enforceAssociatedVariableName: boolean;
  56236. /** Gets the direction of the point */
  56237. get direction(): NodeMaterialConnectionPointDirection;
  56238. /**
  56239. * Gets or sets the additional types supported by this connection point
  56240. */
  56241. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  56242. /**
  56243. * Gets or sets the additional types excluded by this connection point
  56244. */
  56245. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  56246. /**
  56247. * Observable triggered when this point is connected
  56248. */
  56249. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  56250. /**
  56251. * Gets or sets the associated variable name in the shader
  56252. */
  56253. get associatedVariableName(): string;
  56254. set associatedVariableName(value: string);
  56255. /**
  56256. * Gets or sets the connection point type (default is float)
  56257. */
  56258. get type(): NodeMaterialBlockConnectionPointTypes;
  56259. set type(value: NodeMaterialBlockConnectionPointTypes);
  56260. /**
  56261. * Gets or sets the connection point name
  56262. */
  56263. name: string;
  56264. /**
  56265. * Gets or sets a boolean indicating that this connection point can be omitted
  56266. */
  56267. isOptional: boolean;
  56268. /**
  56269. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  56270. */
  56271. define: string;
  56272. /** @hidden */
  56273. _prioritizeVertex: boolean;
  56274. private _target;
  56275. /** Gets or sets the target of that connection point */
  56276. get target(): NodeMaterialBlockTargets;
  56277. set target(value: NodeMaterialBlockTargets);
  56278. /**
  56279. * Gets a boolean indicating that the current point is connected
  56280. */
  56281. get isConnected(): boolean;
  56282. /**
  56283. * Gets a boolean indicating that the current point is connected to an input block
  56284. */
  56285. get isConnectedToInputBlock(): boolean;
  56286. /**
  56287. * Gets a the connected input block (if any)
  56288. */
  56289. get connectInputBlock(): Nullable<InputBlock>;
  56290. /** Get the other side of the connection (if any) */
  56291. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  56292. /** Get the block that owns this connection point */
  56293. get ownerBlock(): NodeMaterialBlock;
  56294. /** Get the block connected on the other side of this connection (if any) */
  56295. get sourceBlock(): Nullable<NodeMaterialBlock>;
  56296. /** Get the block connected on the endpoints of this connection (if any) */
  56297. get connectedBlocks(): Array<NodeMaterialBlock>;
  56298. /** Gets the list of connected endpoints */
  56299. get endpoints(): NodeMaterialConnectionPoint[];
  56300. /** Gets a boolean indicating if that output point is connected to at least one input */
  56301. get hasEndpoints(): boolean;
  56302. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  56303. get isConnectedInVertexShader(): boolean;
  56304. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  56305. get isConnectedInFragmentShader(): boolean;
  56306. /**
  56307. * Creates a new connection point
  56308. * @param name defines the connection point name
  56309. * @param ownerBlock defines the block hosting this connection point
  56310. * @param direction defines the direction of the connection point
  56311. */
  56312. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  56313. /**
  56314. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  56315. * @returns the class name
  56316. */
  56317. getClassName(): string;
  56318. /**
  56319. * Gets a boolean indicating if the current point can be connected to another point
  56320. * @param connectionPoint defines the other connection point
  56321. * @returns a boolean
  56322. */
  56323. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  56324. /**
  56325. * Gets a number indicating if the current point can be connected to another point
  56326. * @param connectionPoint defines the other connection point
  56327. * @returns a number defining the compatibility state
  56328. */
  56329. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  56330. /**
  56331. * Connect this point to another connection point
  56332. * @param connectionPoint defines the other connection point
  56333. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  56334. * @returns the current connection point
  56335. */
  56336. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  56337. /**
  56338. * Disconnect this point from one of his endpoint
  56339. * @param endpoint defines the other connection point
  56340. * @returns the current connection point
  56341. */
  56342. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  56343. /**
  56344. * Serializes this point in a JSON representation
  56345. * @returns the serialized point object
  56346. */
  56347. serialize(): any;
  56348. /**
  56349. * Release resources
  56350. */
  56351. dispose(): void;
  56352. }
  56353. }
  56354. declare module BABYLON {
  56355. /**
  56356. * Block used to add support for vertex skinning (bones)
  56357. */
  56358. export class BonesBlock extends NodeMaterialBlock {
  56359. /**
  56360. * Creates a new BonesBlock
  56361. * @param name defines the block name
  56362. */
  56363. constructor(name: string);
  56364. /**
  56365. * Initialize the block and prepare the context for build
  56366. * @param state defines the state that will be used for the build
  56367. */
  56368. initialize(state: NodeMaterialBuildState): void;
  56369. /**
  56370. * Gets the current class name
  56371. * @returns the class name
  56372. */
  56373. getClassName(): string;
  56374. /**
  56375. * Gets the matrix indices input component
  56376. */
  56377. get matricesIndices(): NodeMaterialConnectionPoint;
  56378. /**
  56379. * Gets the matrix weights input component
  56380. */
  56381. get matricesWeights(): NodeMaterialConnectionPoint;
  56382. /**
  56383. * Gets the extra matrix indices input component
  56384. */
  56385. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  56386. /**
  56387. * Gets the extra matrix weights input component
  56388. */
  56389. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  56390. /**
  56391. * Gets the world input component
  56392. */
  56393. get world(): NodeMaterialConnectionPoint;
  56394. /**
  56395. * Gets the output component
  56396. */
  56397. get output(): NodeMaterialConnectionPoint;
  56398. autoConfigure(material: NodeMaterial): void;
  56399. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  56400. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56401. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56402. protected _buildBlock(state: NodeMaterialBuildState): this;
  56403. }
  56404. }
  56405. declare module BABYLON {
  56406. /**
  56407. * Block used to add support for instances
  56408. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  56409. */
  56410. export class InstancesBlock extends NodeMaterialBlock {
  56411. /**
  56412. * Creates a new InstancesBlock
  56413. * @param name defines the block name
  56414. */
  56415. constructor(name: string);
  56416. /**
  56417. * Gets the current class name
  56418. * @returns the class name
  56419. */
  56420. getClassName(): string;
  56421. /**
  56422. * Gets the first world row input component
  56423. */
  56424. get world0(): NodeMaterialConnectionPoint;
  56425. /**
  56426. * Gets the second world row input component
  56427. */
  56428. get world1(): NodeMaterialConnectionPoint;
  56429. /**
  56430. * Gets the third world row input component
  56431. */
  56432. get world2(): NodeMaterialConnectionPoint;
  56433. /**
  56434. * Gets the forth world row input component
  56435. */
  56436. get world3(): NodeMaterialConnectionPoint;
  56437. /**
  56438. * Gets the world input component
  56439. */
  56440. get world(): NodeMaterialConnectionPoint;
  56441. /**
  56442. * Gets the output component
  56443. */
  56444. get output(): NodeMaterialConnectionPoint;
  56445. autoConfigure(material: NodeMaterial): void;
  56446. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56447. protected _buildBlock(state: NodeMaterialBuildState): this;
  56448. }
  56449. }
  56450. declare module BABYLON {
  56451. /**
  56452. * Block used to add morph targets support to vertex shader
  56453. */
  56454. export class MorphTargetsBlock extends NodeMaterialBlock {
  56455. private _repeatableContentAnchor;
  56456. private _repeatebleContentGenerated;
  56457. /**
  56458. * Create a new MorphTargetsBlock
  56459. * @param name defines the block name
  56460. */
  56461. constructor(name: string);
  56462. /**
  56463. * Gets the current class name
  56464. * @returns the class name
  56465. */
  56466. getClassName(): string;
  56467. /**
  56468. * Gets the position input component
  56469. */
  56470. get position(): NodeMaterialConnectionPoint;
  56471. /**
  56472. * Gets the normal input component
  56473. */
  56474. get normal(): NodeMaterialConnectionPoint;
  56475. /**
  56476. * Gets the tangent input component
  56477. */
  56478. get tangent(): NodeMaterialConnectionPoint;
  56479. /**
  56480. * Gets the tangent input component
  56481. */
  56482. get uv(): NodeMaterialConnectionPoint;
  56483. /**
  56484. * Gets the position output component
  56485. */
  56486. get positionOutput(): NodeMaterialConnectionPoint;
  56487. /**
  56488. * Gets the normal output component
  56489. */
  56490. get normalOutput(): NodeMaterialConnectionPoint;
  56491. /**
  56492. * Gets the tangent output component
  56493. */
  56494. get tangentOutput(): NodeMaterialConnectionPoint;
  56495. /**
  56496. * Gets the tangent output component
  56497. */
  56498. get uvOutput(): NodeMaterialConnectionPoint;
  56499. initialize(state: NodeMaterialBuildState): void;
  56500. autoConfigure(material: NodeMaterial): void;
  56501. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56502. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56503. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  56504. protected _buildBlock(state: NodeMaterialBuildState): this;
  56505. }
  56506. }
  56507. declare module BABYLON {
  56508. /**
  56509. * Block used to get data information from a light
  56510. */
  56511. export class LightInformationBlock extends NodeMaterialBlock {
  56512. private _lightDataUniformName;
  56513. private _lightColorUniformName;
  56514. private _lightTypeDefineName;
  56515. /**
  56516. * Gets or sets the light associated with this block
  56517. */
  56518. light: Nullable<Light>;
  56519. /**
  56520. * Creates a new LightInformationBlock
  56521. * @param name defines the block name
  56522. */
  56523. constructor(name: string);
  56524. /**
  56525. * Gets the current class name
  56526. * @returns the class name
  56527. */
  56528. getClassName(): string;
  56529. /**
  56530. * Gets the world position input component
  56531. */
  56532. get worldPosition(): NodeMaterialConnectionPoint;
  56533. /**
  56534. * Gets the direction output component
  56535. */
  56536. get direction(): NodeMaterialConnectionPoint;
  56537. /**
  56538. * Gets the direction output component
  56539. */
  56540. get color(): NodeMaterialConnectionPoint;
  56541. /**
  56542. * Gets the direction output component
  56543. */
  56544. get intensity(): NodeMaterialConnectionPoint;
  56545. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56546. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56547. protected _buildBlock(state: NodeMaterialBuildState): this;
  56548. serialize(): any;
  56549. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56550. }
  56551. }
  56552. declare module BABYLON {
  56553. /**
  56554. * Block used to add image processing support to fragment shader
  56555. */
  56556. export class ImageProcessingBlock extends NodeMaterialBlock {
  56557. /**
  56558. * Create a new ImageProcessingBlock
  56559. * @param name defines the block name
  56560. */
  56561. constructor(name: string);
  56562. /**
  56563. * Gets the current class name
  56564. * @returns the class name
  56565. */
  56566. getClassName(): string;
  56567. /**
  56568. * Gets the color input component
  56569. */
  56570. get color(): NodeMaterialConnectionPoint;
  56571. /**
  56572. * Gets the output component
  56573. */
  56574. get output(): NodeMaterialConnectionPoint;
  56575. /**
  56576. * Initialize the block and prepare the context for build
  56577. * @param state defines the state that will be used for the build
  56578. */
  56579. initialize(state: NodeMaterialBuildState): void;
  56580. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  56581. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56582. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56583. protected _buildBlock(state: NodeMaterialBuildState): this;
  56584. }
  56585. }
  56586. declare module BABYLON {
  56587. /**
  56588. * Block used to pertub normals based on a normal map
  56589. */
  56590. export class PerturbNormalBlock extends NodeMaterialBlock {
  56591. private _tangentSpaceParameterName;
  56592. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  56593. invertX: boolean;
  56594. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  56595. invertY: boolean;
  56596. /**
  56597. * Create a new PerturbNormalBlock
  56598. * @param name defines the block name
  56599. */
  56600. constructor(name: string);
  56601. /**
  56602. * Gets the current class name
  56603. * @returns the class name
  56604. */
  56605. getClassName(): string;
  56606. /**
  56607. * Gets the world position input component
  56608. */
  56609. get worldPosition(): NodeMaterialConnectionPoint;
  56610. /**
  56611. * Gets the world normal input component
  56612. */
  56613. get worldNormal(): NodeMaterialConnectionPoint;
  56614. /**
  56615. * Gets the uv input component
  56616. */
  56617. get uv(): NodeMaterialConnectionPoint;
  56618. /**
  56619. * Gets the normal map color input component
  56620. */
  56621. get normalMapColor(): NodeMaterialConnectionPoint;
  56622. /**
  56623. * Gets the strength input component
  56624. */
  56625. get strength(): NodeMaterialConnectionPoint;
  56626. /**
  56627. * Gets the output component
  56628. */
  56629. get output(): NodeMaterialConnectionPoint;
  56630. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56631. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56632. autoConfigure(material: NodeMaterial): void;
  56633. protected _buildBlock(state: NodeMaterialBuildState): this;
  56634. protected _dumpPropertiesCode(): string;
  56635. serialize(): any;
  56636. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56637. }
  56638. }
  56639. declare module BABYLON {
  56640. /**
  56641. * Block used to discard a pixel if a value is smaller than a cutoff
  56642. */
  56643. export class DiscardBlock extends NodeMaterialBlock {
  56644. /**
  56645. * Create a new DiscardBlock
  56646. * @param name defines the block name
  56647. */
  56648. constructor(name: string);
  56649. /**
  56650. * Gets the current class name
  56651. * @returns the class name
  56652. */
  56653. getClassName(): string;
  56654. /**
  56655. * Gets the color input component
  56656. */
  56657. get value(): NodeMaterialConnectionPoint;
  56658. /**
  56659. * Gets the cutoff input component
  56660. */
  56661. get cutoff(): NodeMaterialConnectionPoint;
  56662. protected _buildBlock(state: NodeMaterialBuildState): this;
  56663. }
  56664. }
  56665. declare module BABYLON {
  56666. /**
  56667. * Block used to test if the fragment shader is front facing
  56668. */
  56669. export class FrontFacingBlock extends NodeMaterialBlock {
  56670. /**
  56671. * Creates a new FrontFacingBlock
  56672. * @param name defines the block name
  56673. */
  56674. constructor(name: string);
  56675. /**
  56676. * Gets the current class name
  56677. * @returns the class name
  56678. */
  56679. getClassName(): string;
  56680. /**
  56681. * Gets the output component
  56682. */
  56683. get output(): NodeMaterialConnectionPoint;
  56684. protected _buildBlock(state: NodeMaterialBuildState): this;
  56685. }
  56686. }
  56687. declare module BABYLON {
  56688. /**
  56689. * Block used to get the derivative value on x and y of a given input
  56690. */
  56691. export class DerivativeBlock extends NodeMaterialBlock {
  56692. /**
  56693. * Create a new DerivativeBlock
  56694. * @param name defines the block name
  56695. */
  56696. constructor(name: string);
  56697. /**
  56698. * Gets the current class name
  56699. * @returns the class name
  56700. */
  56701. getClassName(): string;
  56702. /**
  56703. * Gets the input component
  56704. */
  56705. get input(): NodeMaterialConnectionPoint;
  56706. /**
  56707. * Gets the derivative output on x
  56708. */
  56709. get dx(): NodeMaterialConnectionPoint;
  56710. /**
  56711. * Gets the derivative output on y
  56712. */
  56713. get dy(): NodeMaterialConnectionPoint;
  56714. protected _buildBlock(state: NodeMaterialBuildState): this;
  56715. }
  56716. }
  56717. declare module BABYLON {
  56718. /**
  56719. * Block used to add support for scene fog
  56720. */
  56721. export class FogBlock extends NodeMaterialBlock {
  56722. private _fogDistanceName;
  56723. private _fogParameters;
  56724. /**
  56725. * Create a new FogBlock
  56726. * @param name defines the block name
  56727. */
  56728. constructor(name: string);
  56729. /**
  56730. * Gets the current class name
  56731. * @returns the class name
  56732. */
  56733. getClassName(): string;
  56734. /**
  56735. * Gets the world position input component
  56736. */
  56737. get worldPosition(): NodeMaterialConnectionPoint;
  56738. /**
  56739. * Gets the view input component
  56740. */
  56741. get view(): NodeMaterialConnectionPoint;
  56742. /**
  56743. * Gets the color input component
  56744. */
  56745. get input(): NodeMaterialConnectionPoint;
  56746. /**
  56747. * Gets the fog color input component
  56748. */
  56749. get fogColor(): NodeMaterialConnectionPoint;
  56750. /**
  56751. * Gets the output component
  56752. */
  56753. get output(): NodeMaterialConnectionPoint;
  56754. autoConfigure(material: NodeMaterial): void;
  56755. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56756. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56757. protected _buildBlock(state: NodeMaterialBuildState): this;
  56758. }
  56759. }
  56760. declare module BABYLON {
  56761. /**
  56762. * Block used to add light in the fragment shader
  56763. */
  56764. export class LightBlock extends NodeMaterialBlock {
  56765. private _lightId;
  56766. /**
  56767. * Gets or sets the light associated with this block
  56768. */
  56769. light: Nullable<Light>;
  56770. /**
  56771. * Create a new LightBlock
  56772. * @param name defines the block name
  56773. */
  56774. constructor(name: string);
  56775. /**
  56776. * Gets the current class name
  56777. * @returns the class name
  56778. */
  56779. getClassName(): string;
  56780. /**
  56781. * Gets the world position input component
  56782. */
  56783. get worldPosition(): NodeMaterialConnectionPoint;
  56784. /**
  56785. * Gets the world normal input component
  56786. */
  56787. get worldNormal(): NodeMaterialConnectionPoint;
  56788. /**
  56789. * Gets the camera (or eye) position component
  56790. */
  56791. get cameraPosition(): NodeMaterialConnectionPoint;
  56792. /**
  56793. * Gets the glossiness component
  56794. */
  56795. get glossiness(): NodeMaterialConnectionPoint;
  56796. /**
  56797. * Gets the glossinness power component
  56798. */
  56799. get glossPower(): NodeMaterialConnectionPoint;
  56800. /**
  56801. * Gets the diffuse color component
  56802. */
  56803. get diffuseColor(): NodeMaterialConnectionPoint;
  56804. /**
  56805. * Gets the specular color component
  56806. */
  56807. get specularColor(): NodeMaterialConnectionPoint;
  56808. /**
  56809. * Gets the diffuse output component
  56810. */
  56811. get diffuseOutput(): NodeMaterialConnectionPoint;
  56812. /**
  56813. * Gets the specular output component
  56814. */
  56815. get specularOutput(): NodeMaterialConnectionPoint;
  56816. autoConfigure(material: NodeMaterial): void;
  56817. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56818. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  56819. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56820. private _injectVertexCode;
  56821. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56822. serialize(): any;
  56823. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56824. }
  56825. }
  56826. declare module BABYLON {
  56827. /**
  56828. * Block used to multiply 2 values
  56829. */
  56830. export class MultiplyBlock extends NodeMaterialBlock {
  56831. /**
  56832. * Creates a new MultiplyBlock
  56833. * @param name defines the block name
  56834. */
  56835. constructor(name: string);
  56836. /**
  56837. * Gets the current class name
  56838. * @returns the class name
  56839. */
  56840. getClassName(): string;
  56841. /**
  56842. * Gets the left operand input component
  56843. */
  56844. get left(): NodeMaterialConnectionPoint;
  56845. /**
  56846. * Gets the right operand input component
  56847. */
  56848. get right(): NodeMaterialConnectionPoint;
  56849. /**
  56850. * Gets the output component
  56851. */
  56852. get output(): NodeMaterialConnectionPoint;
  56853. protected _buildBlock(state: NodeMaterialBuildState): this;
  56854. }
  56855. }
  56856. declare module BABYLON {
  56857. /**
  56858. * Block used to add 2 vectors
  56859. */
  56860. export class AddBlock extends NodeMaterialBlock {
  56861. /**
  56862. * Creates a new AddBlock
  56863. * @param name defines the block name
  56864. */
  56865. constructor(name: string);
  56866. /**
  56867. * Gets the current class name
  56868. * @returns the class name
  56869. */
  56870. getClassName(): string;
  56871. /**
  56872. * Gets the left operand input component
  56873. */
  56874. get left(): NodeMaterialConnectionPoint;
  56875. /**
  56876. * Gets the right operand input component
  56877. */
  56878. get right(): NodeMaterialConnectionPoint;
  56879. /**
  56880. * Gets the output component
  56881. */
  56882. get output(): NodeMaterialConnectionPoint;
  56883. protected _buildBlock(state: NodeMaterialBuildState): this;
  56884. }
  56885. }
  56886. declare module BABYLON {
  56887. /**
  56888. * Block used to scale a vector by a float
  56889. */
  56890. export class ScaleBlock extends NodeMaterialBlock {
  56891. /**
  56892. * Creates a new ScaleBlock
  56893. * @param name defines the block name
  56894. */
  56895. constructor(name: string);
  56896. /**
  56897. * Gets the current class name
  56898. * @returns the class name
  56899. */
  56900. getClassName(): string;
  56901. /**
  56902. * Gets the input component
  56903. */
  56904. get input(): NodeMaterialConnectionPoint;
  56905. /**
  56906. * Gets the factor input component
  56907. */
  56908. get factor(): NodeMaterialConnectionPoint;
  56909. /**
  56910. * Gets the output component
  56911. */
  56912. get output(): NodeMaterialConnectionPoint;
  56913. protected _buildBlock(state: NodeMaterialBuildState): this;
  56914. }
  56915. }
  56916. declare module BABYLON {
  56917. /**
  56918. * Block used to clamp a float
  56919. */
  56920. export class ClampBlock extends NodeMaterialBlock {
  56921. /** Gets or sets the minimum range */
  56922. minimum: number;
  56923. /** Gets or sets the maximum range */
  56924. maximum: number;
  56925. /**
  56926. * Creates a new ClampBlock
  56927. * @param name defines the block name
  56928. */
  56929. constructor(name: string);
  56930. /**
  56931. * Gets the current class name
  56932. * @returns the class name
  56933. */
  56934. getClassName(): string;
  56935. /**
  56936. * Gets the value input component
  56937. */
  56938. get value(): NodeMaterialConnectionPoint;
  56939. /**
  56940. * Gets the output component
  56941. */
  56942. get output(): NodeMaterialConnectionPoint;
  56943. protected _buildBlock(state: NodeMaterialBuildState): this;
  56944. protected _dumpPropertiesCode(): string;
  56945. serialize(): any;
  56946. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56947. }
  56948. }
  56949. declare module BABYLON {
  56950. /**
  56951. * Block used to apply a cross product between 2 vectors
  56952. */
  56953. export class CrossBlock extends NodeMaterialBlock {
  56954. /**
  56955. * Creates a new CrossBlock
  56956. * @param name defines the block name
  56957. */
  56958. constructor(name: string);
  56959. /**
  56960. * Gets the current class name
  56961. * @returns the class name
  56962. */
  56963. getClassName(): string;
  56964. /**
  56965. * Gets the left operand input component
  56966. */
  56967. get left(): NodeMaterialConnectionPoint;
  56968. /**
  56969. * Gets the right operand input component
  56970. */
  56971. get right(): NodeMaterialConnectionPoint;
  56972. /**
  56973. * Gets the output component
  56974. */
  56975. get output(): NodeMaterialConnectionPoint;
  56976. protected _buildBlock(state: NodeMaterialBuildState): this;
  56977. }
  56978. }
  56979. declare module BABYLON {
  56980. /**
  56981. * Block used to apply a dot product between 2 vectors
  56982. */
  56983. export class DotBlock extends NodeMaterialBlock {
  56984. /**
  56985. * Creates a new DotBlock
  56986. * @param name defines the block name
  56987. */
  56988. constructor(name: string);
  56989. /**
  56990. * Gets the current class name
  56991. * @returns the class name
  56992. */
  56993. getClassName(): string;
  56994. /**
  56995. * Gets the left operand input component
  56996. */
  56997. get left(): NodeMaterialConnectionPoint;
  56998. /**
  56999. * Gets the right operand input component
  57000. */
  57001. get right(): NodeMaterialConnectionPoint;
  57002. /**
  57003. * Gets the output component
  57004. */
  57005. get output(): NodeMaterialConnectionPoint;
  57006. protected _buildBlock(state: NodeMaterialBuildState): this;
  57007. }
  57008. }
  57009. declare module BABYLON {
  57010. /**
  57011. * Block used to remap a float from a range to a new one
  57012. */
  57013. export class RemapBlock extends NodeMaterialBlock {
  57014. /**
  57015. * Gets or sets the source range
  57016. */
  57017. sourceRange: Vector2;
  57018. /**
  57019. * Gets or sets the target range
  57020. */
  57021. targetRange: Vector2;
  57022. /**
  57023. * Creates a new RemapBlock
  57024. * @param name defines the block name
  57025. */
  57026. constructor(name: string);
  57027. /**
  57028. * Gets the current class name
  57029. * @returns the class name
  57030. */
  57031. getClassName(): string;
  57032. /**
  57033. * Gets the input component
  57034. */
  57035. get input(): NodeMaterialConnectionPoint;
  57036. /**
  57037. * Gets the source min input component
  57038. */
  57039. get sourceMin(): NodeMaterialConnectionPoint;
  57040. /**
  57041. * Gets the source max input component
  57042. */
  57043. get sourceMax(): NodeMaterialConnectionPoint;
  57044. /**
  57045. * Gets the target min input component
  57046. */
  57047. get targetMin(): NodeMaterialConnectionPoint;
  57048. /**
  57049. * Gets the target max input component
  57050. */
  57051. get targetMax(): NodeMaterialConnectionPoint;
  57052. /**
  57053. * Gets the output component
  57054. */
  57055. get output(): NodeMaterialConnectionPoint;
  57056. protected _buildBlock(state: NodeMaterialBuildState): this;
  57057. protected _dumpPropertiesCode(): string;
  57058. serialize(): any;
  57059. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57060. }
  57061. }
  57062. declare module BABYLON {
  57063. /**
  57064. * Block used to normalize a vector
  57065. */
  57066. export class NormalizeBlock extends NodeMaterialBlock {
  57067. /**
  57068. * Creates a new NormalizeBlock
  57069. * @param name defines the block name
  57070. */
  57071. constructor(name: string);
  57072. /**
  57073. * Gets the current class name
  57074. * @returns the class name
  57075. */
  57076. getClassName(): string;
  57077. /**
  57078. * Gets the input component
  57079. */
  57080. get input(): NodeMaterialConnectionPoint;
  57081. /**
  57082. * Gets the output component
  57083. */
  57084. get output(): NodeMaterialConnectionPoint;
  57085. protected _buildBlock(state: NodeMaterialBuildState): this;
  57086. }
  57087. }
  57088. declare module BABYLON {
  57089. /**
  57090. * Operations supported by the Trigonometry block
  57091. */
  57092. export enum TrigonometryBlockOperations {
  57093. /** Cos */
  57094. Cos = 0,
  57095. /** Sin */
  57096. Sin = 1,
  57097. /** Abs */
  57098. Abs = 2,
  57099. /** Exp */
  57100. Exp = 3,
  57101. /** Exp2 */
  57102. Exp2 = 4,
  57103. /** Round */
  57104. Round = 5,
  57105. /** Floor */
  57106. Floor = 6,
  57107. /** Ceiling */
  57108. Ceiling = 7,
  57109. /** Square root */
  57110. Sqrt = 8,
  57111. /** Log */
  57112. Log = 9,
  57113. /** Tangent */
  57114. Tan = 10,
  57115. /** Arc tangent */
  57116. ArcTan = 11,
  57117. /** Arc cosinus */
  57118. ArcCos = 12,
  57119. /** Arc sinus */
  57120. ArcSin = 13,
  57121. /** Fraction */
  57122. Fract = 14,
  57123. /** Sign */
  57124. Sign = 15,
  57125. /** To radians (from degrees) */
  57126. Radians = 16,
  57127. /** To degrees (from radians) */
  57128. Degrees = 17
  57129. }
  57130. /**
  57131. * Block used to apply trigonometry operation to floats
  57132. */
  57133. export class TrigonometryBlock extends NodeMaterialBlock {
  57134. /**
  57135. * Gets or sets the operation applied by the block
  57136. */
  57137. operation: TrigonometryBlockOperations;
  57138. /**
  57139. * Creates a new TrigonometryBlock
  57140. * @param name defines the block name
  57141. */
  57142. constructor(name: string);
  57143. /**
  57144. * Gets the current class name
  57145. * @returns the class name
  57146. */
  57147. getClassName(): string;
  57148. /**
  57149. * Gets the input component
  57150. */
  57151. get input(): NodeMaterialConnectionPoint;
  57152. /**
  57153. * Gets the output component
  57154. */
  57155. get output(): NodeMaterialConnectionPoint;
  57156. protected _buildBlock(state: NodeMaterialBuildState): this;
  57157. serialize(): any;
  57158. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57159. protected _dumpPropertiesCode(): string;
  57160. }
  57161. }
  57162. declare module BABYLON {
  57163. /**
  57164. * Block used to create a Color3/4 out of individual inputs (one for each component)
  57165. */
  57166. export class ColorMergerBlock extends NodeMaterialBlock {
  57167. /**
  57168. * Create a new ColorMergerBlock
  57169. * @param name defines the block name
  57170. */
  57171. constructor(name: string);
  57172. /**
  57173. * Gets the current class name
  57174. * @returns the class name
  57175. */
  57176. getClassName(): string;
  57177. /**
  57178. * Gets the rgb component (input)
  57179. */
  57180. get rgbIn(): NodeMaterialConnectionPoint;
  57181. /**
  57182. * Gets the r component (input)
  57183. */
  57184. get r(): NodeMaterialConnectionPoint;
  57185. /**
  57186. * Gets the g component (input)
  57187. */
  57188. get g(): NodeMaterialConnectionPoint;
  57189. /**
  57190. * Gets the b component (input)
  57191. */
  57192. get b(): NodeMaterialConnectionPoint;
  57193. /**
  57194. * Gets the a component (input)
  57195. */
  57196. get a(): NodeMaterialConnectionPoint;
  57197. /**
  57198. * Gets the rgba component (output)
  57199. */
  57200. get rgba(): NodeMaterialConnectionPoint;
  57201. /**
  57202. * Gets the rgb component (output)
  57203. */
  57204. get rgbOut(): NodeMaterialConnectionPoint;
  57205. /**
  57206. * Gets the rgb component (output)
  57207. * @deprecated Please use rgbOut instead.
  57208. */
  57209. get rgb(): NodeMaterialConnectionPoint;
  57210. protected _buildBlock(state: NodeMaterialBuildState): this;
  57211. }
  57212. }
  57213. declare module BABYLON {
  57214. /**
  57215. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  57216. */
  57217. export class VectorMergerBlock extends NodeMaterialBlock {
  57218. /**
  57219. * Create a new VectorMergerBlock
  57220. * @param name defines the block name
  57221. */
  57222. constructor(name: string);
  57223. /**
  57224. * Gets the current class name
  57225. * @returns the class name
  57226. */
  57227. getClassName(): string;
  57228. /**
  57229. * Gets the xyz component (input)
  57230. */
  57231. get xyzIn(): NodeMaterialConnectionPoint;
  57232. /**
  57233. * Gets the xy component (input)
  57234. */
  57235. get xyIn(): NodeMaterialConnectionPoint;
  57236. /**
  57237. * Gets the x component (input)
  57238. */
  57239. get x(): NodeMaterialConnectionPoint;
  57240. /**
  57241. * Gets the y component (input)
  57242. */
  57243. get y(): NodeMaterialConnectionPoint;
  57244. /**
  57245. * Gets the z component (input)
  57246. */
  57247. get z(): NodeMaterialConnectionPoint;
  57248. /**
  57249. * Gets the w component (input)
  57250. */
  57251. get w(): NodeMaterialConnectionPoint;
  57252. /**
  57253. * Gets the xyzw component (output)
  57254. */
  57255. get xyzw(): NodeMaterialConnectionPoint;
  57256. /**
  57257. * Gets the xyz component (output)
  57258. */
  57259. get xyzOut(): NodeMaterialConnectionPoint;
  57260. /**
  57261. * Gets the xy component (output)
  57262. */
  57263. get xyOut(): NodeMaterialConnectionPoint;
  57264. /**
  57265. * Gets the xy component (output)
  57266. * @deprecated Please use xyOut instead.
  57267. */
  57268. get xy(): NodeMaterialConnectionPoint;
  57269. /**
  57270. * Gets the xyz component (output)
  57271. * @deprecated Please use xyzOut instead.
  57272. */
  57273. get xyz(): NodeMaterialConnectionPoint;
  57274. protected _buildBlock(state: NodeMaterialBuildState): this;
  57275. }
  57276. }
  57277. declare module BABYLON {
  57278. /**
  57279. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  57280. */
  57281. export class ColorSplitterBlock extends NodeMaterialBlock {
  57282. /**
  57283. * Create a new ColorSplitterBlock
  57284. * @param name defines the block name
  57285. */
  57286. constructor(name: string);
  57287. /**
  57288. * Gets the current class name
  57289. * @returns the class name
  57290. */
  57291. getClassName(): string;
  57292. /**
  57293. * Gets the rgba component (input)
  57294. */
  57295. get rgba(): NodeMaterialConnectionPoint;
  57296. /**
  57297. * Gets the rgb component (input)
  57298. */
  57299. get rgbIn(): NodeMaterialConnectionPoint;
  57300. /**
  57301. * Gets the rgb component (output)
  57302. */
  57303. get rgbOut(): NodeMaterialConnectionPoint;
  57304. /**
  57305. * Gets the r component (output)
  57306. */
  57307. get r(): NodeMaterialConnectionPoint;
  57308. /**
  57309. * Gets the g component (output)
  57310. */
  57311. get g(): NodeMaterialConnectionPoint;
  57312. /**
  57313. * Gets the b component (output)
  57314. */
  57315. get b(): NodeMaterialConnectionPoint;
  57316. /**
  57317. * Gets the a component (output)
  57318. */
  57319. get a(): NodeMaterialConnectionPoint;
  57320. protected _inputRename(name: string): string;
  57321. protected _outputRename(name: string): string;
  57322. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57323. }
  57324. }
  57325. declare module BABYLON {
  57326. /**
  57327. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  57328. */
  57329. export class VectorSplitterBlock extends NodeMaterialBlock {
  57330. /**
  57331. * Create a new VectorSplitterBlock
  57332. * @param name defines the block name
  57333. */
  57334. constructor(name: string);
  57335. /**
  57336. * Gets the current class name
  57337. * @returns the class name
  57338. */
  57339. getClassName(): string;
  57340. /**
  57341. * Gets the xyzw component (input)
  57342. */
  57343. get xyzw(): NodeMaterialConnectionPoint;
  57344. /**
  57345. * Gets the xyz component (input)
  57346. */
  57347. get xyzIn(): NodeMaterialConnectionPoint;
  57348. /**
  57349. * Gets the xy component (input)
  57350. */
  57351. get xyIn(): NodeMaterialConnectionPoint;
  57352. /**
  57353. * Gets the xyz component (output)
  57354. */
  57355. get xyzOut(): NodeMaterialConnectionPoint;
  57356. /**
  57357. * Gets the xy component (output)
  57358. */
  57359. get xyOut(): NodeMaterialConnectionPoint;
  57360. /**
  57361. * Gets the x component (output)
  57362. */
  57363. get x(): NodeMaterialConnectionPoint;
  57364. /**
  57365. * Gets the y component (output)
  57366. */
  57367. get y(): NodeMaterialConnectionPoint;
  57368. /**
  57369. * Gets the z component (output)
  57370. */
  57371. get z(): NodeMaterialConnectionPoint;
  57372. /**
  57373. * Gets the w component (output)
  57374. */
  57375. get w(): NodeMaterialConnectionPoint;
  57376. protected _inputRename(name: string): string;
  57377. protected _outputRename(name: string): string;
  57378. protected _buildBlock(state: NodeMaterialBuildState): this;
  57379. }
  57380. }
  57381. declare module BABYLON {
  57382. /**
  57383. * Block used to lerp between 2 values
  57384. */
  57385. export class LerpBlock extends NodeMaterialBlock {
  57386. /**
  57387. * Creates a new LerpBlock
  57388. * @param name defines the block name
  57389. */
  57390. constructor(name: string);
  57391. /**
  57392. * Gets the current class name
  57393. * @returns the class name
  57394. */
  57395. getClassName(): string;
  57396. /**
  57397. * Gets the left operand input component
  57398. */
  57399. get left(): NodeMaterialConnectionPoint;
  57400. /**
  57401. * Gets the right operand input component
  57402. */
  57403. get right(): NodeMaterialConnectionPoint;
  57404. /**
  57405. * Gets the gradient operand input component
  57406. */
  57407. get gradient(): NodeMaterialConnectionPoint;
  57408. /**
  57409. * Gets the output component
  57410. */
  57411. get output(): NodeMaterialConnectionPoint;
  57412. protected _buildBlock(state: NodeMaterialBuildState): this;
  57413. }
  57414. }
  57415. declare module BABYLON {
  57416. /**
  57417. * Block used to divide 2 vectors
  57418. */
  57419. export class DivideBlock extends NodeMaterialBlock {
  57420. /**
  57421. * Creates a new DivideBlock
  57422. * @param name defines the block name
  57423. */
  57424. constructor(name: string);
  57425. /**
  57426. * Gets the current class name
  57427. * @returns the class name
  57428. */
  57429. getClassName(): string;
  57430. /**
  57431. * Gets the left operand input component
  57432. */
  57433. get left(): NodeMaterialConnectionPoint;
  57434. /**
  57435. * Gets the right operand input component
  57436. */
  57437. get right(): NodeMaterialConnectionPoint;
  57438. /**
  57439. * Gets the output component
  57440. */
  57441. get output(): NodeMaterialConnectionPoint;
  57442. protected _buildBlock(state: NodeMaterialBuildState): this;
  57443. }
  57444. }
  57445. declare module BABYLON {
  57446. /**
  57447. * Block used to subtract 2 vectors
  57448. */
  57449. export class SubtractBlock extends NodeMaterialBlock {
  57450. /**
  57451. * Creates a new SubtractBlock
  57452. * @param name defines the block name
  57453. */
  57454. constructor(name: string);
  57455. /**
  57456. * Gets the current class name
  57457. * @returns the class name
  57458. */
  57459. getClassName(): string;
  57460. /**
  57461. * Gets the left operand input component
  57462. */
  57463. get left(): NodeMaterialConnectionPoint;
  57464. /**
  57465. * Gets the right operand input component
  57466. */
  57467. get right(): NodeMaterialConnectionPoint;
  57468. /**
  57469. * Gets the output component
  57470. */
  57471. get output(): NodeMaterialConnectionPoint;
  57472. protected _buildBlock(state: NodeMaterialBuildState): this;
  57473. }
  57474. }
  57475. declare module BABYLON {
  57476. /**
  57477. * Block used to step a value
  57478. */
  57479. export class StepBlock extends NodeMaterialBlock {
  57480. /**
  57481. * Creates a new StepBlock
  57482. * @param name defines the block name
  57483. */
  57484. constructor(name: string);
  57485. /**
  57486. * Gets the current class name
  57487. * @returns the class name
  57488. */
  57489. getClassName(): string;
  57490. /**
  57491. * Gets the value operand input component
  57492. */
  57493. get value(): NodeMaterialConnectionPoint;
  57494. /**
  57495. * Gets the edge operand input component
  57496. */
  57497. get edge(): NodeMaterialConnectionPoint;
  57498. /**
  57499. * Gets the output component
  57500. */
  57501. get output(): NodeMaterialConnectionPoint;
  57502. protected _buildBlock(state: NodeMaterialBuildState): this;
  57503. }
  57504. }
  57505. declare module BABYLON {
  57506. /**
  57507. * Block used to get the opposite (1 - x) of a value
  57508. */
  57509. export class OneMinusBlock extends NodeMaterialBlock {
  57510. /**
  57511. * Creates a new OneMinusBlock
  57512. * @param name defines the block name
  57513. */
  57514. constructor(name: string);
  57515. /**
  57516. * Gets the current class name
  57517. * @returns the class name
  57518. */
  57519. getClassName(): string;
  57520. /**
  57521. * Gets the input component
  57522. */
  57523. get input(): NodeMaterialConnectionPoint;
  57524. /**
  57525. * Gets the output component
  57526. */
  57527. get output(): NodeMaterialConnectionPoint;
  57528. protected _buildBlock(state: NodeMaterialBuildState): this;
  57529. }
  57530. }
  57531. declare module BABYLON {
  57532. /**
  57533. * Block used to get the view direction
  57534. */
  57535. export class ViewDirectionBlock extends NodeMaterialBlock {
  57536. /**
  57537. * Creates a new ViewDirectionBlock
  57538. * @param name defines the block name
  57539. */
  57540. constructor(name: string);
  57541. /**
  57542. * Gets the current class name
  57543. * @returns the class name
  57544. */
  57545. getClassName(): string;
  57546. /**
  57547. * Gets the world position component
  57548. */
  57549. get worldPosition(): NodeMaterialConnectionPoint;
  57550. /**
  57551. * Gets the camera position component
  57552. */
  57553. get cameraPosition(): NodeMaterialConnectionPoint;
  57554. /**
  57555. * Gets the output component
  57556. */
  57557. get output(): NodeMaterialConnectionPoint;
  57558. autoConfigure(material: NodeMaterial): void;
  57559. protected _buildBlock(state: NodeMaterialBuildState): this;
  57560. }
  57561. }
  57562. declare module BABYLON {
  57563. /**
  57564. * Block used to compute fresnel value
  57565. */
  57566. export class FresnelBlock extends NodeMaterialBlock {
  57567. /**
  57568. * Create a new FresnelBlock
  57569. * @param name defines the block name
  57570. */
  57571. constructor(name: string);
  57572. /**
  57573. * Gets the current class name
  57574. * @returns the class name
  57575. */
  57576. getClassName(): string;
  57577. /**
  57578. * Gets the world normal input component
  57579. */
  57580. get worldNormal(): NodeMaterialConnectionPoint;
  57581. /**
  57582. * Gets the view direction input component
  57583. */
  57584. get viewDirection(): NodeMaterialConnectionPoint;
  57585. /**
  57586. * Gets the bias input component
  57587. */
  57588. get bias(): NodeMaterialConnectionPoint;
  57589. /**
  57590. * Gets the camera (or eye) position component
  57591. */
  57592. get power(): NodeMaterialConnectionPoint;
  57593. /**
  57594. * Gets the fresnel output component
  57595. */
  57596. get fresnel(): NodeMaterialConnectionPoint;
  57597. autoConfigure(material: NodeMaterial): void;
  57598. protected _buildBlock(state: NodeMaterialBuildState): this;
  57599. }
  57600. }
  57601. declare module BABYLON {
  57602. /**
  57603. * Block used to get the max of 2 values
  57604. */
  57605. export class MaxBlock extends NodeMaterialBlock {
  57606. /**
  57607. * Creates a new MaxBlock
  57608. * @param name defines the block name
  57609. */
  57610. constructor(name: string);
  57611. /**
  57612. * Gets the current class name
  57613. * @returns the class name
  57614. */
  57615. getClassName(): string;
  57616. /**
  57617. * Gets the left operand input component
  57618. */
  57619. get left(): NodeMaterialConnectionPoint;
  57620. /**
  57621. * Gets the right operand input component
  57622. */
  57623. get right(): NodeMaterialConnectionPoint;
  57624. /**
  57625. * Gets the output component
  57626. */
  57627. get output(): NodeMaterialConnectionPoint;
  57628. protected _buildBlock(state: NodeMaterialBuildState): this;
  57629. }
  57630. }
  57631. declare module BABYLON {
  57632. /**
  57633. * Block used to get the min of 2 values
  57634. */
  57635. export class MinBlock extends NodeMaterialBlock {
  57636. /**
  57637. * Creates a new MinBlock
  57638. * @param name defines the block name
  57639. */
  57640. constructor(name: string);
  57641. /**
  57642. * Gets the current class name
  57643. * @returns the class name
  57644. */
  57645. getClassName(): string;
  57646. /**
  57647. * Gets the left operand input component
  57648. */
  57649. get left(): NodeMaterialConnectionPoint;
  57650. /**
  57651. * Gets the right operand input component
  57652. */
  57653. get right(): NodeMaterialConnectionPoint;
  57654. /**
  57655. * Gets the output component
  57656. */
  57657. get output(): NodeMaterialConnectionPoint;
  57658. protected _buildBlock(state: NodeMaterialBuildState): this;
  57659. }
  57660. }
  57661. declare module BABYLON {
  57662. /**
  57663. * Block used to get the distance between 2 values
  57664. */
  57665. export class DistanceBlock extends NodeMaterialBlock {
  57666. /**
  57667. * Creates a new DistanceBlock
  57668. * @param name defines the block name
  57669. */
  57670. constructor(name: string);
  57671. /**
  57672. * Gets the current class name
  57673. * @returns the class name
  57674. */
  57675. getClassName(): string;
  57676. /**
  57677. * Gets the left operand input component
  57678. */
  57679. get left(): NodeMaterialConnectionPoint;
  57680. /**
  57681. * Gets the right operand input component
  57682. */
  57683. get right(): NodeMaterialConnectionPoint;
  57684. /**
  57685. * Gets the output component
  57686. */
  57687. get output(): NodeMaterialConnectionPoint;
  57688. protected _buildBlock(state: NodeMaterialBuildState): this;
  57689. }
  57690. }
  57691. declare module BABYLON {
  57692. /**
  57693. * Block used to get the length of a vector
  57694. */
  57695. export class LengthBlock extends NodeMaterialBlock {
  57696. /**
  57697. * Creates a new LengthBlock
  57698. * @param name defines the block name
  57699. */
  57700. constructor(name: string);
  57701. /**
  57702. * Gets the current class name
  57703. * @returns the class name
  57704. */
  57705. getClassName(): string;
  57706. /**
  57707. * Gets the value input component
  57708. */
  57709. get value(): NodeMaterialConnectionPoint;
  57710. /**
  57711. * Gets the output component
  57712. */
  57713. get output(): NodeMaterialConnectionPoint;
  57714. protected _buildBlock(state: NodeMaterialBuildState): this;
  57715. }
  57716. }
  57717. declare module BABYLON {
  57718. /**
  57719. * Block used to get negative version of a value (i.e. x * -1)
  57720. */
  57721. export class NegateBlock extends NodeMaterialBlock {
  57722. /**
  57723. * Creates a new NegateBlock
  57724. * @param name defines the block name
  57725. */
  57726. constructor(name: string);
  57727. /**
  57728. * Gets the current class name
  57729. * @returns the class name
  57730. */
  57731. getClassName(): string;
  57732. /**
  57733. * Gets the value input component
  57734. */
  57735. get value(): NodeMaterialConnectionPoint;
  57736. /**
  57737. * Gets the output component
  57738. */
  57739. get output(): NodeMaterialConnectionPoint;
  57740. protected _buildBlock(state: NodeMaterialBuildState): this;
  57741. }
  57742. }
  57743. declare module BABYLON {
  57744. /**
  57745. * Block used to get the value of the first parameter raised to the power of the second
  57746. */
  57747. export class PowBlock extends NodeMaterialBlock {
  57748. /**
  57749. * Creates a new PowBlock
  57750. * @param name defines the block name
  57751. */
  57752. constructor(name: string);
  57753. /**
  57754. * Gets the current class name
  57755. * @returns the class name
  57756. */
  57757. getClassName(): string;
  57758. /**
  57759. * Gets the value operand input component
  57760. */
  57761. get value(): NodeMaterialConnectionPoint;
  57762. /**
  57763. * Gets the power operand input component
  57764. */
  57765. get power(): NodeMaterialConnectionPoint;
  57766. /**
  57767. * Gets the output component
  57768. */
  57769. get output(): NodeMaterialConnectionPoint;
  57770. protected _buildBlock(state: NodeMaterialBuildState): this;
  57771. }
  57772. }
  57773. declare module BABYLON {
  57774. /**
  57775. * Block used to get a random number
  57776. */
  57777. export class RandomNumberBlock extends NodeMaterialBlock {
  57778. /**
  57779. * Creates a new RandomNumberBlock
  57780. * @param name defines the block name
  57781. */
  57782. constructor(name: string);
  57783. /**
  57784. * Gets the current class name
  57785. * @returns the class name
  57786. */
  57787. getClassName(): string;
  57788. /**
  57789. * Gets the seed input component
  57790. */
  57791. get seed(): NodeMaterialConnectionPoint;
  57792. /**
  57793. * Gets the output component
  57794. */
  57795. get output(): NodeMaterialConnectionPoint;
  57796. protected _buildBlock(state: NodeMaterialBuildState): this;
  57797. }
  57798. }
  57799. declare module BABYLON {
  57800. /**
  57801. * Block used to compute arc tangent of 2 values
  57802. */
  57803. export class ArcTan2Block extends NodeMaterialBlock {
  57804. /**
  57805. * Creates a new ArcTan2Block
  57806. * @param name defines the block name
  57807. */
  57808. constructor(name: string);
  57809. /**
  57810. * Gets the current class name
  57811. * @returns the class name
  57812. */
  57813. getClassName(): string;
  57814. /**
  57815. * Gets the x operand input component
  57816. */
  57817. get x(): NodeMaterialConnectionPoint;
  57818. /**
  57819. * Gets the y operand input component
  57820. */
  57821. get y(): NodeMaterialConnectionPoint;
  57822. /**
  57823. * Gets the output component
  57824. */
  57825. get output(): NodeMaterialConnectionPoint;
  57826. protected _buildBlock(state: NodeMaterialBuildState): this;
  57827. }
  57828. }
  57829. declare module BABYLON {
  57830. /**
  57831. * Block used to smooth step a value
  57832. */
  57833. export class SmoothStepBlock extends NodeMaterialBlock {
  57834. /**
  57835. * Creates a new SmoothStepBlock
  57836. * @param name defines the block name
  57837. */
  57838. constructor(name: string);
  57839. /**
  57840. * Gets the current class name
  57841. * @returns the class name
  57842. */
  57843. getClassName(): string;
  57844. /**
  57845. * Gets the value operand input component
  57846. */
  57847. get value(): NodeMaterialConnectionPoint;
  57848. /**
  57849. * Gets the first edge operand input component
  57850. */
  57851. get edge0(): NodeMaterialConnectionPoint;
  57852. /**
  57853. * Gets the second edge operand input component
  57854. */
  57855. get edge1(): NodeMaterialConnectionPoint;
  57856. /**
  57857. * Gets the output component
  57858. */
  57859. get output(): NodeMaterialConnectionPoint;
  57860. protected _buildBlock(state: NodeMaterialBuildState): this;
  57861. }
  57862. }
  57863. declare module BABYLON {
  57864. /**
  57865. * Block used to get the reciprocal (1 / x) of a value
  57866. */
  57867. export class ReciprocalBlock extends NodeMaterialBlock {
  57868. /**
  57869. * Creates a new ReciprocalBlock
  57870. * @param name defines the block name
  57871. */
  57872. constructor(name: string);
  57873. /**
  57874. * Gets the current class name
  57875. * @returns the class name
  57876. */
  57877. getClassName(): string;
  57878. /**
  57879. * Gets the input component
  57880. */
  57881. get input(): NodeMaterialConnectionPoint;
  57882. /**
  57883. * Gets the output component
  57884. */
  57885. get output(): NodeMaterialConnectionPoint;
  57886. protected _buildBlock(state: NodeMaterialBuildState): this;
  57887. }
  57888. }
  57889. declare module BABYLON {
  57890. /**
  57891. * Block used to replace a color by another one
  57892. */
  57893. export class ReplaceColorBlock extends NodeMaterialBlock {
  57894. /**
  57895. * Creates a new ReplaceColorBlock
  57896. * @param name defines the block name
  57897. */
  57898. constructor(name: string);
  57899. /**
  57900. * Gets the current class name
  57901. * @returns the class name
  57902. */
  57903. getClassName(): string;
  57904. /**
  57905. * Gets the value input component
  57906. */
  57907. get value(): NodeMaterialConnectionPoint;
  57908. /**
  57909. * Gets the reference input component
  57910. */
  57911. get reference(): NodeMaterialConnectionPoint;
  57912. /**
  57913. * Gets the distance input component
  57914. */
  57915. get distance(): NodeMaterialConnectionPoint;
  57916. /**
  57917. * Gets the replacement input component
  57918. */
  57919. get replacement(): NodeMaterialConnectionPoint;
  57920. /**
  57921. * Gets the output component
  57922. */
  57923. get output(): NodeMaterialConnectionPoint;
  57924. protected _buildBlock(state: NodeMaterialBuildState): this;
  57925. }
  57926. }
  57927. declare module BABYLON {
  57928. /**
  57929. * Block used to posterize a value
  57930. * @see https://en.wikipedia.org/wiki/Posterization
  57931. */
  57932. export class PosterizeBlock extends NodeMaterialBlock {
  57933. /**
  57934. * Creates a new PosterizeBlock
  57935. * @param name defines the block name
  57936. */
  57937. constructor(name: string);
  57938. /**
  57939. * Gets the current class name
  57940. * @returns the class name
  57941. */
  57942. getClassName(): string;
  57943. /**
  57944. * Gets the value input component
  57945. */
  57946. get value(): NodeMaterialConnectionPoint;
  57947. /**
  57948. * Gets the steps input component
  57949. */
  57950. get steps(): NodeMaterialConnectionPoint;
  57951. /**
  57952. * Gets the output component
  57953. */
  57954. get output(): NodeMaterialConnectionPoint;
  57955. protected _buildBlock(state: NodeMaterialBuildState): this;
  57956. }
  57957. }
  57958. declare module BABYLON {
  57959. /**
  57960. * Operations supported by the Wave block
  57961. */
  57962. export enum WaveBlockKind {
  57963. /** SawTooth */
  57964. SawTooth = 0,
  57965. /** Square */
  57966. Square = 1,
  57967. /** Triangle */
  57968. Triangle = 2
  57969. }
  57970. /**
  57971. * Block used to apply wave operation to floats
  57972. */
  57973. export class WaveBlock extends NodeMaterialBlock {
  57974. /**
  57975. * Gets or sets the kibnd of wave to be applied by the block
  57976. */
  57977. kind: WaveBlockKind;
  57978. /**
  57979. * Creates a new WaveBlock
  57980. * @param name defines the block name
  57981. */
  57982. constructor(name: string);
  57983. /**
  57984. * Gets the current class name
  57985. * @returns the class name
  57986. */
  57987. getClassName(): string;
  57988. /**
  57989. * Gets the input component
  57990. */
  57991. get input(): NodeMaterialConnectionPoint;
  57992. /**
  57993. * Gets the output component
  57994. */
  57995. get output(): NodeMaterialConnectionPoint;
  57996. protected _buildBlock(state: NodeMaterialBuildState): this;
  57997. serialize(): any;
  57998. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57999. }
  58000. }
  58001. declare module BABYLON {
  58002. /**
  58003. * Class used to store a color step for the GradientBlock
  58004. */
  58005. export class GradientBlockColorStep {
  58006. /**
  58007. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  58008. */
  58009. step: number;
  58010. /**
  58011. * Gets or sets the color associated with this step
  58012. */
  58013. color: Color3;
  58014. /**
  58015. * Creates a new GradientBlockColorStep
  58016. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  58017. * @param color defines the color associated with this step
  58018. */
  58019. constructor(
  58020. /**
  58021. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  58022. */
  58023. step: number,
  58024. /**
  58025. * Gets or sets the color associated with this step
  58026. */
  58027. color: Color3);
  58028. }
  58029. /**
  58030. * Block used to return a color from a gradient based on an input value between 0 and 1
  58031. */
  58032. export class GradientBlock extends NodeMaterialBlock {
  58033. /**
  58034. * Gets or sets the list of color steps
  58035. */
  58036. colorSteps: GradientBlockColorStep[];
  58037. /**
  58038. * Creates a new GradientBlock
  58039. * @param name defines the block name
  58040. */
  58041. constructor(name: string);
  58042. /**
  58043. * Gets the current class name
  58044. * @returns the class name
  58045. */
  58046. getClassName(): string;
  58047. /**
  58048. * Gets the gradient input component
  58049. */
  58050. get gradient(): NodeMaterialConnectionPoint;
  58051. /**
  58052. * Gets the output component
  58053. */
  58054. get output(): NodeMaterialConnectionPoint;
  58055. private _writeColorConstant;
  58056. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58057. serialize(): any;
  58058. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58059. protected _dumpPropertiesCode(): string;
  58060. }
  58061. }
  58062. declare module BABYLON {
  58063. /**
  58064. * Block used to normalize lerp between 2 values
  58065. */
  58066. export class NLerpBlock extends NodeMaterialBlock {
  58067. /**
  58068. * Creates a new NLerpBlock
  58069. * @param name defines the block name
  58070. */
  58071. constructor(name: string);
  58072. /**
  58073. * Gets the current class name
  58074. * @returns the class name
  58075. */
  58076. getClassName(): string;
  58077. /**
  58078. * Gets the left operand input component
  58079. */
  58080. get left(): NodeMaterialConnectionPoint;
  58081. /**
  58082. * Gets the right operand input component
  58083. */
  58084. get right(): NodeMaterialConnectionPoint;
  58085. /**
  58086. * Gets the gradient operand input component
  58087. */
  58088. get gradient(): NodeMaterialConnectionPoint;
  58089. /**
  58090. * Gets the output component
  58091. */
  58092. get output(): NodeMaterialConnectionPoint;
  58093. protected _buildBlock(state: NodeMaterialBuildState): this;
  58094. }
  58095. }
  58096. declare module BABYLON {
  58097. /**
  58098. * block used to Generate a Worley Noise 3D Noise Pattern
  58099. */
  58100. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  58101. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  58102. manhattanDistance: boolean;
  58103. /**
  58104. * Creates a new WorleyNoise3DBlock
  58105. * @param name defines the block name
  58106. */
  58107. constructor(name: string);
  58108. /**
  58109. * Gets the current class name
  58110. * @returns the class name
  58111. */
  58112. getClassName(): string;
  58113. /**
  58114. * Gets the seed input component
  58115. */
  58116. get seed(): NodeMaterialConnectionPoint;
  58117. /**
  58118. * Gets the jitter input component
  58119. */
  58120. get jitter(): NodeMaterialConnectionPoint;
  58121. /**
  58122. * Gets the output component
  58123. */
  58124. get output(): NodeMaterialConnectionPoint;
  58125. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58126. /**
  58127. * Exposes the properties to the UI?
  58128. */
  58129. protected _dumpPropertiesCode(): string;
  58130. /**
  58131. * Exposes the properties to the Seralize?
  58132. */
  58133. serialize(): any;
  58134. /**
  58135. * Exposes the properties to the deseralize?
  58136. */
  58137. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58138. }
  58139. }
  58140. declare module BABYLON {
  58141. /**
  58142. * block used to Generate a Simplex Perlin 3d Noise Pattern
  58143. */
  58144. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  58145. /**
  58146. * Creates a new SimplexPerlin3DBlock
  58147. * @param name defines the block name
  58148. */
  58149. constructor(name: string);
  58150. /**
  58151. * Gets the current class name
  58152. * @returns the class name
  58153. */
  58154. getClassName(): string;
  58155. /**
  58156. * Gets the seed operand input component
  58157. */
  58158. get seed(): NodeMaterialConnectionPoint;
  58159. /**
  58160. * Gets the output component
  58161. */
  58162. get output(): NodeMaterialConnectionPoint;
  58163. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58164. }
  58165. }
  58166. declare module BABYLON {
  58167. /**
  58168. * Block used to blend normals
  58169. */
  58170. export class NormalBlendBlock extends NodeMaterialBlock {
  58171. /**
  58172. * Creates a new NormalBlendBlock
  58173. * @param name defines the block name
  58174. */
  58175. constructor(name: string);
  58176. /**
  58177. * Gets the current class name
  58178. * @returns the class name
  58179. */
  58180. getClassName(): string;
  58181. /**
  58182. * Gets the first input component
  58183. */
  58184. get normalMap0(): NodeMaterialConnectionPoint;
  58185. /**
  58186. * Gets the second input component
  58187. */
  58188. get normalMap1(): NodeMaterialConnectionPoint;
  58189. /**
  58190. * Gets the output component
  58191. */
  58192. get output(): NodeMaterialConnectionPoint;
  58193. protected _buildBlock(state: NodeMaterialBuildState): this;
  58194. }
  58195. }
  58196. declare module BABYLON {
  58197. /**
  58198. * Block used to rotate a 2d vector by a given angle
  58199. */
  58200. export class Rotate2dBlock extends NodeMaterialBlock {
  58201. /**
  58202. * Creates a new Rotate2dBlock
  58203. * @param name defines the block name
  58204. */
  58205. constructor(name: string);
  58206. /**
  58207. * Gets the current class name
  58208. * @returns the class name
  58209. */
  58210. getClassName(): string;
  58211. /**
  58212. * Gets the input vector
  58213. */
  58214. get input(): NodeMaterialConnectionPoint;
  58215. /**
  58216. * Gets the input angle
  58217. */
  58218. get angle(): NodeMaterialConnectionPoint;
  58219. /**
  58220. * Gets the output component
  58221. */
  58222. get output(): NodeMaterialConnectionPoint;
  58223. autoConfigure(material: NodeMaterial): void;
  58224. protected _buildBlock(state: NodeMaterialBuildState): this;
  58225. }
  58226. }
  58227. declare module BABYLON {
  58228. /**
  58229. * Block used to get the reflected vector from a direction and a normal
  58230. */
  58231. export class ReflectBlock extends NodeMaterialBlock {
  58232. /**
  58233. * Creates a new ReflectBlock
  58234. * @param name defines the block name
  58235. */
  58236. constructor(name: string);
  58237. /**
  58238. * Gets the current class name
  58239. * @returns the class name
  58240. */
  58241. getClassName(): string;
  58242. /**
  58243. * Gets the incident component
  58244. */
  58245. get incident(): NodeMaterialConnectionPoint;
  58246. /**
  58247. * Gets the normal component
  58248. */
  58249. get normal(): NodeMaterialConnectionPoint;
  58250. /**
  58251. * Gets the output component
  58252. */
  58253. get output(): NodeMaterialConnectionPoint;
  58254. protected _buildBlock(state: NodeMaterialBuildState): this;
  58255. }
  58256. }
  58257. declare module BABYLON {
  58258. /**
  58259. * Block used to get the refracted vector from a direction and a normal
  58260. */
  58261. export class RefractBlock extends NodeMaterialBlock {
  58262. /**
  58263. * Creates a new RefractBlock
  58264. * @param name defines the block name
  58265. */
  58266. constructor(name: string);
  58267. /**
  58268. * Gets the current class name
  58269. * @returns the class name
  58270. */
  58271. getClassName(): string;
  58272. /**
  58273. * Gets the incident component
  58274. */
  58275. get incident(): NodeMaterialConnectionPoint;
  58276. /**
  58277. * Gets the normal component
  58278. */
  58279. get normal(): NodeMaterialConnectionPoint;
  58280. /**
  58281. * Gets the index of refraction component
  58282. */
  58283. get ior(): NodeMaterialConnectionPoint;
  58284. /**
  58285. * Gets the output component
  58286. */
  58287. get output(): NodeMaterialConnectionPoint;
  58288. protected _buildBlock(state: NodeMaterialBuildState): this;
  58289. }
  58290. }
  58291. declare module BABYLON {
  58292. /**
  58293. * Block used to desaturate a color
  58294. */
  58295. export class DesaturateBlock extends NodeMaterialBlock {
  58296. /**
  58297. * Creates a new DesaturateBlock
  58298. * @param name defines the block name
  58299. */
  58300. constructor(name: string);
  58301. /**
  58302. * Gets the current class name
  58303. * @returns the class name
  58304. */
  58305. getClassName(): string;
  58306. /**
  58307. * Gets the color operand input component
  58308. */
  58309. get color(): NodeMaterialConnectionPoint;
  58310. /**
  58311. * Gets the level operand input component
  58312. */
  58313. get level(): NodeMaterialConnectionPoint;
  58314. /**
  58315. * Gets the output component
  58316. */
  58317. get output(): NodeMaterialConnectionPoint;
  58318. protected _buildBlock(state: NodeMaterialBuildState): this;
  58319. }
  58320. }
  58321. declare module BABYLON {
  58322. /**
  58323. * Effect Render Options
  58324. */
  58325. export interface IEffectRendererOptions {
  58326. /**
  58327. * Defines the vertices positions.
  58328. */
  58329. positions?: number[];
  58330. /**
  58331. * Defines the indices.
  58332. */
  58333. indices?: number[];
  58334. }
  58335. /**
  58336. * Helper class to render one or more effects
  58337. */
  58338. export class EffectRenderer {
  58339. private engine;
  58340. private static _DefaultOptions;
  58341. private _vertexBuffers;
  58342. private _indexBuffer;
  58343. private _ringBufferIndex;
  58344. private _ringScreenBuffer;
  58345. private _fullscreenViewport;
  58346. private _getNextFrameBuffer;
  58347. /**
  58348. * Creates an effect renderer
  58349. * @param engine the engine to use for rendering
  58350. * @param options defines the options of the effect renderer
  58351. */
  58352. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  58353. /**
  58354. * Sets the current viewport in normalized coordinates 0-1
  58355. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  58356. */
  58357. setViewport(viewport?: Viewport): void;
  58358. /**
  58359. * Binds the embedded attributes buffer to the effect.
  58360. * @param effect Defines the effect to bind the attributes for
  58361. */
  58362. bindBuffers(effect: Effect): void;
  58363. /**
  58364. * Sets the current effect wrapper to use during draw.
  58365. * The effect needs to be ready before calling this api.
  58366. * This also sets the default full screen position attribute.
  58367. * @param effectWrapper Defines the effect to draw with
  58368. */
  58369. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  58370. /**
  58371. * Draws a full screen quad.
  58372. */
  58373. draw(): void;
  58374. /**
  58375. * renders one or more effects to a specified texture
  58376. * @param effectWrappers list of effects to renderer
  58377. * @param outputTexture texture to draw to, if null it will render to the screen
  58378. */
  58379. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  58380. /**
  58381. * Disposes of the effect renderer
  58382. */
  58383. dispose(): void;
  58384. }
  58385. /**
  58386. * Options to create an EffectWrapper
  58387. */
  58388. interface EffectWrapperCreationOptions {
  58389. /**
  58390. * Engine to use to create the effect
  58391. */
  58392. engine: ThinEngine;
  58393. /**
  58394. * Fragment shader for the effect
  58395. */
  58396. fragmentShader: string;
  58397. /**
  58398. * Vertex shader for the effect
  58399. */
  58400. vertexShader?: string;
  58401. /**
  58402. * Attributes to use in the shader
  58403. */
  58404. attributeNames?: Array<string>;
  58405. /**
  58406. * Uniforms to use in the shader
  58407. */
  58408. uniformNames?: Array<string>;
  58409. /**
  58410. * Texture sampler names to use in the shader
  58411. */
  58412. samplerNames?: Array<string>;
  58413. /**
  58414. * The friendly name of the effect displayed in Spector.
  58415. */
  58416. name?: string;
  58417. }
  58418. /**
  58419. * Wraps an effect to be used for rendering
  58420. */
  58421. export class EffectWrapper {
  58422. /**
  58423. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  58424. */
  58425. onApplyObservable: Observable<{}>;
  58426. /**
  58427. * The underlying effect
  58428. */
  58429. effect: Effect;
  58430. /**
  58431. * Creates an effect to be renderer
  58432. * @param creationOptions options to create the effect
  58433. */
  58434. constructor(creationOptions: EffectWrapperCreationOptions);
  58435. /**
  58436. * Disposes of the effect wrapper
  58437. */
  58438. dispose(): void;
  58439. }
  58440. }
  58441. declare module BABYLON {
  58442. /**
  58443. * Helper class to push actions to a pool of workers.
  58444. */
  58445. export class WorkerPool implements IDisposable {
  58446. private _workerInfos;
  58447. private _pendingActions;
  58448. /**
  58449. * Constructor
  58450. * @param workers Array of workers to use for actions
  58451. */
  58452. constructor(workers: Array<Worker>);
  58453. /**
  58454. * Terminates all workers and clears any pending actions.
  58455. */
  58456. dispose(): void;
  58457. /**
  58458. * Pushes an action to the worker pool. If all the workers are active, the action will be
  58459. * pended until a worker has completed its action.
  58460. * @param action The action to perform. Call onComplete when the action is complete.
  58461. */
  58462. push(action: (worker: Worker, onComplete: () => void) => void): void;
  58463. private _execute;
  58464. }
  58465. }
  58466. declare module BABYLON {
  58467. /**
  58468. * Configuration for Draco compression
  58469. */
  58470. export interface IDracoCompressionConfiguration {
  58471. /**
  58472. * Configuration for the decoder.
  58473. */
  58474. decoder: {
  58475. /**
  58476. * The url to the WebAssembly module.
  58477. */
  58478. wasmUrl?: string;
  58479. /**
  58480. * The url to the WebAssembly binary.
  58481. */
  58482. wasmBinaryUrl?: string;
  58483. /**
  58484. * The url to the fallback JavaScript module.
  58485. */
  58486. fallbackUrl?: string;
  58487. };
  58488. }
  58489. /**
  58490. * Draco compression (https://google.github.io/draco/)
  58491. *
  58492. * This class wraps the Draco module.
  58493. *
  58494. * **Encoder**
  58495. *
  58496. * The encoder is not currently implemented.
  58497. *
  58498. * **Decoder**
  58499. *
  58500. * 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.
  58501. *
  58502. * To update the configuration, use the following code:
  58503. * ```javascript
  58504. * DracoCompression.Configuration = {
  58505. * decoder: {
  58506. * wasmUrl: "<url to the WebAssembly library>",
  58507. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  58508. * fallbackUrl: "<url to the fallback JavaScript library>",
  58509. * }
  58510. * };
  58511. * ```
  58512. *
  58513. * 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.
  58514. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  58515. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  58516. *
  58517. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  58518. * ```javascript
  58519. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  58520. * ```
  58521. *
  58522. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  58523. */
  58524. export class DracoCompression implements IDisposable {
  58525. private _workerPoolPromise?;
  58526. private _decoderModulePromise?;
  58527. /**
  58528. * The configuration. Defaults to the following urls:
  58529. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  58530. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  58531. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  58532. */
  58533. static Configuration: IDracoCompressionConfiguration;
  58534. /**
  58535. * Returns true if the decoder configuration is available.
  58536. */
  58537. static get DecoderAvailable(): boolean;
  58538. /**
  58539. * Default number of workers to create when creating the draco compression object.
  58540. */
  58541. static DefaultNumWorkers: number;
  58542. private static GetDefaultNumWorkers;
  58543. private static _Default;
  58544. /**
  58545. * Default instance for the draco compression object.
  58546. */
  58547. static get Default(): DracoCompression;
  58548. /**
  58549. * Constructor
  58550. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  58551. */
  58552. constructor(numWorkers?: number);
  58553. /**
  58554. * Stop all async operations and release resources.
  58555. */
  58556. dispose(): void;
  58557. /**
  58558. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  58559. * @returns a promise that resolves when ready
  58560. */
  58561. whenReadyAsync(): Promise<void>;
  58562. /**
  58563. * Decode Draco compressed mesh data to vertex data.
  58564. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  58565. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  58566. * @returns A promise that resolves with the decoded vertex data
  58567. */
  58568. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  58569. [kind: string]: number;
  58570. }): Promise<VertexData>;
  58571. }
  58572. }
  58573. declare module BABYLON {
  58574. /**
  58575. * Class for building Constructive Solid Geometry
  58576. */
  58577. export class CSG {
  58578. private polygons;
  58579. /**
  58580. * The world matrix
  58581. */
  58582. matrix: Matrix;
  58583. /**
  58584. * Stores the position
  58585. */
  58586. position: Vector3;
  58587. /**
  58588. * Stores the rotation
  58589. */
  58590. rotation: Vector3;
  58591. /**
  58592. * Stores the rotation quaternion
  58593. */
  58594. rotationQuaternion: Nullable<Quaternion>;
  58595. /**
  58596. * Stores the scaling vector
  58597. */
  58598. scaling: Vector3;
  58599. /**
  58600. * Convert the Mesh to CSG
  58601. * @param mesh The Mesh to convert to CSG
  58602. * @returns A new CSG from the Mesh
  58603. */
  58604. static FromMesh(mesh: Mesh): CSG;
  58605. /**
  58606. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  58607. * @param polygons Polygons used to construct a CSG solid
  58608. */
  58609. private static FromPolygons;
  58610. /**
  58611. * Clones, or makes a deep copy, of the CSG
  58612. * @returns A new CSG
  58613. */
  58614. clone(): CSG;
  58615. /**
  58616. * Unions this CSG with another CSG
  58617. * @param csg The CSG to union against this CSG
  58618. * @returns The unioned CSG
  58619. */
  58620. union(csg: CSG): CSG;
  58621. /**
  58622. * Unions this CSG with another CSG in place
  58623. * @param csg The CSG to union against this CSG
  58624. */
  58625. unionInPlace(csg: CSG): void;
  58626. /**
  58627. * Subtracts this CSG with another CSG
  58628. * @param csg The CSG to subtract against this CSG
  58629. * @returns A new CSG
  58630. */
  58631. subtract(csg: CSG): CSG;
  58632. /**
  58633. * Subtracts this CSG with another CSG in place
  58634. * @param csg The CSG to subtact against this CSG
  58635. */
  58636. subtractInPlace(csg: CSG): void;
  58637. /**
  58638. * Intersect this CSG with another CSG
  58639. * @param csg The CSG to intersect against this CSG
  58640. * @returns A new CSG
  58641. */
  58642. intersect(csg: CSG): CSG;
  58643. /**
  58644. * Intersects this CSG with another CSG in place
  58645. * @param csg The CSG to intersect against this CSG
  58646. */
  58647. intersectInPlace(csg: CSG): void;
  58648. /**
  58649. * Return a new CSG solid with solid and empty space switched. This solid is
  58650. * not modified.
  58651. * @returns A new CSG solid with solid and empty space switched
  58652. */
  58653. inverse(): CSG;
  58654. /**
  58655. * Inverses the CSG in place
  58656. */
  58657. inverseInPlace(): void;
  58658. /**
  58659. * This is used to keep meshes transformations so they can be restored
  58660. * when we build back a Babylon Mesh
  58661. * NB : All CSG operations are performed in world coordinates
  58662. * @param csg The CSG to copy the transform attributes from
  58663. * @returns This CSG
  58664. */
  58665. copyTransformAttributes(csg: CSG): CSG;
  58666. /**
  58667. * Build Raw mesh from CSG
  58668. * Coordinates here are in world space
  58669. * @param name The name of the mesh geometry
  58670. * @param scene The Scene
  58671. * @param keepSubMeshes Specifies if the submeshes should be kept
  58672. * @returns A new Mesh
  58673. */
  58674. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  58675. /**
  58676. * Build Mesh from CSG taking material and transforms into account
  58677. * @param name The name of the Mesh
  58678. * @param material The material of the Mesh
  58679. * @param scene The Scene
  58680. * @param keepSubMeshes Specifies if submeshes should be kept
  58681. * @returns The new Mesh
  58682. */
  58683. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  58684. }
  58685. }
  58686. declare module BABYLON {
  58687. /**
  58688. * Class used to create a trail following a mesh
  58689. */
  58690. export class TrailMesh extends Mesh {
  58691. private _generator;
  58692. private _autoStart;
  58693. private _running;
  58694. private _diameter;
  58695. private _length;
  58696. private _sectionPolygonPointsCount;
  58697. private _sectionVectors;
  58698. private _sectionNormalVectors;
  58699. private _beforeRenderObserver;
  58700. /**
  58701. * @constructor
  58702. * @param name The value used by scene.getMeshByName() to do a lookup.
  58703. * @param generator The mesh to generate a trail.
  58704. * @param scene The scene to add this mesh to.
  58705. * @param diameter Diameter of trailing mesh. Default is 1.
  58706. * @param length Length of trailing mesh. Default is 60.
  58707. * @param autoStart Automatically start trailing mesh. Default true.
  58708. */
  58709. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  58710. /**
  58711. * "TrailMesh"
  58712. * @returns "TrailMesh"
  58713. */
  58714. getClassName(): string;
  58715. private _createMesh;
  58716. /**
  58717. * Start trailing mesh.
  58718. */
  58719. start(): void;
  58720. /**
  58721. * Stop trailing mesh.
  58722. */
  58723. stop(): void;
  58724. /**
  58725. * Update trailing mesh geometry.
  58726. */
  58727. update(): void;
  58728. /**
  58729. * Returns a new TrailMesh object.
  58730. * @param name is a string, the name given to the new mesh
  58731. * @param newGenerator use new generator object for cloned trail mesh
  58732. * @returns a new mesh
  58733. */
  58734. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  58735. /**
  58736. * Serializes this trail mesh
  58737. * @param serializationObject object to write serialization to
  58738. */
  58739. serialize(serializationObject: any): void;
  58740. /**
  58741. * Parses a serialized trail mesh
  58742. * @param parsedMesh the serialized mesh
  58743. * @param scene the scene to create the trail mesh in
  58744. * @returns the created trail mesh
  58745. */
  58746. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  58747. }
  58748. }
  58749. declare module BABYLON {
  58750. /**
  58751. * Class containing static functions to help procedurally build meshes
  58752. */
  58753. export class TiledBoxBuilder {
  58754. /**
  58755. * Creates a box mesh
  58756. * 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)
  58757. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  58758. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58759. * * 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
  58760. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58761. * @param name defines the name of the mesh
  58762. * @param options defines the options used to create the mesh
  58763. * @param scene defines the hosting scene
  58764. * @returns the box mesh
  58765. */
  58766. static CreateTiledBox(name: string, options: {
  58767. pattern?: number;
  58768. width?: number;
  58769. height?: number;
  58770. depth?: number;
  58771. tileSize?: number;
  58772. tileWidth?: number;
  58773. tileHeight?: number;
  58774. alignHorizontal?: number;
  58775. alignVertical?: number;
  58776. faceUV?: Vector4[];
  58777. faceColors?: Color4[];
  58778. sideOrientation?: number;
  58779. updatable?: boolean;
  58780. }, scene?: Nullable<Scene>): Mesh;
  58781. }
  58782. }
  58783. declare module BABYLON {
  58784. /**
  58785. * Class containing static functions to help procedurally build meshes
  58786. */
  58787. export class TorusKnotBuilder {
  58788. /**
  58789. * Creates a torus knot mesh
  58790. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  58791. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  58792. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  58793. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  58794. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58795. * * 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
  58796. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58797. * @param name defines the name of the mesh
  58798. * @param options defines the options used to create the mesh
  58799. * @param scene defines the hosting scene
  58800. * @returns the torus knot mesh
  58801. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  58802. */
  58803. static CreateTorusKnot(name: string, options: {
  58804. radius?: number;
  58805. tube?: number;
  58806. radialSegments?: number;
  58807. tubularSegments?: number;
  58808. p?: number;
  58809. q?: number;
  58810. updatable?: boolean;
  58811. sideOrientation?: number;
  58812. frontUVs?: Vector4;
  58813. backUVs?: Vector4;
  58814. }, scene: any): Mesh;
  58815. }
  58816. }
  58817. declare module BABYLON {
  58818. /**
  58819. * Polygon
  58820. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  58821. */
  58822. export class Polygon {
  58823. /**
  58824. * Creates a rectangle
  58825. * @param xmin bottom X coord
  58826. * @param ymin bottom Y coord
  58827. * @param xmax top X coord
  58828. * @param ymax top Y coord
  58829. * @returns points that make the resulting rectation
  58830. */
  58831. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  58832. /**
  58833. * Creates a circle
  58834. * @param radius radius of circle
  58835. * @param cx scale in x
  58836. * @param cy scale in y
  58837. * @param numberOfSides number of sides that make up the circle
  58838. * @returns points that make the resulting circle
  58839. */
  58840. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  58841. /**
  58842. * Creates a polygon from input string
  58843. * @param input Input polygon data
  58844. * @returns the parsed points
  58845. */
  58846. static Parse(input: string): Vector2[];
  58847. /**
  58848. * Starts building a polygon from x and y coordinates
  58849. * @param x x coordinate
  58850. * @param y y coordinate
  58851. * @returns the started path2
  58852. */
  58853. static StartingAt(x: number, y: number): Path2;
  58854. }
  58855. /**
  58856. * Builds a polygon
  58857. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  58858. */
  58859. export class PolygonMeshBuilder {
  58860. private _points;
  58861. private _outlinepoints;
  58862. private _holes;
  58863. private _name;
  58864. private _scene;
  58865. private _epoints;
  58866. private _eholes;
  58867. private _addToepoint;
  58868. /**
  58869. * Babylon reference to the earcut plugin.
  58870. */
  58871. bjsEarcut: any;
  58872. /**
  58873. * Creates a PolygonMeshBuilder
  58874. * @param name name of the builder
  58875. * @param contours Path of the polygon
  58876. * @param scene scene to add to when creating the mesh
  58877. * @param earcutInjection can be used to inject your own earcut reference
  58878. */
  58879. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  58880. /**
  58881. * Adds a whole within the polygon
  58882. * @param hole Array of points defining the hole
  58883. * @returns this
  58884. */
  58885. addHole(hole: Vector2[]): PolygonMeshBuilder;
  58886. /**
  58887. * Creates the polygon
  58888. * @param updatable If the mesh should be updatable
  58889. * @param depth The depth of the mesh created
  58890. * @returns the created mesh
  58891. */
  58892. build(updatable?: boolean, depth?: number): Mesh;
  58893. /**
  58894. * Creates the polygon
  58895. * @param depth The depth of the mesh created
  58896. * @returns the created VertexData
  58897. */
  58898. buildVertexData(depth?: number): VertexData;
  58899. /**
  58900. * Adds a side to the polygon
  58901. * @param positions points that make the polygon
  58902. * @param normals normals of the polygon
  58903. * @param uvs uvs of the polygon
  58904. * @param indices indices of the polygon
  58905. * @param bounds bounds of the polygon
  58906. * @param points points of the polygon
  58907. * @param depth depth of the polygon
  58908. * @param flip flip of the polygon
  58909. */
  58910. private addSide;
  58911. }
  58912. }
  58913. declare module BABYLON {
  58914. /**
  58915. * Class containing static functions to help procedurally build meshes
  58916. */
  58917. export class PolygonBuilder {
  58918. /**
  58919. * Creates a polygon mesh
  58920. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  58921. * * 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
  58922. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  58923. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58924. * * 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)
  58925. * * Remember you can only change the shape positions, not their number when updating a polygon
  58926. * @param name defines the name of the mesh
  58927. * @param options defines the options used to create the mesh
  58928. * @param scene defines the hosting scene
  58929. * @param earcutInjection can be used to inject your own earcut reference
  58930. * @returns the polygon mesh
  58931. */
  58932. static CreatePolygon(name: string, options: {
  58933. shape: Vector3[];
  58934. holes?: Vector3[][];
  58935. depth?: number;
  58936. faceUV?: Vector4[];
  58937. faceColors?: Color4[];
  58938. updatable?: boolean;
  58939. sideOrientation?: number;
  58940. frontUVs?: Vector4;
  58941. backUVs?: Vector4;
  58942. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  58943. /**
  58944. * Creates an extruded polygon mesh, with depth in the Y direction.
  58945. * * 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)
  58946. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  58947. * @param name defines the name of the mesh
  58948. * @param options defines the options used to create the mesh
  58949. * @param scene defines the hosting scene
  58950. * @param earcutInjection can be used to inject your own earcut reference
  58951. * @returns the polygon mesh
  58952. */
  58953. static ExtrudePolygon(name: string, options: {
  58954. shape: Vector3[];
  58955. holes?: Vector3[][];
  58956. depth?: number;
  58957. faceUV?: Vector4[];
  58958. faceColors?: Color4[];
  58959. updatable?: boolean;
  58960. sideOrientation?: number;
  58961. frontUVs?: Vector4;
  58962. backUVs?: Vector4;
  58963. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  58964. }
  58965. }
  58966. declare module BABYLON {
  58967. /**
  58968. * Class containing static functions to help procedurally build meshes
  58969. */
  58970. export class LatheBuilder {
  58971. /**
  58972. * Creates lathe mesh.
  58973. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  58974. * * 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
  58975. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  58976. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  58977. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  58978. * * 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
  58979. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  58980. * * 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
  58981. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58982. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58983. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58984. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58985. * @param name defines the name of the mesh
  58986. * @param options defines the options used to create the mesh
  58987. * @param scene defines the hosting scene
  58988. * @returns the lathe mesh
  58989. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  58990. */
  58991. static CreateLathe(name: string, options: {
  58992. shape: Vector3[];
  58993. radius?: number;
  58994. tessellation?: number;
  58995. clip?: number;
  58996. arc?: number;
  58997. closed?: boolean;
  58998. updatable?: boolean;
  58999. sideOrientation?: number;
  59000. frontUVs?: Vector4;
  59001. backUVs?: Vector4;
  59002. cap?: number;
  59003. invertUV?: boolean;
  59004. }, scene?: Nullable<Scene>): Mesh;
  59005. }
  59006. }
  59007. declare module BABYLON {
  59008. /**
  59009. * Class containing static functions to help procedurally build meshes
  59010. */
  59011. export class TiledPlaneBuilder {
  59012. /**
  59013. * Creates a tiled plane mesh
  59014. * * The parameter `pattern` will, depending on value, do nothing or
  59015. * * * flip (reflect about central vertical) alternate tiles across and up
  59016. * * * flip every tile on alternate rows
  59017. * * * rotate (180 degs) alternate tiles across and up
  59018. * * * rotate every tile on alternate rows
  59019. * * * flip and rotate alternate tiles across and up
  59020. * * * flip and rotate every tile on alternate rows
  59021. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  59022. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  59023. * * 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
  59024. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  59025. * * 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)
  59026. * * 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)
  59027. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  59028. * @param name defines the name of the mesh
  59029. * @param options defines the options used to create the mesh
  59030. * @param scene defines the hosting scene
  59031. * @returns the box mesh
  59032. */
  59033. static CreateTiledPlane(name: string, options: {
  59034. pattern?: number;
  59035. tileSize?: number;
  59036. tileWidth?: number;
  59037. tileHeight?: number;
  59038. size?: number;
  59039. width?: number;
  59040. height?: number;
  59041. alignHorizontal?: number;
  59042. alignVertical?: number;
  59043. sideOrientation?: number;
  59044. frontUVs?: Vector4;
  59045. backUVs?: Vector4;
  59046. updatable?: boolean;
  59047. }, scene?: Nullable<Scene>): Mesh;
  59048. }
  59049. }
  59050. declare module BABYLON {
  59051. /**
  59052. * Class containing static functions to help procedurally build meshes
  59053. */
  59054. export class TubeBuilder {
  59055. /**
  59056. * Creates a tube mesh.
  59057. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  59058. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  59059. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  59060. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  59061. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  59062. * * 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)
  59063. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  59064. * * 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
  59065. * * 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
  59066. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59067. * * 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
  59068. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59069. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59070. * @param name defines the name of the mesh
  59071. * @param options defines the options used to create the mesh
  59072. * @param scene defines the hosting scene
  59073. * @returns the tube mesh
  59074. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59075. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  59076. */
  59077. static CreateTube(name: string, options: {
  59078. path: Vector3[];
  59079. radius?: number;
  59080. tessellation?: number;
  59081. radiusFunction?: {
  59082. (i: number, distance: number): number;
  59083. };
  59084. cap?: number;
  59085. arc?: number;
  59086. updatable?: boolean;
  59087. sideOrientation?: number;
  59088. frontUVs?: Vector4;
  59089. backUVs?: Vector4;
  59090. instance?: Mesh;
  59091. invertUV?: boolean;
  59092. }, scene?: Nullable<Scene>): Mesh;
  59093. }
  59094. }
  59095. declare module BABYLON {
  59096. /**
  59097. * Class containing static functions to help procedurally build meshes
  59098. */
  59099. export class IcoSphereBuilder {
  59100. /**
  59101. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  59102. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  59103. * * 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`)
  59104. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  59105. * * 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
  59106. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59107. * * 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
  59108. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59109. * @param name defines the name of the mesh
  59110. * @param options defines the options used to create the mesh
  59111. * @param scene defines the hosting scene
  59112. * @returns the icosahedron mesh
  59113. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  59114. */
  59115. static CreateIcoSphere(name: string, options: {
  59116. radius?: number;
  59117. radiusX?: number;
  59118. radiusY?: number;
  59119. radiusZ?: number;
  59120. flat?: boolean;
  59121. subdivisions?: number;
  59122. sideOrientation?: number;
  59123. frontUVs?: Vector4;
  59124. backUVs?: Vector4;
  59125. updatable?: boolean;
  59126. }, scene?: Nullable<Scene>): Mesh;
  59127. }
  59128. }
  59129. declare module BABYLON {
  59130. /**
  59131. * Class containing static functions to help procedurally build meshes
  59132. */
  59133. export class DecalBuilder {
  59134. /**
  59135. * Creates a decal mesh.
  59136. * 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
  59137. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  59138. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  59139. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  59140. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  59141. * @param name defines the name of the mesh
  59142. * @param sourceMesh defines the mesh where the decal must be applied
  59143. * @param options defines the options used to create the mesh
  59144. * @param scene defines the hosting scene
  59145. * @returns the decal mesh
  59146. * @see https://doc.babylonjs.com/how_to/decals
  59147. */
  59148. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  59149. position?: Vector3;
  59150. normal?: Vector3;
  59151. size?: Vector3;
  59152. angle?: number;
  59153. }): Mesh;
  59154. }
  59155. }
  59156. declare module BABYLON {
  59157. /**
  59158. * Class containing static functions to help procedurally build meshes
  59159. */
  59160. export class MeshBuilder {
  59161. /**
  59162. * Creates a box mesh
  59163. * * The parameter `size` sets the size (float) of each box side (default 1)
  59164. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  59165. * * 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)
  59166. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  59167. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59168. * * 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
  59169. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59170. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  59171. * @param name defines the name of the mesh
  59172. * @param options defines the options used to create the mesh
  59173. * @param scene defines the hosting scene
  59174. * @returns the box mesh
  59175. */
  59176. static CreateBox(name: string, options: {
  59177. size?: number;
  59178. width?: number;
  59179. height?: number;
  59180. depth?: number;
  59181. faceUV?: Vector4[];
  59182. faceColors?: Color4[];
  59183. sideOrientation?: number;
  59184. frontUVs?: Vector4;
  59185. backUVs?: Vector4;
  59186. updatable?: boolean;
  59187. }, scene?: Nullable<Scene>): Mesh;
  59188. /**
  59189. * Creates a tiled box mesh
  59190. * * faceTiles sets the pattern, tile size and number of tiles for a face
  59191. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59192. * @param name defines the name of the mesh
  59193. * @param options defines the options used to create the mesh
  59194. * @param scene defines the hosting scene
  59195. * @returns the tiled box mesh
  59196. */
  59197. static CreateTiledBox(name: string, options: {
  59198. pattern?: number;
  59199. size?: number;
  59200. width?: number;
  59201. height?: number;
  59202. depth: number;
  59203. tileSize?: number;
  59204. tileWidth?: number;
  59205. tileHeight?: number;
  59206. faceUV?: Vector4[];
  59207. faceColors?: Color4[];
  59208. alignHorizontal?: number;
  59209. alignVertical?: number;
  59210. sideOrientation?: number;
  59211. updatable?: boolean;
  59212. }, scene?: Nullable<Scene>): Mesh;
  59213. /**
  59214. * Creates a sphere mesh
  59215. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  59216. * * 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`)
  59217. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  59218. * * 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
  59219. * * 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)
  59220. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59221. * * 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
  59222. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59223. * @param name defines the name of the mesh
  59224. * @param options defines the options used to create the mesh
  59225. * @param scene defines the hosting scene
  59226. * @returns the sphere mesh
  59227. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  59228. */
  59229. static CreateSphere(name: string, options: {
  59230. segments?: number;
  59231. diameter?: number;
  59232. diameterX?: number;
  59233. diameterY?: number;
  59234. diameterZ?: number;
  59235. arc?: number;
  59236. slice?: number;
  59237. sideOrientation?: number;
  59238. frontUVs?: Vector4;
  59239. backUVs?: Vector4;
  59240. updatable?: boolean;
  59241. }, scene?: Nullable<Scene>): Mesh;
  59242. /**
  59243. * Creates a plane polygonal mesh. By default, this is a disc
  59244. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  59245. * * 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
  59246. * * 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
  59247. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59248. * * 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
  59249. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59250. * @param name defines the name of the mesh
  59251. * @param options defines the options used to create the mesh
  59252. * @param scene defines the hosting scene
  59253. * @returns the plane polygonal mesh
  59254. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  59255. */
  59256. static CreateDisc(name: string, options: {
  59257. radius?: number;
  59258. tessellation?: number;
  59259. arc?: number;
  59260. updatable?: boolean;
  59261. sideOrientation?: number;
  59262. frontUVs?: Vector4;
  59263. backUVs?: Vector4;
  59264. }, scene?: Nullable<Scene>): Mesh;
  59265. /**
  59266. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  59267. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  59268. * * 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`)
  59269. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  59270. * * 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
  59271. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59272. * * 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
  59273. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59274. * @param name defines the name of the mesh
  59275. * @param options defines the options used to create the mesh
  59276. * @param scene defines the hosting scene
  59277. * @returns the icosahedron mesh
  59278. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  59279. */
  59280. static CreateIcoSphere(name: string, options: {
  59281. radius?: number;
  59282. radiusX?: number;
  59283. radiusY?: number;
  59284. radiusZ?: number;
  59285. flat?: boolean;
  59286. subdivisions?: number;
  59287. sideOrientation?: number;
  59288. frontUVs?: Vector4;
  59289. backUVs?: Vector4;
  59290. updatable?: boolean;
  59291. }, scene?: Nullable<Scene>): Mesh;
  59292. /**
  59293. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  59294. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  59295. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  59296. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  59297. * * 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
  59298. * * 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
  59299. * * 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
  59300. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59301. * * 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
  59302. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59303. * * 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
  59304. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  59305. * * 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
  59306. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  59307. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59308. * @param name defines the name of the mesh
  59309. * @param options defines the options used to create the mesh
  59310. * @param scene defines the hosting scene
  59311. * @returns the ribbon mesh
  59312. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  59313. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59314. */
  59315. static CreateRibbon(name: string, options: {
  59316. pathArray: Vector3[][];
  59317. closeArray?: boolean;
  59318. closePath?: boolean;
  59319. offset?: number;
  59320. updatable?: boolean;
  59321. sideOrientation?: number;
  59322. frontUVs?: Vector4;
  59323. backUVs?: Vector4;
  59324. instance?: Mesh;
  59325. invertUV?: boolean;
  59326. uvs?: Vector2[];
  59327. colors?: Color4[];
  59328. }, scene?: Nullable<Scene>): Mesh;
  59329. /**
  59330. * Creates a cylinder or a cone mesh
  59331. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  59332. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  59333. * * 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.
  59334. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  59335. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  59336. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  59337. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  59338. * * 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).
  59339. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  59340. * * 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).
  59341. * * 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
  59342. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  59343. * * 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
  59344. * * 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.
  59345. * * If `enclose` is false, a ring surface is one element.
  59346. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  59347. * * 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
  59348. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59349. * * 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
  59350. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59351. * @param name defines the name of the mesh
  59352. * @param options defines the options used to create the mesh
  59353. * @param scene defines the hosting scene
  59354. * @returns the cylinder mesh
  59355. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  59356. */
  59357. static CreateCylinder(name: string, options: {
  59358. height?: number;
  59359. diameterTop?: number;
  59360. diameterBottom?: number;
  59361. diameter?: number;
  59362. tessellation?: number;
  59363. subdivisions?: number;
  59364. arc?: number;
  59365. faceColors?: Color4[];
  59366. faceUV?: Vector4[];
  59367. updatable?: boolean;
  59368. hasRings?: boolean;
  59369. enclose?: boolean;
  59370. cap?: number;
  59371. sideOrientation?: number;
  59372. frontUVs?: Vector4;
  59373. backUVs?: Vector4;
  59374. }, scene?: Nullable<Scene>): Mesh;
  59375. /**
  59376. * Creates a torus mesh
  59377. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  59378. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  59379. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  59380. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59381. * * 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
  59382. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59383. * @param name defines the name of the mesh
  59384. * @param options defines the options used to create the mesh
  59385. * @param scene defines the hosting scene
  59386. * @returns the torus mesh
  59387. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  59388. */
  59389. static CreateTorus(name: string, options: {
  59390. diameter?: number;
  59391. thickness?: number;
  59392. tessellation?: number;
  59393. updatable?: boolean;
  59394. sideOrientation?: number;
  59395. frontUVs?: Vector4;
  59396. backUVs?: Vector4;
  59397. }, scene?: Nullable<Scene>): Mesh;
  59398. /**
  59399. * Creates a torus knot mesh
  59400. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  59401. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  59402. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  59403. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  59404. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59405. * * 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
  59406. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59407. * @param name defines the name of the mesh
  59408. * @param options defines the options used to create the mesh
  59409. * @param scene defines the hosting scene
  59410. * @returns the torus knot mesh
  59411. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  59412. */
  59413. static CreateTorusKnot(name: string, options: {
  59414. radius?: number;
  59415. tube?: number;
  59416. radialSegments?: number;
  59417. tubularSegments?: number;
  59418. p?: number;
  59419. q?: number;
  59420. updatable?: boolean;
  59421. sideOrientation?: number;
  59422. frontUVs?: Vector4;
  59423. backUVs?: Vector4;
  59424. }, scene?: Nullable<Scene>): Mesh;
  59425. /**
  59426. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  59427. * * 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
  59428. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  59429. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  59430. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  59431. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  59432. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  59433. * * 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
  59434. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  59435. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59436. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  59437. * @param name defines the name of the new line system
  59438. * @param options defines the options used to create the line system
  59439. * @param scene defines the hosting scene
  59440. * @returns a new line system mesh
  59441. */
  59442. static CreateLineSystem(name: string, options: {
  59443. lines: Vector3[][];
  59444. updatable?: boolean;
  59445. instance?: Nullable<LinesMesh>;
  59446. colors?: Nullable<Color4[][]>;
  59447. useVertexAlpha?: boolean;
  59448. }, scene: Nullable<Scene>): LinesMesh;
  59449. /**
  59450. * Creates a line mesh
  59451. * 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
  59452. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  59453. * * The parameter `points` is an array successive Vector3
  59454. * * 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
  59455. * * The optional parameter `colors` is an array of successive Color4, one per line point
  59456. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  59457. * * When updating an instance, remember that only point positions can change, not the number of points
  59458. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59459. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  59460. * @param name defines the name of the new line system
  59461. * @param options defines the options used to create the line system
  59462. * @param scene defines the hosting scene
  59463. * @returns a new line mesh
  59464. */
  59465. static CreateLines(name: string, options: {
  59466. points: Vector3[];
  59467. updatable?: boolean;
  59468. instance?: Nullable<LinesMesh>;
  59469. colors?: Color4[];
  59470. useVertexAlpha?: boolean;
  59471. }, scene?: Nullable<Scene>): LinesMesh;
  59472. /**
  59473. * Creates a dashed line mesh
  59474. * * 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
  59475. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  59476. * * The parameter `points` is an array successive Vector3
  59477. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  59478. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  59479. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  59480. * * 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
  59481. * * When updating an instance, remember that only point positions can change, not the number of points
  59482. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59483. * @param name defines the name of the mesh
  59484. * @param options defines the options used to create the mesh
  59485. * @param scene defines the hosting scene
  59486. * @returns the dashed line mesh
  59487. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  59488. */
  59489. static CreateDashedLines(name: string, options: {
  59490. points: Vector3[];
  59491. dashSize?: number;
  59492. gapSize?: number;
  59493. dashNb?: number;
  59494. updatable?: boolean;
  59495. instance?: LinesMesh;
  59496. }, scene?: Nullable<Scene>): LinesMesh;
  59497. /**
  59498. * 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.
  59499. * * 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.
  59500. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  59501. * * 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.
  59502. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  59503. * * 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
  59504. * * 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
  59505. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  59506. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59507. * * 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
  59508. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  59509. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59510. * @param name defines the name of the mesh
  59511. * @param options defines the options used to create the mesh
  59512. * @param scene defines the hosting scene
  59513. * @returns the extruded shape mesh
  59514. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59515. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  59516. */
  59517. static ExtrudeShape(name: string, options: {
  59518. shape: Vector3[];
  59519. path: Vector3[];
  59520. scale?: number;
  59521. rotation?: number;
  59522. cap?: number;
  59523. updatable?: boolean;
  59524. sideOrientation?: number;
  59525. frontUVs?: Vector4;
  59526. backUVs?: Vector4;
  59527. instance?: Mesh;
  59528. invertUV?: boolean;
  59529. }, scene?: Nullable<Scene>): Mesh;
  59530. /**
  59531. * Creates an custom extruded shape mesh.
  59532. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  59533. * * 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.
  59534. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  59535. * * 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
  59536. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  59537. * * 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
  59538. * * It must returns a float value that will be the scale value applied to the shape on each path point
  59539. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  59540. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  59541. * * 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
  59542. * * 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
  59543. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  59544. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59545. * * 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
  59546. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59547. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59548. * @param name defines the name of the mesh
  59549. * @param options defines the options used to create the mesh
  59550. * @param scene defines the hosting scene
  59551. * @returns the custom extruded shape mesh
  59552. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  59553. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59554. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  59555. */
  59556. static ExtrudeShapeCustom(name: string, options: {
  59557. shape: Vector3[];
  59558. path: Vector3[];
  59559. scaleFunction?: any;
  59560. rotationFunction?: any;
  59561. ribbonCloseArray?: boolean;
  59562. ribbonClosePath?: boolean;
  59563. cap?: number;
  59564. updatable?: boolean;
  59565. sideOrientation?: number;
  59566. frontUVs?: Vector4;
  59567. backUVs?: Vector4;
  59568. instance?: Mesh;
  59569. invertUV?: boolean;
  59570. }, scene?: Nullable<Scene>): Mesh;
  59571. /**
  59572. * Creates lathe mesh.
  59573. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  59574. * * 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
  59575. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  59576. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  59577. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  59578. * * 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
  59579. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  59580. * * 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
  59581. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59582. * * 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
  59583. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59584. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59585. * @param name defines the name of the mesh
  59586. * @param options defines the options used to create the mesh
  59587. * @param scene defines the hosting scene
  59588. * @returns the lathe mesh
  59589. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  59590. */
  59591. static CreateLathe(name: string, options: {
  59592. shape: Vector3[];
  59593. radius?: number;
  59594. tessellation?: number;
  59595. clip?: number;
  59596. arc?: number;
  59597. closed?: boolean;
  59598. updatable?: boolean;
  59599. sideOrientation?: number;
  59600. frontUVs?: Vector4;
  59601. backUVs?: Vector4;
  59602. cap?: number;
  59603. invertUV?: boolean;
  59604. }, scene?: Nullable<Scene>): Mesh;
  59605. /**
  59606. * Creates a tiled plane mesh
  59607. * * You can set a limited pattern arrangement with the tiles
  59608. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59609. * * 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
  59610. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59611. * @param name defines the name of the mesh
  59612. * @param options defines the options used to create the mesh
  59613. * @param scene defines the hosting scene
  59614. * @returns the plane mesh
  59615. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  59616. */
  59617. static CreateTiledPlane(name: string, options: {
  59618. pattern?: number;
  59619. tileSize?: number;
  59620. tileWidth?: number;
  59621. tileHeight?: number;
  59622. size?: number;
  59623. width?: number;
  59624. height?: number;
  59625. alignHorizontal?: number;
  59626. alignVertical?: number;
  59627. sideOrientation?: number;
  59628. frontUVs?: Vector4;
  59629. backUVs?: Vector4;
  59630. updatable?: boolean;
  59631. }, scene?: Nullable<Scene>): Mesh;
  59632. /**
  59633. * Creates a plane mesh
  59634. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  59635. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  59636. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  59637. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59638. * * 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
  59639. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59640. * @param name defines the name of the mesh
  59641. * @param options defines the options used to create the mesh
  59642. * @param scene defines the hosting scene
  59643. * @returns the plane mesh
  59644. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  59645. */
  59646. static CreatePlane(name: string, options: {
  59647. size?: number;
  59648. width?: number;
  59649. height?: number;
  59650. sideOrientation?: number;
  59651. frontUVs?: Vector4;
  59652. backUVs?: Vector4;
  59653. updatable?: boolean;
  59654. sourcePlane?: Plane;
  59655. }, scene?: Nullable<Scene>): Mesh;
  59656. /**
  59657. * Creates a ground mesh
  59658. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  59659. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  59660. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59661. * @param name defines the name of the mesh
  59662. * @param options defines the options used to create the mesh
  59663. * @param scene defines the hosting scene
  59664. * @returns the ground mesh
  59665. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  59666. */
  59667. static CreateGround(name: string, options: {
  59668. width?: number;
  59669. height?: number;
  59670. subdivisions?: number;
  59671. subdivisionsX?: number;
  59672. subdivisionsY?: number;
  59673. updatable?: boolean;
  59674. }, scene?: Nullable<Scene>): Mesh;
  59675. /**
  59676. * Creates a tiled ground mesh
  59677. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  59678. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  59679. * * 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
  59680. * * 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
  59681. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59682. * @param name defines the name of the mesh
  59683. * @param options defines the options used to create the mesh
  59684. * @param scene defines the hosting scene
  59685. * @returns the tiled ground mesh
  59686. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  59687. */
  59688. static CreateTiledGround(name: string, options: {
  59689. xmin: number;
  59690. zmin: number;
  59691. xmax: number;
  59692. zmax: number;
  59693. subdivisions?: {
  59694. w: number;
  59695. h: number;
  59696. };
  59697. precision?: {
  59698. w: number;
  59699. h: number;
  59700. };
  59701. updatable?: boolean;
  59702. }, scene?: Nullable<Scene>): Mesh;
  59703. /**
  59704. * Creates a ground mesh from a height map
  59705. * * The parameter `url` sets the URL of the height map image resource.
  59706. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  59707. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  59708. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  59709. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  59710. * * 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.
  59711. * * 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).
  59712. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  59713. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59714. * @param name defines the name of the mesh
  59715. * @param url defines the url to the height map
  59716. * @param options defines the options used to create the mesh
  59717. * @param scene defines the hosting scene
  59718. * @returns the ground mesh
  59719. * @see https://doc.babylonjs.com/babylon101/height_map
  59720. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  59721. */
  59722. static CreateGroundFromHeightMap(name: string, url: string, options: {
  59723. width?: number;
  59724. height?: number;
  59725. subdivisions?: number;
  59726. minHeight?: number;
  59727. maxHeight?: number;
  59728. colorFilter?: Color3;
  59729. alphaFilter?: number;
  59730. updatable?: boolean;
  59731. onReady?: (mesh: GroundMesh) => void;
  59732. }, scene?: Nullable<Scene>): GroundMesh;
  59733. /**
  59734. * Creates a polygon mesh
  59735. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  59736. * * 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
  59737. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  59738. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59739. * * 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)
  59740. * * Remember you can only change the shape positions, not their number when updating a polygon
  59741. * @param name defines the name of the mesh
  59742. * @param options defines the options used to create the mesh
  59743. * @param scene defines the hosting scene
  59744. * @param earcutInjection can be used to inject your own earcut reference
  59745. * @returns the polygon mesh
  59746. */
  59747. static CreatePolygon(name: string, options: {
  59748. shape: Vector3[];
  59749. holes?: Vector3[][];
  59750. depth?: number;
  59751. faceUV?: Vector4[];
  59752. faceColors?: Color4[];
  59753. updatable?: boolean;
  59754. sideOrientation?: number;
  59755. frontUVs?: Vector4;
  59756. backUVs?: Vector4;
  59757. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  59758. /**
  59759. * Creates an extruded polygon mesh, with depth in the Y direction.
  59760. * * 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)
  59761. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  59762. * @param name defines the name of the mesh
  59763. * @param options defines the options used to create the mesh
  59764. * @param scene defines the hosting scene
  59765. * @param earcutInjection can be used to inject your own earcut reference
  59766. * @returns the polygon mesh
  59767. */
  59768. static ExtrudePolygon(name: string, options: {
  59769. shape: Vector3[];
  59770. holes?: Vector3[][];
  59771. depth?: number;
  59772. faceUV?: Vector4[];
  59773. faceColors?: Color4[];
  59774. updatable?: boolean;
  59775. sideOrientation?: number;
  59776. frontUVs?: Vector4;
  59777. backUVs?: Vector4;
  59778. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  59779. /**
  59780. * Creates a tube mesh.
  59781. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  59782. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  59783. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  59784. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  59785. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  59786. * * 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)
  59787. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  59788. * * 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
  59789. * * 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
  59790. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59791. * * 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
  59792. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59793. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59794. * @param name defines the name of the mesh
  59795. * @param options defines the options used to create the mesh
  59796. * @param scene defines the hosting scene
  59797. * @returns the tube mesh
  59798. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59799. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  59800. */
  59801. static CreateTube(name: string, options: {
  59802. path: Vector3[];
  59803. radius?: number;
  59804. tessellation?: number;
  59805. radiusFunction?: {
  59806. (i: number, distance: number): number;
  59807. };
  59808. cap?: number;
  59809. arc?: number;
  59810. updatable?: boolean;
  59811. sideOrientation?: number;
  59812. frontUVs?: Vector4;
  59813. backUVs?: Vector4;
  59814. instance?: Mesh;
  59815. invertUV?: boolean;
  59816. }, scene?: Nullable<Scene>): Mesh;
  59817. /**
  59818. * Creates a polyhedron mesh
  59819. * * 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
  59820. * * The parameter `size` (positive float, default 1) sets the polygon size
  59821. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  59822. * * 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`
  59823. * * 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
  59824. * * 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)`)
  59825. * * 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
  59826. * * 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
  59827. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59828. * * 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
  59829. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59830. * @param name defines the name of the mesh
  59831. * @param options defines the options used to create the mesh
  59832. * @param scene defines the hosting scene
  59833. * @returns the polyhedron mesh
  59834. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  59835. */
  59836. static CreatePolyhedron(name: string, options: {
  59837. type?: number;
  59838. size?: number;
  59839. sizeX?: number;
  59840. sizeY?: number;
  59841. sizeZ?: number;
  59842. custom?: any;
  59843. faceUV?: Vector4[];
  59844. faceColors?: Color4[];
  59845. flat?: boolean;
  59846. updatable?: boolean;
  59847. sideOrientation?: number;
  59848. frontUVs?: Vector4;
  59849. backUVs?: Vector4;
  59850. }, scene?: Nullable<Scene>): Mesh;
  59851. /**
  59852. * Creates a decal mesh.
  59853. * 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
  59854. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  59855. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  59856. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  59857. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  59858. * @param name defines the name of the mesh
  59859. * @param sourceMesh defines the mesh where the decal must be applied
  59860. * @param options defines the options used to create the mesh
  59861. * @param scene defines the hosting scene
  59862. * @returns the decal mesh
  59863. * @see https://doc.babylonjs.com/how_to/decals
  59864. */
  59865. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  59866. position?: Vector3;
  59867. normal?: Vector3;
  59868. size?: Vector3;
  59869. angle?: number;
  59870. }): Mesh;
  59871. }
  59872. }
  59873. declare module BABYLON {
  59874. /**
  59875. * A simplifier interface for future simplification implementations
  59876. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59877. */
  59878. export interface ISimplifier {
  59879. /**
  59880. * Simplification of a given mesh according to the given settings.
  59881. * Since this requires computation, it is assumed that the function runs async.
  59882. * @param settings The settings of the simplification, including quality and distance
  59883. * @param successCallback A callback that will be called after the mesh was simplified.
  59884. * @param errorCallback in case of an error, this callback will be called. optional.
  59885. */
  59886. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  59887. }
  59888. /**
  59889. * Expected simplification settings.
  59890. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  59891. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59892. */
  59893. export interface ISimplificationSettings {
  59894. /**
  59895. * Gets or sets the expected quality
  59896. */
  59897. quality: number;
  59898. /**
  59899. * Gets or sets the distance when this optimized version should be used
  59900. */
  59901. distance: number;
  59902. /**
  59903. * Gets an already optimized mesh
  59904. */
  59905. optimizeMesh?: boolean;
  59906. }
  59907. /**
  59908. * Class used to specify simplification options
  59909. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59910. */
  59911. export class SimplificationSettings implements ISimplificationSettings {
  59912. /** expected quality */
  59913. quality: number;
  59914. /** distance when this optimized version should be used */
  59915. distance: number;
  59916. /** already optimized mesh */
  59917. optimizeMesh?: boolean | undefined;
  59918. /**
  59919. * Creates a SimplificationSettings
  59920. * @param quality expected quality
  59921. * @param distance distance when this optimized version should be used
  59922. * @param optimizeMesh already optimized mesh
  59923. */
  59924. constructor(
  59925. /** expected quality */
  59926. quality: number,
  59927. /** distance when this optimized version should be used */
  59928. distance: number,
  59929. /** already optimized mesh */
  59930. optimizeMesh?: boolean | undefined);
  59931. }
  59932. /**
  59933. * Interface used to define a simplification task
  59934. */
  59935. export interface ISimplificationTask {
  59936. /**
  59937. * Array of settings
  59938. */
  59939. settings: Array<ISimplificationSettings>;
  59940. /**
  59941. * Simplification type
  59942. */
  59943. simplificationType: SimplificationType;
  59944. /**
  59945. * Mesh to simplify
  59946. */
  59947. mesh: Mesh;
  59948. /**
  59949. * Callback called on success
  59950. */
  59951. successCallback?: () => void;
  59952. /**
  59953. * Defines if parallel processing can be used
  59954. */
  59955. parallelProcessing: boolean;
  59956. }
  59957. /**
  59958. * Queue used to order the simplification tasks
  59959. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59960. */
  59961. export class SimplificationQueue {
  59962. private _simplificationArray;
  59963. /**
  59964. * Gets a boolean indicating that the process is still running
  59965. */
  59966. running: boolean;
  59967. /**
  59968. * Creates a new queue
  59969. */
  59970. constructor();
  59971. /**
  59972. * Adds a new simplification task
  59973. * @param task defines a task to add
  59974. */
  59975. addTask(task: ISimplificationTask): void;
  59976. /**
  59977. * Execute next task
  59978. */
  59979. executeNext(): void;
  59980. /**
  59981. * Execute a simplification task
  59982. * @param task defines the task to run
  59983. */
  59984. runSimplification(task: ISimplificationTask): void;
  59985. private getSimplifier;
  59986. }
  59987. /**
  59988. * The implemented types of simplification
  59989. * At the moment only Quadratic Error Decimation is implemented
  59990. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59991. */
  59992. export enum SimplificationType {
  59993. /** Quadratic error decimation */
  59994. QUADRATIC = 0
  59995. }
  59996. }
  59997. declare module BABYLON {
  59998. interface Scene {
  59999. /** @hidden (Backing field) */
  60000. _simplificationQueue: SimplificationQueue;
  60001. /**
  60002. * Gets or sets the simplification queue attached to the scene
  60003. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60004. */
  60005. simplificationQueue: SimplificationQueue;
  60006. }
  60007. interface Mesh {
  60008. /**
  60009. * Simplify the mesh according to the given array of settings.
  60010. * Function will return immediately and will simplify async
  60011. * @param settings a collection of simplification settings
  60012. * @param parallelProcessing should all levels calculate parallel or one after the other
  60013. * @param simplificationType the type of simplification to run
  60014. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  60015. * @returns the current mesh
  60016. */
  60017. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  60018. }
  60019. /**
  60020. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  60021. * created in a scene
  60022. */
  60023. export class SimplicationQueueSceneComponent implements ISceneComponent {
  60024. /**
  60025. * The component name helpfull to identify the component in the list of scene components.
  60026. */
  60027. readonly name: string;
  60028. /**
  60029. * The scene the component belongs to.
  60030. */
  60031. scene: Scene;
  60032. /**
  60033. * Creates a new instance of the component for the given scene
  60034. * @param scene Defines the scene to register the component in
  60035. */
  60036. constructor(scene: Scene);
  60037. /**
  60038. * Registers the component in a given scene
  60039. */
  60040. register(): void;
  60041. /**
  60042. * Rebuilds the elements related to this component in case of
  60043. * context lost for instance.
  60044. */
  60045. rebuild(): void;
  60046. /**
  60047. * Disposes the component and the associated ressources
  60048. */
  60049. dispose(): void;
  60050. private _beforeCameraUpdate;
  60051. }
  60052. }
  60053. declare module BABYLON {
  60054. /**
  60055. * Navigation plugin interface to add navigation constrained by a navigation mesh
  60056. */
  60057. export interface INavigationEnginePlugin {
  60058. /**
  60059. * plugin name
  60060. */
  60061. name: string;
  60062. /**
  60063. * Creates a navigation mesh
  60064. * @param meshes array of all the geometry used to compute the navigatio mesh
  60065. * @param parameters bunch of parameters used to filter geometry
  60066. */
  60067. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  60068. /**
  60069. * Create a navigation mesh debug mesh
  60070. * @param scene is where the mesh will be added
  60071. * @returns debug display mesh
  60072. */
  60073. createDebugNavMesh(scene: Scene): Mesh;
  60074. /**
  60075. * Get a navigation mesh constrained position, closest to the parameter position
  60076. * @param position world position
  60077. * @returns the closest point to position constrained by the navigation mesh
  60078. */
  60079. getClosestPoint(position: Vector3): Vector3;
  60080. /**
  60081. * Get a navigation mesh constrained position, within a particular radius
  60082. * @param position world position
  60083. * @param maxRadius the maximum distance to the constrained world position
  60084. * @returns the closest point to position constrained by the navigation mesh
  60085. */
  60086. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  60087. /**
  60088. * Compute the final position from a segment made of destination-position
  60089. * @param position world position
  60090. * @param destination world position
  60091. * @returns the resulting point along the navmesh
  60092. */
  60093. moveAlong(position: Vector3, destination: Vector3): Vector3;
  60094. /**
  60095. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  60096. * @param start world position
  60097. * @param end world position
  60098. * @returns array containing world position composing the path
  60099. */
  60100. computePath(start: Vector3, end: Vector3): Vector3[];
  60101. /**
  60102. * If this plugin is supported
  60103. * @returns true if plugin is supported
  60104. */
  60105. isSupported(): boolean;
  60106. /**
  60107. * Create a new Crowd so you can add agents
  60108. * @param maxAgents the maximum agent count in the crowd
  60109. * @param maxAgentRadius the maximum radius an agent can have
  60110. * @param scene to attach the crowd to
  60111. * @returns the crowd you can add agents to
  60112. */
  60113. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  60114. /**
  60115. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60116. * The queries will try to find a solution within those bounds
  60117. * default is (1,1,1)
  60118. * @param extent x,y,z value that define the extent around the queries point of reference
  60119. */
  60120. setDefaultQueryExtent(extent: Vector3): void;
  60121. /**
  60122. * Get the Bounding box extent specified by setDefaultQueryExtent
  60123. * @returns the box extent values
  60124. */
  60125. getDefaultQueryExtent(): Vector3;
  60126. /**
  60127. * Release all resources
  60128. */
  60129. dispose(): void;
  60130. }
  60131. /**
  60132. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  60133. */
  60134. export interface ICrowd {
  60135. /**
  60136. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  60137. * You can attach anything to that node. The node position is updated in the scene update tick.
  60138. * @param pos world position that will be constrained by the navigation mesh
  60139. * @param parameters agent parameters
  60140. * @param transform hooked to the agent that will be update by the scene
  60141. * @returns agent index
  60142. */
  60143. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  60144. /**
  60145. * Returns the agent position in world space
  60146. * @param index agent index returned by addAgent
  60147. * @returns world space position
  60148. */
  60149. getAgentPosition(index: number): Vector3;
  60150. /**
  60151. * Gets the agent velocity in world space
  60152. * @param index agent index returned by addAgent
  60153. * @returns world space velocity
  60154. */
  60155. getAgentVelocity(index: number): Vector3;
  60156. /**
  60157. * remove a particular agent previously created
  60158. * @param index agent index returned by addAgent
  60159. */
  60160. removeAgent(index: number): void;
  60161. /**
  60162. * get the list of all agents attached to this crowd
  60163. * @returns list of agent indices
  60164. */
  60165. getAgents(): number[];
  60166. /**
  60167. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  60168. * @param deltaTime in seconds
  60169. */
  60170. update(deltaTime: number): void;
  60171. /**
  60172. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  60173. * @param index agent index returned by addAgent
  60174. * @param destination targeted world position
  60175. */
  60176. agentGoto(index: number, destination: Vector3): void;
  60177. /**
  60178. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60179. * The queries will try to find a solution within those bounds
  60180. * default is (1,1,1)
  60181. * @param extent x,y,z value that define the extent around the queries point of reference
  60182. */
  60183. setDefaultQueryExtent(extent: Vector3): void;
  60184. /**
  60185. * Get the Bounding box extent specified by setDefaultQueryExtent
  60186. * @returns the box extent values
  60187. */
  60188. getDefaultQueryExtent(): Vector3;
  60189. /**
  60190. * Release all resources
  60191. */
  60192. dispose(): void;
  60193. }
  60194. /**
  60195. * Configures an agent
  60196. */
  60197. export interface IAgentParameters {
  60198. /**
  60199. * Agent radius. [Limit: >= 0]
  60200. */
  60201. radius: number;
  60202. /**
  60203. * Agent height. [Limit: > 0]
  60204. */
  60205. height: number;
  60206. /**
  60207. * Maximum allowed acceleration. [Limit: >= 0]
  60208. */
  60209. maxAcceleration: number;
  60210. /**
  60211. * Maximum allowed speed. [Limit: >= 0]
  60212. */
  60213. maxSpeed: number;
  60214. /**
  60215. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  60216. */
  60217. collisionQueryRange: number;
  60218. /**
  60219. * The path visibility optimization range. [Limit: > 0]
  60220. */
  60221. pathOptimizationRange: number;
  60222. /**
  60223. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  60224. */
  60225. separationWeight: number;
  60226. }
  60227. /**
  60228. * Configures the navigation mesh creation
  60229. */
  60230. export interface INavMeshParameters {
  60231. /**
  60232. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  60233. */
  60234. cs: number;
  60235. /**
  60236. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  60237. */
  60238. ch: number;
  60239. /**
  60240. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  60241. */
  60242. walkableSlopeAngle: number;
  60243. /**
  60244. * Minimum floor to 'ceiling' height that will still allow the floor area to
  60245. * be considered walkable. [Limit: >= 3] [Units: vx]
  60246. */
  60247. walkableHeight: number;
  60248. /**
  60249. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  60250. */
  60251. walkableClimb: number;
  60252. /**
  60253. * The distance to erode/shrink the walkable area of the heightfield away from
  60254. * obstructions. [Limit: >=0] [Units: vx]
  60255. */
  60256. walkableRadius: number;
  60257. /**
  60258. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  60259. */
  60260. maxEdgeLen: number;
  60261. /**
  60262. * The maximum distance a simplfied contour's border edges should deviate
  60263. * the original raw contour. [Limit: >=0] [Units: vx]
  60264. */
  60265. maxSimplificationError: number;
  60266. /**
  60267. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  60268. */
  60269. minRegionArea: number;
  60270. /**
  60271. * Any regions with a span count smaller than this value will, if possible,
  60272. * be merged with larger regions. [Limit: >=0] [Units: vx]
  60273. */
  60274. mergeRegionArea: number;
  60275. /**
  60276. * The maximum number of vertices allowed for polygons generated during the
  60277. * contour to polygon conversion process. [Limit: >= 3]
  60278. */
  60279. maxVertsPerPoly: number;
  60280. /**
  60281. * Sets the sampling distance to use when generating the detail mesh.
  60282. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  60283. */
  60284. detailSampleDist: number;
  60285. /**
  60286. * The maximum distance the detail mesh surface should deviate from heightfield
  60287. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  60288. */
  60289. detailSampleMaxError: number;
  60290. }
  60291. }
  60292. declare module BABYLON {
  60293. /**
  60294. * RecastJS navigation plugin
  60295. */
  60296. export class RecastJSPlugin implements INavigationEnginePlugin {
  60297. /**
  60298. * Reference to the Recast library
  60299. */
  60300. bjsRECAST: any;
  60301. /**
  60302. * plugin name
  60303. */
  60304. name: string;
  60305. /**
  60306. * the first navmesh created. We might extend this to support multiple navmeshes
  60307. */
  60308. navMesh: any;
  60309. /**
  60310. * Initializes the recastJS plugin
  60311. * @param recastInjection can be used to inject your own recast reference
  60312. */
  60313. constructor(recastInjection?: any);
  60314. /**
  60315. * Creates a navigation mesh
  60316. * @param meshes array of all the geometry used to compute the navigatio mesh
  60317. * @param parameters bunch of parameters used to filter geometry
  60318. */
  60319. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  60320. /**
  60321. * Create a navigation mesh debug mesh
  60322. * @param scene is where the mesh will be added
  60323. * @returns debug display mesh
  60324. */
  60325. createDebugNavMesh(scene: Scene): Mesh;
  60326. /**
  60327. * Get a navigation mesh constrained position, closest to the parameter position
  60328. * @param position world position
  60329. * @returns the closest point to position constrained by the navigation mesh
  60330. */
  60331. getClosestPoint(position: Vector3): Vector3;
  60332. /**
  60333. * Get a navigation mesh constrained position, within a particular radius
  60334. * @param position world position
  60335. * @param maxRadius the maximum distance to the constrained world position
  60336. * @returns the closest point to position constrained by the navigation mesh
  60337. */
  60338. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  60339. /**
  60340. * Compute the final position from a segment made of destination-position
  60341. * @param position world position
  60342. * @param destination world position
  60343. * @returns the resulting point along the navmesh
  60344. */
  60345. moveAlong(position: Vector3, destination: Vector3): Vector3;
  60346. /**
  60347. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  60348. * @param start world position
  60349. * @param end world position
  60350. * @returns array containing world position composing the path
  60351. */
  60352. computePath(start: Vector3, end: Vector3): Vector3[];
  60353. /**
  60354. * Create a new Crowd so you can add agents
  60355. * @param maxAgents the maximum agent count in the crowd
  60356. * @param maxAgentRadius the maximum radius an agent can have
  60357. * @param scene to attach the crowd to
  60358. * @returns the crowd you can add agents to
  60359. */
  60360. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  60361. /**
  60362. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60363. * The queries will try to find a solution within those bounds
  60364. * default is (1,1,1)
  60365. * @param extent x,y,z value that define the extent around the queries point of reference
  60366. */
  60367. setDefaultQueryExtent(extent: Vector3): void;
  60368. /**
  60369. * Get the Bounding box extent specified by setDefaultQueryExtent
  60370. * @returns the box extent values
  60371. */
  60372. getDefaultQueryExtent(): Vector3;
  60373. /**
  60374. * Disposes
  60375. */
  60376. dispose(): void;
  60377. /**
  60378. * If this plugin is supported
  60379. * @returns true if plugin is supported
  60380. */
  60381. isSupported(): boolean;
  60382. }
  60383. /**
  60384. * Recast detour crowd implementation
  60385. */
  60386. export class RecastJSCrowd implements ICrowd {
  60387. /**
  60388. * Recast/detour plugin
  60389. */
  60390. bjsRECASTPlugin: RecastJSPlugin;
  60391. /**
  60392. * Link to the detour crowd
  60393. */
  60394. recastCrowd: any;
  60395. /**
  60396. * One transform per agent
  60397. */
  60398. transforms: TransformNode[];
  60399. /**
  60400. * All agents created
  60401. */
  60402. agents: number[];
  60403. /**
  60404. * Link to the scene is kept to unregister the crowd from the scene
  60405. */
  60406. private _scene;
  60407. /**
  60408. * Observer for crowd updates
  60409. */
  60410. private _onBeforeAnimationsObserver;
  60411. /**
  60412. * Constructor
  60413. * @param plugin recastJS plugin
  60414. * @param maxAgents the maximum agent count in the crowd
  60415. * @param maxAgentRadius the maximum radius an agent can have
  60416. * @param scene to attach the crowd to
  60417. * @returns the crowd you can add agents to
  60418. */
  60419. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  60420. /**
  60421. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  60422. * You can attach anything to that node. The node position is updated in the scene update tick.
  60423. * @param pos world position that will be constrained by the navigation mesh
  60424. * @param parameters agent parameters
  60425. * @param transform hooked to the agent that will be update by the scene
  60426. * @returns agent index
  60427. */
  60428. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  60429. /**
  60430. * Returns the agent position in world space
  60431. * @param index agent index returned by addAgent
  60432. * @returns world space position
  60433. */
  60434. getAgentPosition(index: number): Vector3;
  60435. /**
  60436. * Returns the agent velocity in world space
  60437. * @param index agent index returned by addAgent
  60438. * @returns world space velocity
  60439. */
  60440. getAgentVelocity(index: number): Vector3;
  60441. /**
  60442. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  60443. * @param index agent index returned by addAgent
  60444. * @param destination targeted world position
  60445. */
  60446. agentGoto(index: number, destination: Vector3): void;
  60447. /**
  60448. * remove a particular agent previously created
  60449. * @param index agent index returned by addAgent
  60450. */
  60451. removeAgent(index: number): void;
  60452. /**
  60453. * get the list of all agents attached to this crowd
  60454. * @returns list of agent indices
  60455. */
  60456. getAgents(): number[];
  60457. /**
  60458. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  60459. * @param deltaTime in seconds
  60460. */
  60461. update(deltaTime: number): void;
  60462. /**
  60463. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60464. * The queries will try to find a solution within those bounds
  60465. * default is (1,1,1)
  60466. * @param extent x,y,z value that define the extent around the queries point of reference
  60467. */
  60468. setDefaultQueryExtent(extent: Vector3): void;
  60469. /**
  60470. * Get the Bounding box extent specified by setDefaultQueryExtent
  60471. * @returns the box extent values
  60472. */
  60473. getDefaultQueryExtent(): Vector3;
  60474. /**
  60475. * Release all resources
  60476. */
  60477. dispose(): void;
  60478. }
  60479. }
  60480. declare module BABYLON {
  60481. /**
  60482. * Class used to enable access to IndexedDB
  60483. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  60484. */
  60485. export class Database implements IOfflineProvider {
  60486. private _callbackManifestChecked;
  60487. private _currentSceneUrl;
  60488. private _db;
  60489. private _enableSceneOffline;
  60490. private _enableTexturesOffline;
  60491. private _manifestVersionFound;
  60492. private _mustUpdateRessources;
  60493. private _hasReachedQuota;
  60494. private _isSupported;
  60495. private _idbFactory;
  60496. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  60497. private static IsUASupportingBlobStorage;
  60498. /**
  60499. * Gets a boolean indicating if Database storate is enabled (off by default)
  60500. */
  60501. static IDBStorageEnabled: boolean;
  60502. /**
  60503. * Gets a boolean indicating if scene must be saved in the database
  60504. */
  60505. get enableSceneOffline(): boolean;
  60506. /**
  60507. * Gets a boolean indicating if textures must be saved in the database
  60508. */
  60509. get enableTexturesOffline(): boolean;
  60510. /**
  60511. * Creates a new Database
  60512. * @param urlToScene defines the url to load the scene
  60513. * @param callbackManifestChecked defines the callback to use when manifest is checked
  60514. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  60515. */
  60516. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  60517. private static _ParseURL;
  60518. private static _ReturnFullUrlLocation;
  60519. private _checkManifestFile;
  60520. /**
  60521. * Open the database and make it available
  60522. * @param successCallback defines the callback to call on success
  60523. * @param errorCallback defines the callback to call on error
  60524. */
  60525. open(successCallback: () => void, errorCallback: () => void): void;
  60526. /**
  60527. * Loads an image from the database
  60528. * @param url defines the url to load from
  60529. * @param image defines the target DOM image
  60530. */
  60531. loadImage(url: string, image: HTMLImageElement): void;
  60532. private _loadImageFromDBAsync;
  60533. private _saveImageIntoDBAsync;
  60534. private _checkVersionFromDB;
  60535. private _loadVersionFromDBAsync;
  60536. private _saveVersionIntoDBAsync;
  60537. /**
  60538. * Loads a file from database
  60539. * @param url defines the URL to load from
  60540. * @param sceneLoaded defines a callback to call on success
  60541. * @param progressCallBack defines a callback to call when progress changed
  60542. * @param errorCallback defines a callback to call on error
  60543. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  60544. */
  60545. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  60546. private _loadFileAsync;
  60547. private _saveFileAsync;
  60548. /**
  60549. * Validates if xhr data is correct
  60550. * @param xhr defines the request to validate
  60551. * @param dataType defines the expected data type
  60552. * @returns true if data is correct
  60553. */
  60554. private static _ValidateXHRData;
  60555. }
  60556. }
  60557. declare module BABYLON {
  60558. /** @hidden */
  60559. export var gpuUpdateParticlesPixelShader: {
  60560. name: string;
  60561. shader: string;
  60562. };
  60563. }
  60564. declare module BABYLON {
  60565. /** @hidden */
  60566. export var gpuUpdateParticlesVertexShader: {
  60567. name: string;
  60568. shader: string;
  60569. };
  60570. }
  60571. declare module BABYLON {
  60572. /** @hidden */
  60573. export var clipPlaneFragmentDeclaration2: {
  60574. name: string;
  60575. shader: string;
  60576. };
  60577. }
  60578. declare module BABYLON {
  60579. /** @hidden */
  60580. export var gpuRenderParticlesPixelShader: {
  60581. name: string;
  60582. shader: string;
  60583. };
  60584. }
  60585. declare module BABYLON {
  60586. /** @hidden */
  60587. export var clipPlaneVertexDeclaration2: {
  60588. name: string;
  60589. shader: string;
  60590. };
  60591. }
  60592. declare module BABYLON {
  60593. /** @hidden */
  60594. export var gpuRenderParticlesVertexShader: {
  60595. name: string;
  60596. shader: string;
  60597. };
  60598. }
  60599. declare module BABYLON {
  60600. /**
  60601. * This represents a GPU particle system in Babylon
  60602. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  60603. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  60604. */
  60605. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  60606. /**
  60607. * The layer mask we are rendering the particles through.
  60608. */
  60609. layerMask: number;
  60610. private _capacity;
  60611. private _activeCount;
  60612. private _currentActiveCount;
  60613. private _accumulatedCount;
  60614. private _renderEffect;
  60615. private _updateEffect;
  60616. private _buffer0;
  60617. private _buffer1;
  60618. private _spriteBuffer;
  60619. private _updateVAO;
  60620. private _renderVAO;
  60621. private _targetIndex;
  60622. private _sourceBuffer;
  60623. private _targetBuffer;
  60624. private _engine;
  60625. private _currentRenderId;
  60626. private _started;
  60627. private _stopped;
  60628. private _timeDelta;
  60629. private _randomTexture;
  60630. private _randomTexture2;
  60631. private _attributesStrideSize;
  60632. private _updateEffectOptions;
  60633. private _randomTextureSize;
  60634. private _actualFrame;
  60635. private readonly _rawTextureWidth;
  60636. /**
  60637. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  60638. */
  60639. static get IsSupported(): boolean;
  60640. /**
  60641. * An event triggered when the system is disposed.
  60642. */
  60643. onDisposeObservable: Observable<GPUParticleSystem>;
  60644. /**
  60645. * Gets the maximum number of particles active at the same time.
  60646. * @returns The max number of active particles.
  60647. */
  60648. getCapacity(): number;
  60649. /**
  60650. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  60651. * to override the particles.
  60652. */
  60653. forceDepthWrite: boolean;
  60654. /**
  60655. * Gets or set the number of active particles
  60656. */
  60657. get activeParticleCount(): number;
  60658. set activeParticleCount(value: number);
  60659. private _preWarmDone;
  60660. /**
  60661. * Is this system ready to be used/rendered
  60662. * @return true if the system is ready
  60663. */
  60664. isReady(): boolean;
  60665. /**
  60666. * Gets if the system has been started. (Note: this will still be true after stop is called)
  60667. * @returns True if it has been started, otherwise false.
  60668. */
  60669. isStarted(): boolean;
  60670. /**
  60671. * Starts the particle system and begins to emit
  60672. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  60673. */
  60674. start(delay?: number): void;
  60675. /**
  60676. * Stops the particle system.
  60677. */
  60678. stop(): void;
  60679. /**
  60680. * Remove all active particles
  60681. */
  60682. reset(): void;
  60683. /**
  60684. * Returns the string "GPUParticleSystem"
  60685. * @returns a string containing the class name
  60686. */
  60687. getClassName(): string;
  60688. private _colorGradientsTexture;
  60689. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  60690. /**
  60691. * Adds a new color gradient
  60692. * @param gradient defines the gradient to use (between 0 and 1)
  60693. * @param color1 defines the color to affect to the specified gradient
  60694. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  60695. * @returns the current particle system
  60696. */
  60697. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  60698. /**
  60699. * Remove a specific color gradient
  60700. * @param gradient defines the gradient to remove
  60701. * @returns the current particle system
  60702. */
  60703. removeColorGradient(gradient: number): GPUParticleSystem;
  60704. private _angularSpeedGradientsTexture;
  60705. private _sizeGradientsTexture;
  60706. private _velocityGradientsTexture;
  60707. private _limitVelocityGradientsTexture;
  60708. private _dragGradientsTexture;
  60709. private _addFactorGradient;
  60710. /**
  60711. * Adds a new size gradient
  60712. * @param gradient defines the gradient to use (between 0 and 1)
  60713. * @param factor defines the size factor to affect to the specified gradient
  60714. * @returns the current particle system
  60715. */
  60716. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  60717. /**
  60718. * Remove a specific size gradient
  60719. * @param gradient defines the gradient to remove
  60720. * @returns the current particle system
  60721. */
  60722. removeSizeGradient(gradient: number): GPUParticleSystem;
  60723. /**
  60724. * Adds a new angular speed gradient
  60725. * @param gradient defines the gradient to use (between 0 and 1)
  60726. * @param factor defines the angular speed to affect to the specified gradient
  60727. * @returns the current particle system
  60728. */
  60729. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  60730. /**
  60731. * Remove a specific angular speed gradient
  60732. * @param gradient defines the gradient to remove
  60733. * @returns the current particle system
  60734. */
  60735. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  60736. /**
  60737. * Adds a new velocity gradient
  60738. * @param gradient defines the gradient to use (between 0 and 1)
  60739. * @param factor defines the velocity to affect to the specified gradient
  60740. * @returns the current particle system
  60741. */
  60742. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  60743. /**
  60744. * Remove a specific velocity gradient
  60745. * @param gradient defines the gradient to remove
  60746. * @returns the current particle system
  60747. */
  60748. removeVelocityGradient(gradient: number): GPUParticleSystem;
  60749. /**
  60750. * Adds a new limit velocity gradient
  60751. * @param gradient defines the gradient to use (between 0 and 1)
  60752. * @param factor defines the limit velocity value to affect to the specified gradient
  60753. * @returns the current particle system
  60754. */
  60755. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  60756. /**
  60757. * Remove a specific limit velocity gradient
  60758. * @param gradient defines the gradient to remove
  60759. * @returns the current particle system
  60760. */
  60761. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  60762. /**
  60763. * Adds a new drag gradient
  60764. * @param gradient defines the gradient to use (between 0 and 1)
  60765. * @param factor defines the drag value to affect to the specified gradient
  60766. * @returns the current particle system
  60767. */
  60768. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  60769. /**
  60770. * Remove a specific drag gradient
  60771. * @param gradient defines the gradient to remove
  60772. * @returns the current particle system
  60773. */
  60774. removeDragGradient(gradient: number): GPUParticleSystem;
  60775. /**
  60776. * Not supported by GPUParticleSystem
  60777. * @param gradient defines the gradient to use (between 0 and 1)
  60778. * @param factor defines the emit rate value to affect to the specified gradient
  60779. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  60780. * @returns the current particle system
  60781. */
  60782. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  60783. /**
  60784. * Not supported by GPUParticleSystem
  60785. * @param gradient defines the gradient to remove
  60786. * @returns the current particle system
  60787. */
  60788. removeEmitRateGradient(gradient: number): IParticleSystem;
  60789. /**
  60790. * Not supported by GPUParticleSystem
  60791. * @param gradient defines the gradient to use (between 0 and 1)
  60792. * @param factor defines the start size value to affect to the specified gradient
  60793. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  60794. * @returns the current particle system
  60795. */
  60796. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  60797. /**
  60798. * Not supported by GPUParticleSystem
  60799. * @param gradient defines the gradient to remove
  60800. * @returns the current particle system
  60801. */
  60802. removeStartSizeGradient(gradient: number): IParticleSystem;
  60803. /**
  60804. * Not supported by GPUParticleSystem
  60805. * @param gradient defines the gradient to use (between 0 and 1)
  60806. * @param min defines the color remap minimal range
  60807. * @param max defines the color remap maximal range
  60808. * @returns the current particle system
  60809. */
  60810. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  60811. /**
  60812. * Not supported by GPUParticleSystem
  60813. * @param gradient defines the gradient to remove
  60814. * @returns the current particle system
  60815. */
  60816. removeColorRemapGradient(): IParticleSystem;
  60817. /**
  60818. * Not supported by GPUParticleSystem
  60819. * @param gradient defines the gradient to use (between 0 and 1)
  60820. * @param min defines the alpha remap minimal range
  60821. * @param max defines the alpha remap maximal range
  60822. * @returns the current particle system
  60823. */
  60824. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  60825. /**
  60826. * Not supported by GPUParticleSystem
  60827. * @param gradient defines the gradient to remove
  60828. * @returns the current particle system
  60829. */
  60830. removeAlphaRemapGradient(): IParticleSystem;
  60831. /**
  60832. * Not supported by GPUParticleSystem
  60833. * @param gradient defines the gradient to use (between 0 and 1)
  60834. * @param color defines the color to affect to the specified gradient
  60835. * @returns the current particle system
  60836. */
  60837. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  60838. /**
  60839. * Not supported by GPUParticleSystem
  60840. * @param gradient defines the gradient to remove
  60841. * @returns the current particle system
  60842. */
  60843. removeRampGradient(): IParticleSystem;
  60844. /**
  60845. * Not supported by GPUParticleSystem
  60846. * @returns the list of ramp gradients
  60847. */
  60848. getRampGradients(): Nullable<Array<Color3Gradient>>;
  60849. /**
  60850. * Not supported by GPUParticleSystem
  60851. * Gets or sets a boolean indicating that ramp gradients must be used
  60852. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  60853. */
  60854. get useRampGradients(): boolean;
  60855. set useRampGradients(value: boolean);
  60856. /**
  60857. * Not supported by GPUParticleSystem
  60858. * @param gradient defines the gradient to use (between 0 and 1)
  60859. * @param factor defines the life time factor to affect to the specified gradient
  60860. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  60861. * @returns the current particle system
  60862. */
  60863. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  60864. /**
  60865. * Not supported by GPUParticleSystem
  60866. * @param gradient defines the gradient to remove
  60867. * @returns the current particle system
  60868. */
  60869. removeLifeTimeGradient(gradient: number): IParticleSystem;
  60870. /**
  60871. * Instantiates a GPU particle system.
  60872. * 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.
  60873. * @param name The name of the particle system
  60874. * @param options The options used to create the system
  60875. * @param scene The scene the particle system belongs to
  60876. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  60877. */
  60878. constructor(name: string, options: Partial<{
  60879. capacity: number;
  60880. randomTextureSize: number;
  60881. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  60882. protected _reset(): void;
  60883. private _createUpdateVAO;
  60884. private _createRenderVAO;
  60885. private _initialize;
  60886. /** @hidden */
  60887. _recreateUpdateEffect(): void;
  60888. /** @hidden */
  60889. _recreateRenderEffect(): void;
  60890. /**
  60891. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  60892. * @param preWarm defines if we are in the pre-warmimg phase
  60893. */
  60894. animate(preWarm?: boolean): void;
  60895. private _createFactorGradientTexture;
  60896. private _createSizeGradientTexture;
  60897. private _createAngularSpeedGradientTexture;
  60898. private _createVelocityGradientTexture;
  60899. private _createLimitVelocityGradientTexture;
  60900. private _createDragGradientTexture;
  60901. private _createColorGradientTexture;
  60902. /**
  60903. * Renders the particle system in its current state
  60904. * @param preWarm defines if the system should only update the particles but not render them
  60905. * @returns the current number of particles
  60906. */
  60907. render(preWarm?: boolean): number;
  60908. /**
  60909. * Rebuilds the particle system
  60910. */
  60911. rebuild(): void;
  60912. private _releaseBuffers;
  60913. private _releaseVAOs;
  60914. /**
  60915. * Disposes the particle system and free the associated resources
  60916. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  60917. */
  60918. dispose(disposeTexture?: boolean): void;
  60919. /**
  60920. * Clones the particle system.
  60921. * @param name The name of the cloned object
  60922. * @param newEmitter The new emitter to use
  60923. * @returns the cloned particle system
  60924. */
  60925. clone(name: string, newEmitter: any): GPUParticleSystem;
  60926. /**
  60927. * Serializes the particle system to a JSON object.
  60928. * @returns the JSON object
  60929. */
  60930. serialize(): any;
  60931. /**
  60932. * Parses a JSON object to create a GPU particle system.
  60933. * @param parsedParticleSystem The JSON object to parse
  60934. * @param scene The scene to create the particle system in
  60935. * @param rootUrl The root url to use to load external dependencies like texture
  60936. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  60937. * @returns the parsed GPU particle system
  60938. */
  60939. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  60940. }
  60941. }
  60942. declare module BABYLON {
  60943. /**
  60944. * Represents a set of particle systems working together to create a specific effect
  60945. */
  60946. export class ParticleSystemSet implements IDisposable {
  60947. /**
  60948. * Gets or sets base Assets URL
  60949. */
  60950. static BaseAssetsUrl: string;
  60951. private _emitterCreationOptions;
  60952. private _emitterNode;
  60953. /**
  60954. * Gets the particle system list
  60955. */
  60956. systems: IParticleSystem[];
  60957. /**
  60958. * Gets the emitter node used with this set
  60959. */
  60960. get emitterNode(): Nullable<TransformNode>;
  60961. /**
  60962. * Creates a new emitter mesh as a sphere
  60963. * @param options defines the options used to create the sphere
  60964. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  60965. * @param scene defines the hosting scene
  60966. */
  60967. setEmitterAsSphere(options: {
  60968. diameter: number;
  60969. segments: number;
  60970. color: Color3;
  60971. }, renderingGroupId: number, scene: Scene): void;
  60972. /**
  60973. * Starts all particle systems of the set
  60974. * @param emitter defines an optional mesh to use as emitter for the particle systems
  60975. */
  60976. start(emitter?: AbstractMesh): void;
  60977. /**
  60978. * Release all associated resources
  60979. */
  60980. dispose(): void;
  60981. /**
  60982. * Serialize the set into a JSON compatible object
  60983. * @returns a JSON compatible representation of the set
  60984. */
  60985. serialize(): any;
  60986. /**
  60987. * Parse a new ParticleSystemSet from a serialized source
  60988. * @param data defines a JSON compatible representation of the set
  60989. * @param scene defines the hosting scene
  60990. * @param gpu defines if we want GPU particles or CPU particles
  60991. * @returns a new ParticleSystemSet
  60992. */
  60993. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  60994. }
  60995. }
  60996. declare module BABYLON {
  60997. /**
  60998. * This class is made for on one-liner static method to help creating particle system set.
  60999. */
  61000. export class ParticleHelper {
  61001. /**
  61002. * Gets or sets base Assets URL
  61003. */
  61004. static BaseAssetsUrl: string;
  61005. /**
  61006. * Create a default particle system that you can tweak
  61007. * @param emitter defines the emitter to use
  61008. * @param capacity defines the system capacity (default is 500 particles)
  61009. * @param scene defines the hosting scene
  61010. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  61011. * @returns the new Particle system
  61012. */
  61013. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  61014. /**
  61015. * This is the main static method (one-liner) of this helper to create different particle systems
  61016. * @param type This string represents the type to the particle system to create
  61017. * @param scene The scene where the particle system should live
  61018. * @param gpu If the system will use gpu
  61019. * @returns the ParticleSystemSet created
  61020. */
  61021. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  61022. /**
  61023. * Static function used to export a particle system to a ParticleSystemSet variable.
  61024. * Please note that the emitter shape is not exported
  61025. * @param systems defines the particle systems to export
  61026. * @returns the created particle system set
  61027. */
  61028. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  61029. }
  61030. }
  61031. declare module BABYLON {
  61032. interface Engine {
  61033. /**
  61034. * Create an effect to use with particle systems.
  61035. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  61036. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  61037. * @param uniformsNames defines a list of attribute names
  61038. * @param samplers defines an array of string used to represent textures
  61039. * @param defines defines the string containing the defines to use to compile the shaders
  61040. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  61041. * @param onCompiled defines a function to call when the effect creation is successful
  61042. * @param onError defines a function to call when the effect creation has failed
  61043. * @returns the new Effect
  61044. */
  61045. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  61046. }
  61047. interface Mesh {
  61048. /**
  61049. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  61050. * @returns an array of IParticleSystem
  61051. */
  61052. getEmittedParticleSystems(): IParticleSystem[];
  61053. /**
  61054. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  61055. * @returns an array of IParticleSystem
  61056. */
  61057. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  61058. }
  61059. /**
  61060. * @hidden
  61061. */
  61062. export var _IDoNeedToBeInTheBuild: number;
  61063. }
  61064. declare module BABYLON {
  61065. /** Defines the 4 color options */
  61066. export enum PointColor {
  61067. /** color value */
  61068. Color = 2,
  61069. /** uv value */
  61070. UV = 1,
  61071. /** random value */
  61072. Random = 0,
  61073. /** stated value */
  61074. Stated = 3
  61075. }
  61076. /**
  61077. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  61078. * 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.
  61079. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  61080. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  61081. *
  61082. * Full documentation here : TO BE ENTERED
  61083. */
  61084. export class PointsCloudSystem implements IDisposable {
  61085. /**
  61086. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  61087. * Example : var p = SPS.particles[i];
  61088. */
  61089. particles: CloudPoint[];
  61090. /**
  61091. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  61092. */
  61093. nbParticles: number;
  61094. /**
  61095. * This a counter for your own usage. It's not set by any SPS functions.
  61096. */
  61097. counter: number;
  61098. /**
  61099. * The PCS name. This name is also given to the underlying mesh.
  61100. */
  61101. name: string;
  61102. /**
  61103. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  61104. */
  61105. mesh: Mesh;
  61106. /**
  61107. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  61108. * Please read :
  61109. */
  61110. vars: any;
  61111. /**
  61112. * @hidden
  61113. */
  61114. _size: number;
  61115. private _scene;
  61116. private _promises;
  61117. private _positions;
  61118. private _indices;
  61119. private _normals;
  61120. private _colors;
  61121. private _uvs;
  61122. private _indices32;
  61123. private _positions32;
  61124. private _colors32;
  61125. private _uvs32;
  61126. private _updatable;
  61127. private _isVisibilityBoxLocked;
  61128. private _alwaysVisible;
  61129. private _groups;
  61130. private _groupCounter;
  61131. private _computeParticleColor;
  61132. private _computeParticleTexture;
  61133. private _computeParticleRotation;
  61134. private _computeBoundingBox;
  61135. private _isReady;
  61136. /**
  61137. * Creates a PCS (Points Cloud System) object
  61138. * @param name (String) is the PCS name, this will be the underlying mesh name
  61139. * @param pointSize (number) is the size for each point
  61140. * @param scene (Scene) is the scene in which the PCS is added
  61141. * @param options defines the options of the PCS e.g.
  61142. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  61143. */
  61144. constructor(name: string, pointSize: number, scene: Scene, options?: {
  61145. updatable?: boolean;
  61146. });
  61147. /**
  61148. * Builds the PCS underlying mesh. Returns a standard Mesh.
  61149. * If no points were added to the PCS, the returned mesh is just a single point.
  61150. * @returns a promise for the created mesh
  61151. */
  61152. buildMeshAsync(): Promise<Mesh>;
  61153. /**
  61154. * @hidden
  61155. */
  61156. private _buildMesh;
  61157. private _addParticle;
  61158. private _randomUnitVector;
  61159. private _getColorIndicesForCoord;
  61160. private _setPointsColorOrUV;
  61161. private _colorFromTexture;
  61162. private _calculateDensity;
  61163. /**
  61164. * Adds points to the PCS in random positions within a unit sphere
  61165. * @param nb (positive integer) the number of particles to be created from this model
  61166. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  61167. * @returns the number of groups in the system
  61168. */
  61169. addPoints(nb: number, pointFunction?: any): number;
  61170. /**
  61171. * Adds points to the PCS from the surface of the model shape
  61172. * @param mesh is any Mesh object that will be used as a surface model for the points
  61173. * @param nb (positive integer) the number of particles to be created from this model
  61174. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  61175. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  61176. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  61177. * @returns the number of groups in the system
  61178. */
  61179. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  61180. /**
  61181. * Adds points to the PCS inside the model shape
  61182. * @param mesh is any Mesh object that will be used as a surface model for the points
  61183. * @param nb (positive integer) the number of particles to be created from this model
  61184. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  61185. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  61186. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  61187. * @returns the number of groups in the system
  61188. */
  61189. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  61190. /**
  61191. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  61192. * This method calls `updateParticle()` for each particle of the SPS.
  61193. * For an animated SPS, it is usually called within the render loop.
  61194. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  61195. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  61196. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  61197. * @returns the PCS.
  61198. */
  61199. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  61200. /**
  61201. * Disposes the PCS.
  61202. */
  61203. dispose(): void;
  61204. /**
  61205. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  61206. * doc :
  61207. * @returns the PCS.
  61208. */
  61209. refreshVisibleSize(): PointsCloudSystem;
  61210. /**
  61211. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  61212. * @param size the size (float) of the visibility box
  61213. * note : this doesn't lock the PCS mesh bounding box.
  61214. * doc :
  61215. */
  61216. setVisibilityBox(size: number): void;
  61217. /**
  61218. * Gets whether the PCS is always visible or not
  61219. * doc :
  61220. */
  61221. get isAlwaysVisible(): boolean;
  61222. /**
  61223. * Sets the PCS as always visible or not
  61224. * doc :
  61225. */
  61226. set isAlwaysVisible(val: boolean);
  61227. /**
  61228. * Tells to `setParticles()` to compute the particle rotations or not
  61229. * Default value : false. The PCS is faster when it's set to false
  61230. * Note : particle rotations are only applied to parent particles
  61231. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  61232. */
  61233. set computeParticleRotation(val: boolean);
  61234. /**
  61235. * Tells to `setParticles()` to compute the particle colors or not.
  61236. * Default value : true. The PCS is faster when it's set to false.
  61237. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  61238. */
  61239. set computeParticleColor(val: boolean);
  61240. set computeParticleTexture(val: boolean);
  61241. /**
  61242. * Gets if `setParticles()` computes the particle colors or not.
  61243. * Default value : false. The PCS is faster when it's set to false.
  61244. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  61245. */
  61246. get computeParticleColor(): boolean;
  61247. /**
  61248. * Gets if `setParticles()` computes the particle textures or not.
  61249. * Default value : false. The PCS is faster when it's set to false.
  61250. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  61251. */
  61252. get computeParticleTexture(): boolean;
  61253. /**
  61254. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  61255. */
  61256. set computeBoundingBox(val: boolean);
  61257. /**
  61258. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  61259. */
  61260. get computeBoundingBox(): boolean;
  61261. /**
  61262. * This function does nothing. It may be overwritten to set all the particle first values.
  61263. * The PCS doesn't call this function, you may have to call it by your own.
  61264. * doc :
  61265. */
  61266. initParticles(): void;
  61267. /**
  61268. * This function does nothing. It may be overwritten to recycle a particle
  61269. * The PCS doesn't call this function, you can to call it
  61270. * doc :
  61271. * @param particle The particle to recycle
  61272. * @returns the recycled particle
  61273. */
  61274. recycleParticle(particle: CloudPoint): CloudPoint;
  61275. /**
  61276. * Updates a particle : this function should be overwritten by the user.
  61277. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  61278. * doc :
  61279. * @example : just set a particle position or velocity and recycle conditions
  61280. * @param particle The particle to update
  61281. * @returns the updated particle
  61282. */
  61283. updateParticle(particle: CloudPoint): CloudPoint;
  61284. /**
  61285. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  61286. * This does nothing and may be overwritten by the user.
  61287. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  61288. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  61289. * @param update the boolean update value actually passed to setParticles()
  61290. */
  61291. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  61292. /**
  61293. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  61294. * This will be passed three parameters.
  61295. * This does nothing and may be overwritten by the user.
  61296. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  61297. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  61298. * @param update the boolean update value actually passed to setParticles()
  61299. */
  61300. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  61301. }
  61302. }
  61303. declare module BABYLON {
  61304. /**
  61305. * Represents one particle of a points cloud system.
  61306. */
  61307. export class CloudPoint {
  61308. /**
  61309. * particle global index
  61310. */
  61311. idx: number;
  61312. /**
  61313. * The color of the particle
  61314. */
  61315. color: Nullable<Color4>;
  61316. /**
  61317. * The world space position of the particle.
  61318. */
  61319. position: Vector3;
  61320. /**
  61321. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  61322. */
  61323. rotation: Vector3;
  61324. /**
  61325. * The world space rotation quaternion of the particle.
  61326. */
  61327. rotationQuaternion: Nullable<Quaternion>;
  61328. /**
  61329. * The uv of the particle.
  61330. */
  61331. uv: Nullable<Vector2>;
  61332. /**
  61333. * The current speed of the particle.
  61334. */
  61335. velocity: Vector3;
  61336. /**
  61337. * The pivot point in the particle local space.
  61338. */
  61339. pivot: Vector3;
  61340. /**
  61341. * Must the particle be translated from its pivot point in its local space ?
  61342. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  61343. * Default : false
  61344. */
  61345. translateFromPivot: boolean;
  61346. /**
  61347. * Index of this particle in the global "positions" array (Internal use)
  61348. * @hidden
  61349. */
  61350. _pos: number;
  61351. /**
  61352. * @hidden Index of this particle in the global "indices" array (Internal use)
  61353. */
  61354. _ind: number;
  61355. /**
  61356. * Group this particle belongs to
  61357. */
  61358. _group: PointsGroup;
  61359. /**
  61360. * Group id of this particle
  61361. */
  61362. groupId: number;
  61363. /**
  61364. * Index of the particle in its group id (Internal use)
  61365. */
  61366. idxInGroup: number;
  61367. /**
  61368. * @hidden Particle BoundingInfo object (Internal use)
  61369. */
  61370. _boundingInfo: BoundingInfo;
  61371. /**
  61372. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  61373. */
  61374. _pcs: PointsCloudSystem;
  61375. /**
  61376. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  61377. */
  61378. _stillInvisible: boolean;
  61379. /**
  61380. * @hidden Last computed particle rotation matrix
  61381. */
  61382. _rotationMatrix: number[];
  61383. /**
  61384. * Parent particle Id, if any.
  61385. * Default null.
  61386. */
  61387. parentId: Nullable<number>;
  61388. /**
  61389. * @hidden Internal global position in the PCS.
  61390. */
  61391. _globalPosition: Vector3;
  61392. /**
  61393. * Creates a Point Cloud object.
  61394. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  61395. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  61396. * @param group (PointsGroup) is the group the particle belongs to
  61397. * @param groupId (integer) is the group identifier in the PCS.
  61398. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  61399. * @param pcs defines the PCS it is associated to
  61400. */
  61401. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  61402. /**
  61403. * get point size
  61404. */
  61405. get size(): Vector3;
  61406. /**
  61407. * Set point size
  61408. */
  61409. set size(scale: Vector3);
  61410. /**
  61411. * Legacy support, changed quaternion to rotationQuaternion
  61412. */
  61413. get quaternion(): Nullable<Quaternion>;
  61414. /**
  61415. * Legacy support, changed quaternion to rotationQuaternion
  61416. */
  61417. set quaternion(q: Nullable<Quaternion>);
  61418. /**
  61419. * Returns a boolean. True if the particle intersects a mesh, else false
  61420. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  61421. * @param target is the object (point or mesh) what the intersection is computed against
  61422. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  61423. * @returns true if it intersects
  61424. */
  61425. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  61426. /**
  61427. * get the rotation matrix of the particle
  61428. * @hidden
  61429. */
  61430. getRotationMatrix(m: Matrix): void;
  61431. }
  61432. /**
  61433. * Represents a group of points in a points cloud system
  61434. * * PCS internal tool, don't use it manually.
  61435. */
  61436. export class PointsGroup {
  61437. /**
  61438. * The group id
  61439. * @hidden
  61440. */
  61441. groupID: number;
  61442. /**
  61443. * image data for group (internal use)
  61444. * @hidden
  61445. */
  61446. _groupImageData: Nullable<ArrayBufferView>;
  61447. /**
  61448. * Image Width (internal use)
  61449. * @hidden
  61450. */
  61451. _groupImgWidth: number;
  61452. /**
  61453. * Image Height (internal use)
  61454. * @hidden
  61455. */
  61456. _groupImgHeight: number;
  61457. /**
  61458. * Custom position function (internal use)
  61459. * @hidden
  61460. */
  61461. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  61462. /**
  61463. * density per facet for surface points
  61464. * @hidden
  61465. */
  61466. _groupDensity: number[];
  61467. /**
  61468. * Only when points are colored by texture carries pointer to texture list array
  61469. * @hidden
  61470. */
  61471. _textureNb: number;
  61472. /**
  61473. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  61474. * PCS internal tool, don't use it manually.
  61475. * @hidden
  61476. */
  61477. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  61478. }
  61479. }
  61480. declare module BABYLON {
  61481. interface Scene {
  61482. /** @hidden (Backing field) */
  61483. _physicsEngine: Nullable<IPhysicsEngine>;
  61484. /** @hidden */
  61485. _physicsTimeAccumulator: number;
  61486. /**
  61487. * Gets the current physics engine
  61488. * @returns a IPhysicsEngine or null if none attached
  61489. */
  61490. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  61491. /**
  61492. * Enables physics to the current scene
  61493. * @param gravity defines the scene's gravity for the physics engine
  61494. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  61495. * @return a boolean indicating if the physics engine was initialized
  61496. */
  61497. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  61498. /**
  61499. * Disables and disposes the physics engine associated with the scene
  61500. */
  61501. disablePhysicsEngine(): void;
  61502. /**
  61503. * Gets a boolean indicating if there is an active physics engine
  61504. * @returns a boolean indicating if there is an active physics engine
  61505. */
  61506. isPhysicsEnabled(): boolean;
  61507. /**
  61508. * Deletes a physics compound impostor
  61509. * @param compound defines the compound to delete
  61510. */
  61511. deleteCompoundImpostor(compound: any): void;
  61512. /**
  61513. * An event triggered when physic simulation is about to be run
  61514. */
  61515. onBeforePhysicsObservable: Observable<Scene>;
  61516. /**
  61517. * An event triggered when physic simulation has been done
  61518. */
  61519. onAfterPhysicsObservable: Observable<Scene>;
  61520. }
  61521. interface AbstractMesh {
  61522. /** @hidden */
  61523. _physicsImpostor: Nullable<PhysicsImpostor>;
  61524. /**
  61525. * Gets or sets impostor used for physic simulation
  61526. * @see http://doc.babylonjs.com/features/physics_engine
  61527. */
  61528. physicsImpostor: Nullable<PhysicsImpostor>;
  61529. /**
  61530. * Gets the current physics impostor
  61531. * @see http://doc.babylonjs.com/features/physics_engine
  61532. * @returns a physics impostor or null
  61533. */
  61534. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  61535. /** Apply a physic impulse to the mesh
  61536. * @param force defines the force to apply
  61537. * @param contactPoint defines where to apply the force
  61538. * @returns the current mesh
  61539. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  61540. */
  61541. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  61542. /**
  61543. * Creates a physic joint between two meshes
  61544. * @param otherMesh defines the other mesh to use
  61545. * @param pivot1 defines the pivot to use on this mesh
  61546. * @param pivot2 defines the pivot to use on the other mesh
  61547. * @param options defines additional options (can be plugin dependent)
  61548. * @returns the current mesh
  61549. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  61550. */
  61551. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  61552. /** @hidden */
  61553. _disposePhysicsObserver: Nullable<Observer<Node>>;
  61554. }
  61555. /**
  61556. * Defines the physics engine scene component responsible to manage a physics engine
  61557. */
  61558. export class PhysicsEngineSceneComponent implements ISceneComponent {
  61559. /**
  61560. * The component name helpful to identify the component in the list of scene components.
  61561. */
  61562. readonly name: string;
  61563. /**
  61564. * The scene the component belongs to.
  61565. */
  61566. scene: Scene;
  61567. /**
  61568. * Creates a new instance of the component for the given scene
  61569. * @param scene Defines the scene to register the component in
  61570. */
  61571. constructor(scene: Scene);
  61572. /**
  61573. * Registers the component in a given scene
  61574. */
  61575. register(): void;
  61576. /**
  61577. * Rebuilds the elements related to this component in case of
  61578. * context lost for instance.
  61579. */
  61580. rebuild(): void;
  61581. /**
  61582. * Disposes the component and the associated ressources
  61583. */
  61584. dispose(): void;
  61585. }
  61586. }
  61587. declare module BABYLON {
  61588. /**
  61589. * A helper for physics simulations
  61590. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61591. */
  61592. export class PhysicsHelper {
  61593. private _scene;
  61594. private _physicsEngine;
  61595. /**
  61596. * Initializes the Physics helper
  61597. * @param scene Babylon.js scene
  61598. */
  61599. constructor(scene: Scene);
  61600. /**
  61601. * Applies a radial explosion impulse
  61602. * @param origin the origin of the explosion
  61603. * @param radiusOrEventOptions the radius or the options of radial explosion
  61604. * @param strength the explosion strength
  61605. * @param falloff possible options: Constant & Linear. Defaults to Constant
  61606. * @returns A physics radial explosion event, or null
  61607. */
  61608. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  61609. /**
  61610. * Applies a radial explosion force
  61611. * @param origin the origin of the explosion
  61612. * @param radiusOrEventOptions the radius or the options of radial explosion
  61613. * @param strength the explosion strength
  61614. * @param falloff possible options: Constant & Linear. Defaults to Constant
  61615. * @returns A physics radial explosion event, or null
  61616. */
  61617. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  61618. /**
  61619. * Creates a gravitational field
  61620. * @param origin the origin of the explosion
  61621. * @param radiusOrEventOptions the radius or the options of radial explosion
  61622. * @param strength the explosion strength
  61623. * @param falloff possible options: Constant & Linear. Defaults to Constant
  61624. * @returns A physics gravitational field event, or null
  61625. */
  61626. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  61627. /**
  61628. * Creates a physics updraft event
  61629. * @param origin the origin of the updraft
  61630. * @param radiusOrEventOptions the radius or the options of the updraft
  61631. * @param strength the strength of the updraft
  61632. * @param height the height of the updraft
  61633. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  61634. * @returns A physics updraft event, or null
  61635. */
  61636. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  61637. /**
  61638. * Creates a physics vortex event
  61639. * @param origin the of the vortex
  61640. * @param radiusOrEventOptions the radius or the options of the vortex
  61641. * @param strength the strength of the vortex
  61642. * @param height the height of the vortex
  61643. * @returns a Physics vortex event, or null
  61644. * A physics vortex event or null
  61645. */
  61646. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  61647. }
  61648. /**
  61649. * Represents a physics radial explosion event
  61650. */
  61651. class PhysicsRadialExplosionEvent {
  61652. private _scene;
  61653. private _options;
  61654. private _sphere;
  61655. private _dataFetched;
  61656. /**
  61657. * Initializes a radial explosioin event
  61658. * @param _scene BabylonJS scene
  61659. * @param _options The options for the vortex event
  61660. */
  61661. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  61662. /**
  61663. * Returns the data related to the radial explosion event (sphere).
  61664. * @returns The radial explosion event data
  61665. */
  61666. getData(): PhysicsRadialExplosionEventData;
  61667. /**
  61668. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  61669. * @param impostor A physics imposter
  61670. * @param origin the origin of the explosion
  61671. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  61672. */
  61673. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  61674. /**
  61675. * Triggers affecterd impostors callbacks
  61676. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  61677. */
  61678. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  61679. /**
  61680. * Disposes the sphere.
  61681. * @param force Specifies if the sphere should be disposed by force
  61682. */
  61683. dispose(force?: boolean): void;
  61684. /*** Helpers ***/
  61685. private _prepareSphere;
  61686. private _intersectsWithSphere;
  61687. }
  61688. /**
  61689. * Represents a gravitational field event
  61690. */
  61691. class PhysicsGravitationalFieldEvent {
  61692. private _physicsHelper;
  61693. private _scene;
  61694. private _origin;
  61695. private _options;
  61696. private _tickCallback;
  61697. private _sphere;
  61698. private _dataFetched;
  61699. /**
  61700. * Initializes the physics gravitational field event
  61701. * @param _physicsHelper A physics helper
  61702. * @param _scene BabylonJS scene
  61703. * @param _origin The origin position of the gravitational field event
  61704. * @param _options The options for the vortex event
  61705. */
  61706. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  61707. /**
  61708. * Returns the data related to the gravitational field event (sphere).
  61709. * @returns A gravitational field event
  61710. */
  61711. getData(): PhysicsGravitationalFieldEventData;
  61712. /**
  61713. * Enables the gravitational field.
  61714. */
  61715. enable(): void;
  61716. /**
  61717. * Disables the gravitational field.
  61718. */
  61719. disable(): void;
  61720. /**
  61721. * Disposes the sphere.
  61722. * @param force The force to dispose from the gravitational field event
  61723. */
  61724. dispose(force?: boolean): void;
  61725. private _tick;
  61726. }
  61727. /**
  61728. * Represents a physics updraft event
  61729. */
  61730. class PhysicsUpdraftEvent {
  61731. private _scene;
  61732. private _origin;
  61733. private _options;
  61734. private _physicsEngine;
  61735. private _originTop;
  61736. private _originDirection;
  61737. private _tickCallback;
  61738. private _cylinder;
  61739. private _cylinderPosition;
  61740. private _dataFetched;
  61741. /**
  61742. * Initializes the physics updraft event
  61743. * @param _scene BabylonJS scene
  61744. * @param _origin The origin position of the updraft
  61745. * @param _options The options for the updraft event
  61746. */
  61747. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  61748. /**
  61749. * Returns the data related to the updraft event (cylinder).
  61750. * @returns A physics updraft event
  61751. */
  61752. getData(): PhysicsUpdraftEventData;
  61753. /**
  61754. * Enables the updraft.
  61755. */
  61756. enable(): void;
  61757. /**
  61758. * Disables the updraft.
  61759. */
  61760. disable(): void;
  61761. /**
  61762. * Disposes the cylinder.
  61763. * @param force Specifies if the updraft should be disposed by force
  61764. */
  61765. dispose(force?: boolean): void;
  61766. private getImpostorHitData;
  61767. private _tick;
  61768. /*** Helpers ***/
  61769. private _prepareCylinder;
  61770. private _intersectsWithCylinder;
  61771. }
  61772. /**
  61773. * Represents a physics vortex event
  61774. */
  61775. class PhysicsVortexEvent {
  61776. private _scene;
  61777. private _origin;
  61778. private _options;
  61779. private _physicsEngine;
  61780. private _originTop;
  61781. private _tickCallback;
  61782. private _cylinder;
  61783. private _cylinderPosition;
  61784. private _dataFetched;
  61785. /**
  61786. * Initializes the physics vortex event
  61787. * @param _scene The BabylonJS scene
  61788. * @param _origin The origin position of the vortex
  61789. * @param _options The options for the vortex event
  61790. */
  61791. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  61792. /**
  61793. * Returns the data related to the vortex event (cylinder).
  61794. * @returns The physics vortex event data
  61795. */
  61796. getData(): PhysicsVortexEventData;
  61797. /**
  61798. * Enables the vortex.
  61799. */
  61800. enable(): void;
  61801. /**
  61802. * Disables the cortex.
  61803. */
  61804. disable(): void;
  61805. /**
  61806. * Disposes the sphere.
  61807. * @param force
  61808. */
  61809. dispose(force?: boolean): void;
  61810. private getImpostorHitData;
  61811. private _tick;
  61812. /*** Helpers ***/
  61813. private _prepareCylinder;
  61814. private _intersectsWithCylinder;
  61815. }
  61816. /**
  61817. * Options fot the radial explosion event
  61818. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61819. */
  61820. export class PhysicsRadialExplosionEventOptions {
  61821. /**
  61822. * The radius of the sphere for the radial explosion.
  61823. */
  61824. radius: number;
  61825. /**
  61826. * The strenth of the explosion.
  61827. */
  61828. strength: number;
  61829. /**
  61830. * The strenght of the force in correspondence to the distance of the affected object
  61831. */
  61832. falloff: PhysicsRadialImpulseFalloff;
  61833. /**
  61834. * Sphere options for the radial explosion.
  61835. */
  61836. sphere: {
  61837. segments: number;
  61838. diameter: number;
  61839. };
  61840. /**
  61841. * Sphere options for the radial explosion.
  61842. */
  61843. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  61844. }
  61845. /**
  61846. * Options fot the updraft event
  61847. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61848. */
  61849. export class PhysicsUpdraftEventOptions {
  61850. /**
  61851. * The radius of the cylinder for the vortex
  61852. */
  61853. radius: number;
  61854. /**
  61855. * The strenth of the updraft.
  61856. */
  61857. strength: number;
  61858. /**
  61859. * The height of the cylinder for the updraft.
  61860. */
  61861. height: number;
  61862. /**
  61863. * The mode for the the updraft.
  61864. */
  61865. updraftMode: PhysicsUpdraftMode;
  61866. }
  61867. /**
  61868. * Options fot the vortex event
  61869. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61870. */
  61871. export class PhysicsVortexEventOptions {
  61872. /**
  61873. * The radius of the cylinder for the vortex
  61874. */
  61875. radius: number;
  61876. /**
  61877. * The strenth of the vortex.
  61878. */
  61879. strength: number;
  61880. /**
  61881. * The height of the cylinder for the vortex.
  61882. */
  61883. height: number;
  61884. /**
  61885. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  61886. */
  61887. centripetalForceThreshold: number;
  61888. /**
  61889. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  61890. */
  61891. centripetalForceMultiplier: number;
  61892. /**
  61893. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  61894. */
  61895. centrifugalForceMultiplier: number;
  61896. /**
  61897. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  61898. */
  61899. updraftForceMultiplier: number;
  61900. }
  61901. /**
  61902. * The strenght of the force in correspondence to the distance of the affected object
  61903. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61904. */
  61905. export enum PhysicsRadialImpulseFalloff {
  61906. /** Defines that impulse is constant in strength across it's whole radius */
  61907. Constant = 0,
  61908. /** Defines that impulse gets weaker if it's further from the origin */
  61909. Linear = 1
  61910. }
  61911. /**
  61912. * The strength of the force in correspondence to the distance of the affected object
  61913. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61914. */
  61915. export enum PhysicsUpdraftMode {
  61916. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  61917. Center = 0,
  61918. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  61919. Perpendicular = 1
  61920. }
  61921. /**
  61922. * Interface for a physics hit data
  61923. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61924. */
  61925. export interface PhysicsHitData {
  61926. /**
  61927. * The force applied at the contact point
  61928. */
  61929. force: Vector3;
  61930. /**
  61931. * The contact point
  61932. */
  61933. contactPoint: Vector3;
  61934. /**
  61935. * The distance from the origin to the contact point
  61936. */
  61937. distanceFromOrigin: number;
  61938. }
  61939. /**
  61940. * Interface for radial explosion event data
  61941. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61942. */
  61943. export interface PhysicsRadialExplosionEventData {
  61944. /**
  61945. * A sphere used for the radial explosion event
  61946. */
  61947. sphere: Mesh;
  61948. }
  61949. /**
  61950. * Interface for gravitational field event data
  61951. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61952. */
  61953. export interface PhysicsGravitationalFieldEventData {
  61954. /**
  61955. * A sphere mesh used for the gravitational field event
  61956. */
  61957. sphere: Mesh;
  61958. }
  61959. /**
  61960. * Interface for updraft event data
  61961. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61962. */
  61963. export interface PhysicsUpdraftEventData {
  61964. /**
  61965. * A cylinder used for the updraft event
  61966. */
  61967. cylinder: Mesh;
  61968. }
  61969. /**
  61970. * Interface for vortex event data
  61971. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61972. */
  61973. export interface PhysicsVortexEventData {
  61974. /**
  61975. * A cylinder used for the vortex event
  61976. */
  61977. cylinder: Mesh;
  61978. }
  61979. /**
  61980. * Interface for an affected physics impostor
  61981. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61982. */
  61983. export interface PhysicsAffectedImpostorWithData {
  61984. /**
  61985. * The impostor affected by the effect
  61986. */
  61987. impostor: PhysicsImpostor;
  61988. /**
  61989. * The data about the hit/horce from the explosion
  61990. */
  61991. hitData: PhysicsHitData;
  61992. }
  61993. }
  61994. declare module BABYLON {
  61995. /** @hidden */
  61996. export var blackAndWhitePixelShader: {
  61997. name: string;
  61998. shader: string;
  61999. };
  62000. }
  62001. declare module BABYLON {
  62002. /**
  62003. * Post process used to render in black and white
  62004. */
  62005. export class BlackAndWhitePostProcess extends PostProcess {
  62006. /**
  62007. * Linear about to convert he result to black and white (default: 1)
  62008. */
  62009. degree: number;
  62010. /**
  62011. * Creates a black and white post process
  62012. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  62013. * @param name The name of the effect.
  62014. * @param options The required width/height ratio to downsize to before computing the render pass.
  62015. * @param camera The camera to apply the render pass to.
  62016. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62017. * @param engine The engine which the post process will be applied. (default: current engine)
  62018. * @param reusable If the post process can be reused on the same frame. (default: false)
  62019. */
  62020. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  62021. }
  62022. }
  62023. declare module BABYLON {
  62024. /**
  62025. * This represents a set of one or more post processes in Babylon.
  62026. * A post process can be used to apply a shader to a texture after it is rendered.
  62027. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  62028. */
  62029. export class PostProcessRenderEffect {
  62030. private _postProcesses;
  62031. private _getPostProcesses;
  62032. private _singleInstance;
  62033. private _cameras;
  62034. private _indicesForCamera;
  62035. /**
  62036. * Name of the effect
  62037. * @hidden
  62038. */
  62039. _name: string;
  62040. /**
  62041. * Instantiates a post process render effect.
  62042. * A post process can be used to apply a shader to a texture after it is rendered.
  62043. * @param engine The engine the effect is tied to
  62044. * @param name The name of the effect
  62045. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  62046. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  62047. */
  62048. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  62049. /**
  62050. * Checks if all the post processes in the effect are supported.
  62051. */
  62052. get isSupported(): boolean;
  62053. /**
  62054. * Updates the current state of the effect
  62055. * @hidden
  62056. */
  62057. _update(): void;
  62058. /**
  62059. * Attaches the effect on cameras
  62060. * @param cameras The camera to attach to.
  62061. * @hidden
  62062. */
  62063. _attachCameras(cameras: Camera): void;
  62064. /**
  62065. * Attaches the effect on cameras
  62066. * @param cameras The camera to attach to.
  62067. * @hidden
  62068. */
  62069. _attachCameras(cameras: Camera[]): void;
  62070. /**
  62071. * Detaches the effect on cameras
  62072. * @param cameras The camera to detatch from.
  62073. * @hidden
  62074. */
  62075. _detachCameras(cameras: Camera): void;
  62076. /**
  62077. * Detatches the effect on cameras
  62078. * @param cameras The camera to detatch from.
  62079. * @hidden
  62080. */
  62081. _detachCameras(cameras: Camera[]): void;
  62082. /**
  62083. * Enables the effect on given cameras
  62084. * @param cameras The camera to enable.
  62085. * @hidden
  62086. */
  62087. _enable(cameras: Camera): void;
  62088. /**
  62089. * Enables the effect on given cameras
  62090. * @param cameras The camera to enable.
  62091. * @hidden
  62092. */
  62093. _enable(cameras: Nullable<Camera[]>): void;
  62094. /**
  62095. * Disables the effect on the given cameras
  62096. * @param cameras The camera to disable.
  62097. * @hidden
  62098. */
  62099. _disable(cameras: Camera): void;
  62100. /**
  62101. * Disables the effect on the given cameras
  62102. * @param cameras The camera to disable.
  62103. * @hidden
  62104. */
  62105. _disable(cameras: Nullable<Camera[]>): void;
  62106. /**
  62107. * Gets a list of the post processes contained in the effect.
  62108. * @param camera The camera to get the post processes on.
  62109. * @returns The list of the post processes in the effect.
  62110. */
  62111. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  62112. }
  62113. }
  62114. declare module BABYLON {
  62115. /** @hidden */
  62116. export var extractHighlightsPixelShader: {
  62117. name: string;
  62118. shader: string;
  62119. };
  62120. }
  62121. declare module BABYLON {
  62122. /**
  62123. * 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.
  62124. */
  62125. export class ExtractHighlightsPostProcess extends PostProcess {
  62126. /**
  62127. * The luminance threshold, pixels below this value will be set to black.
  62128. */
  62129. threshold: number;
  62130. /** @hidden */
  62131. _exposure: number;
  62132. /**
  62133. * Post process which has the input texture to be used when performing highlight extraction
  62134. * @hidden
  62135. */
  62136. _inputPostProcess: Nullable<PostProcess>;
  62137. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62138. }
  62139. }
  62140. declare module BABYLON {
  62141. /** @hidden */
  62142. export var bloomMergePixelShader: {
  62143. name: string;
  62144. shader: string;
  62145. };
  62146. }
  62147. declare module BABYLON {
  62148. /**
  62149. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  62150. */
  62151. export class BloomMergePostProcess extends PostProcess {
  62152. /** Weight of the bloom to be added to the original input. */
  62153. weight: number;
  62154. /**
  62155. * Creates a new instance of @see BloomMergePostProcess
  62156. * @param name The name of the effect.
  62157. * @param originalFromInput Post process which's input will be used for the merge.
  62158. * @param blurred Blurred highlights post process which's output will be used.
  62159. * @param weight Weight of the bloom to be added to the original input.
  62160. * @param options The required width/height ratio to downsize to before computing the render pass.
  62161. * @param camera The camera to apply the render pass to.
  62162. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62163. * @param engine The engine which the post process will be applied. (default: current engine)
  62164. * @param reusable If the post process can be reused on the same frame. (default: false)
  62165. * @param textureType Type of textures used when performing the post process. (default: 0)
  62166. * @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)
  62167. */
  62168. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  62169. /** Weight of the bloom to be added to the original input. */
  62170. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62171. }
  62172. }
  62173. declare module BABYLON {
  62174. /**
  62175. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  62176. */
  62177. export class BloomEffect extends PostProcessRenderEffect {
  62178. private bloomScale;
  62179. /**
  62180. * @hidden Internal
  62181. */
  62182. _effects: Array<PostProcess>;
  62183. /**
  62184. * @hidden Internal
  62185. */
  62186. _downscale: ExtractHighlightsPostProcess;
  62187. private _blurX;
  62188. private _blurY;
  62189. private _merge;
  62190. /**
  62191. * The luminance threshold to find bright areas of the image to bloom.
  62192. */
  62193. get threshold(): number;
  62194. set threshold(value: number);
  62195. /**
  62196. * The strength of the bloom.
  62197. */
  62198. get weight(): number;
  62199. set weight(value: number);
  62200. /**
  62201. * Specifies the size of the bloom blur kernel, relative to the final output size
  62202. */
  62203. get kernel(): number;
  62204. set kernel(value: number);
  62205. /**
  62206. * Creates a new instance of @see BloomEffect
  62207. * @param scene The scene the effect belongs to.
  62208. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  62209. * @param bloomKernel The size of the kernel to be used when applying the blur.
  62210. * @param bloomWeight The the strength of bloom.
  62211. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  62212. * @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)
  62213. */
  62214. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  62215. /**
  62216. * Disposes each of the internal effects for a given camera.
  62217. * @param camera The camera to dispose the effect on.
  62218. */
  62219. disposeEffects(camera: Camera): void;
  62220. /**
  62221. * @hidden Internal
  62222. */
  62223. _updateEffects(): void;
  62224. /**
  62225. * Internal
  62226. * @returns if all the contained post processes are ready.
  62227. * @hidden
  62228. */
  62229. _isReady(): boolean;
  62230. }
  62231. }
  62232. declare module BABYLON {
  62233. /** @hidden */
  62234. export var chromaticAberrationPixelShader: {
  62235. name: string;
  62236. shader: string;
  62237. };
  62238. }
  62239. declare module BABYLON {
  62240. /**
  62241. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  62242. */
  62243. export class ChromaticAberrationPostProcess extends PostProcess {
  62244. /**
  62245. * The amount of seperation of rgb channels (default: 30)
  62246. */
  62247. aberrationAmount: number;
  62248. /**
  62249. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  62250. */
  62251. radialIntensity: number;
  62252. /**
  62253. * 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))
  62254. */
  62255. direction: Vector2;
  62256. /**
  62257. * 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))
  62258. */
  62259. centerPosition: Vector2;
  62260. /**
  62261. * Creates a new instance ChromaticAberrationPostProcess
  62262. * @param name The name of the effect.
  62263. * @param screenWidth The width of the screen to apply the effect on.
  62264. * @param screenHeight The height of the screen to apply the effect on.
  62265. * @param options The required width/height ratio to downsize to before computing the render pass.
  62266. * @param camera The camera to apply the render pass to.
  62267. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62268. * @param engine The engine which the post process will be applied. (default: current engine)
  62269. * @param reusable If the post process can be reused on the same frame. (default: false)
  62270. * @param textureType Type of textures used when performing the post process. (default: 0)
  62271. * @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)
  62272. */
  62273. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62274. }
  62275. }
  62276. declare module BABYLON {
  62277. /** @hidden */
  62278. export var circleOfConfusionPixelShader: {
  62279. name: string;
  62280. shader: string;
  62281. };
  62282. }
  62283. declare module BABYLON {
  62284. /**
  62285. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  62286. */
  62287. export class CircleOfConfusionPostProcess extends PostProcess {
  62288. /**
  62289. * 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.
  62290. */
  62291. lensSize: number;
  62292. /**
  62293. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  62294. */
  62295. fStop: number;
  62296. /**
  62297. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  62298. */
  62299. focusDistance: number;
  62300. /**
  62301. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  62302. */
  62303. focalLength: number;
  62304. private _depthTexture;
  62305. /**
  62306. * Creates a new instance CircleOfConfusionPostProcess
  62307. * @param name The name of the effect.
  62308. * @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.
  62309. * @param options The required width/height ratio to downsize to before computing the render pass.
  62310. * @param camera The camera to apply the render pass to.
  62311. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62312. * @param engine The engine which the post process will be applied. (default: current engine)
  62313. * @param reusable If the post process can be reused on the same frame. (default: false)
  62314. * @param textureType Type of textures used when performing the post process. (default: 0)
  62315. * @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)
  62316. */
  62317. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62318. /**
  62319. * 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.
  62320. */
  62321. set depthTexture(value: RenderTargetTexture);
  62322. }
  62323. }
  62324. declare module BABYLON {
  62325. /** @hidden */
  62326. export var colorCorrectionPixelShader: {
  62327. name: string;
  62328. shader: string;
  62329. };
  62330. }
  62331. declare module BABYLON {
  62332. /**
  62333. *
  62334. * This post-process allows the modification of rendered colors by using
  62335. * a 'look-up table' (LUT). This effect is also called Color Grading.
  62336. *
  62337. * The object needs to be provided an url to a texture containing the color
  62338. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  62339. * Use an image editing software to tweak the LUT to match your needs.
  62340. *
  62341. * For an example of a color LUT, see here:
  62342. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  62343. * For explanations on color grading, see here:
  62344. * @see http://udn.epicgames.com/Three/ColorGrading.html
  62345. *
  62346. */
  62347. export class ColorCorrectionPostProcess extends PostProcess {
  62348. private _colorTableTexture;
  62349. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  62350. }
  62351. }
  62352. declare module BABYLON {
  62353. /** @hidden */
  62354. export var convolutionPixelShader: {
  62355. name: string;
  62356. shader: string;
  62357. };
  62358. }
  62359. declare module BABYLON {
  62360. /**
  62361. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  62362. * input texture to perform effects such as edge detection or sharpening
  62363. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  62364. */
  62365. export class ConvolutionPostProcess extends PostProcess {
  62366. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  62367. kernel: number[];
  62368. /**
  62369. * Creates a new instance ConvolutionPostProcess
  62370. * @param name The name of the effect.
  62371. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  62372. * @param options The required width/height ratio to downsize to before computing the render pass.
  62373. * @param camera The camera to apply the render pass to.
  62374. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62375. * @param engine The engine which the post process will be applied. (default: current engine)
  62376. * @param reusable If the post process can be reused on the same frame. (default: false)
  62377. * @param textureType Type of textures used when performing the post process. (default: 0)
  62378. */
  62379. constructor(name: string,
  62380. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  62381. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  62382. /**
  62383. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62384. */
  62385. static EdgeDetect0Kernel: number[];
  62386. /**
  62387. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62388. */
  62389. static EdgeDetect1Kernel: number[];
  62390. /**
  62391. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62392. */
  62393. static EdgeDetect2Kernel: number[];
  62394. /**
  62395. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62396. */
  62397. static SharpenKernel: number[];
  62398. /**
  62399. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62400. */
  62401. static EmbossKernel: number[];
  62402. /**
  62403. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62404. */
  62405. static GaussianKernel: number[];
  62406. }
  62407. }
  62408. declare module BABYLON {
  62409. /**
  62410. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  62411. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  62412. * based on samples that have a large difference in distance than the center pixel.
  62413. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  62414. */
  62415. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  62416. direction: Vector2;
  62417. /**
  62418. * Creates a new instance CircleOfConfusionPostProcess
  62419. * @param name The name of the effect.
  62420. * @param scene The scene the effect belongs to.
  62421. * @param direction The direction the blur should be applied.
  62422. * @param kernel The size of the kernel used to blur.
  62423. * @param options The required width/height ratio to downsize to before computing the render pass.
  62424. * @param camera The camera to apply the render pass to.
  62425. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  62426. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  62427. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62428. * @param engine The engine which the post process will be applied. (default: current engine)
  62429. * @param reusable If the post process can be reused on the same frame. (default: false)
  62430. * @param textureType Type of textures used when performing the post process. (default: 0)
  62431. * @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)
  62432. */
  62433. 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);
  62434. }
  62435. }
  62436. declare module BABYLON {
  62437. /** @hidden */
  62438. export var depthOfFieldMergePixelShader: {
  62439. name: string;
  62440. shader: string;
  62441. };
  62442. }
  62443. declare module BABYLON {
  62444. /**
  62445. * Options to be set when merging outputs from the default pipeline.
  62446. */
  62447. export class DepthOfFieldMergePostProcessOptions {
  62448. /**
  62449. * The original image to merge on top of
  62450. */
  62451. originalFromInput: PostProcess;
  62452. /**
  62453. * Parameters to perform the merge of the depth of field effect
  62454. */
  62455. depthOfField?: {
  62456. circleOfConfusion: PostProcess;
  62457. blurSteps: Array<PostProcess>;
  62458. };
  62459. /**
  62460. * Parameters to perform the merge of bloom effect
  62461. */
  62462. bloom?: {
  62463. blurred: PostProcess;
  62464. weight: number;
  62465. };
  62466. }
  62467. /**
  62468. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  62469. */
  62470. export class DepthOfFieldMergePostProcess extends PostProcess {
  62471. private blurSteps;
  62472. /**
  62473. * Creates a new instance of DepthOfFieldMergePostProcess
  62474. * @param name The name of the effect.
  62475. * @param originalFromInput Post process which's input will be used for the merge.
  62476. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  62477. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  62478. * @param options The required width/height ratio to downsize to before computing the render pass.
  62479. * @param camera The camera to apply the render pass to.
  62480. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62481. * @param engine The engine which the post process will be applied. (default: current engine)
  62482. * @param reusable If the post process can be reused on the same frame. (default: false)
  62483. * @param textureType Type of textures used when performing the post process. (default: 0)
  62484. * @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)
  62485. */
  62486. 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);
  62487. /**
  62488. * Updates the effect with the current post process compile time values and recompiles the shader.
  62489. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  62490. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  62491. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  62492. * @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
  62493. * @param onCompiled Called when the shader has been compiled.
  62494. * @param onError Called if there is an error when compiling a shader.
  62495. */
  62496. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  62497. }
  62498. }
  62499. declare module BABYLON {
  62500. /**
  62501. * Specifies the level of max blur that should be applied when using the depth of field effect
  62502. */
  62503. export enum DepthOfFieldEffectBlurLevel {
  62504. /**
  62505. * Subtle blur
  62506. */
  62507. Low = 0,
  62508. /**
  62509. * Medium blur
  62510. */
  62511. Medium = 1,
  62512. /**
  62513. * Large blur
  62514. */
  62515. High = 2
  62516. }
  62517. /**
  62518. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  62519. */
  62520. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  62521. private _circleOfConfusion;
  62522. /**
  62523. * @hidden Internal, blurs from high to low
  62524. */
  62525. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  62526. private _depthOfFieldBlurY;
  62527. private _dofMerge;
  62528. /**
  62529. * @hidden Internal post processes in depth of field effect
  62530. */
  62531. _effects: Array<PostProcess>;
  62532. /**
  62533. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  62534. */
  62535. set focalLength(value: number);
  62536. get focalLength(): number;
  62537. /**
  62538. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  62539. */
  62540. set fStop(value: number);
  62541. get fStop(): number;
  62542. /**
  62543. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  62544. */
  62545. set focusDistance(value: number);
  62546. get focusDistance(): number;
  62547. /**
  62548. * 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.
  62549. */
  62550. set lensSize(value: number);
  62551. get lensSize(): number;
  62552. /**
  62553. * Creates a new instance DepthOfFieldEffect
  62554. * @param scene The scene the effect belongs to.
  62555. * @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.
  62556. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  62557. * @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)
  62558. */
  62559. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  62560. /**
  62561. * Get the current class name of the current effet
  62562. * @returns "DepthOfFieldEffect"
  62563. */
  62564. getClassName(): string;
  62565. /**
  62566. * 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.
  62567. */
  62568. set depthTexture(value: RenderTargetTexture);
  62569. /**
  62570. * Disposes each of the internal effects for a given camera.
  62571. * @param camera The camera to dispose the effect on.
  62572. */
  62573. disposeEffects(camera: Camera): void;
  62574. /**
  62575. * @hidden Internal
  62576. */
  62577. _updateEffects(): void;
  62578. /**
  62579. * Internal
  62580. * @returns if all the contained post processes are ready.
  62581. * @hidden
  62582. */
  62583. _isReady(): boolean;
  62584. }
  62585. }
  62586. declare module BABYLON {
  62587. /** @hidden */
  62588. export var displayPassPixelShader: {
  62589. name: string;
  62590. shader: string;
  62591. };
  62592. }
  62593. declare module BABYLON {
  62594. /**
  62595. * DisplayPassPostProcess which produces an output the same as it's input
  62596. */
  62597. export class DisplayPassPostProcess extends PostProcess {
  62598. /**
  62599. * Creates the DisplayPassPostProcess
  62600. * @param name The name of the effect.
  62601. * @param options The required width/height ratio to downsize to before computing the render pass.
  62602. * @param camera The camera to apply the render pass to.
  62603. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62604. * @param engine The engine which the post process will be applied. (default: current engine)
  62605. * @param reusable If the post process can be reused on the same frame. (default: false)
  62606. */
  62607. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  62608. }
  62609. }
  62610. declare module BABYLON {
  62611. /** @hidden */
  62612. export var filterPixelShader: {
  62613. name: string;
  62614. shader: string;
  62615. };
  62616. }
  62617. declare module BABYLON {
  62618. /**
  62619. * Applies a kernel filter to the image
  62620. */
  62621. export class FilterPostProcess extends PostProcess {
  62622. /** The matrix to be applied to the image */
  62623. kernelMatrix: Matrix;
  62624. /**
  62625. *
  62626. * @param name The name of the effect.
  62627. * @param kernelMatrix The matrix to be applied to the image
  62628. * @param options The required width/height ratio to downsize to before computing the render pass.
  62629. * @param camera The camera to apply the render pass to.
  62630. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62631. * @param engine The engine which the post process will be applied. (default: current engine)
  62632. * @param reusable If the post process can be reused on the same frame. (default: false)
  62633. */
  62634. constructor(name: string,
  62635. /** The matrix to be applied to the image */
  62636. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  62637. }
  62638. }
  62639. declare module BABYLON {
  62640. /** @hidden */
  62641. export var fxaaPixelShader: {
  62642. name: string;
  62643. shader: string;
  62644. };
  62645. }
  62646. declare module BABYLON {
  62647. /** @hidden */
  62648. export var fxaaVertexShader: {
  62649. name: string;
  62650. shader: string;
  62651. };
  62652. }
  62653. declare module BABYLON {
  62654. /**
  62655. * Fxaa post process
  62656. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  62657. */
  62658. export class FxaaPostProcess extends PostProcess {
  62659. /** @hidden */
  62660. texelWidth: number;
  62661. /** @hidden */
  62662. texelHeight: number;
  62663. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  62664. private _getDefines;
  62665. }
  62666. }
  62667. declare module BABYLON {
  62668. /** @hidden */
  62669. export var grainPixelShader: {
  62670. name: string;
  62671. shader: string;
  62672. };
  62673. }
  62674. declare module BABYLON {
  62675. /**
  62676. * The GrainPostProcess adds noise to the image at mid luminance levels
  62677. */
  62678. export class GrainPostProcess extends PostProcess {
  62679. /**
  62680. * The intensity of the grain added (default: 30)
  62681. */
  62682. intensity: number;
  62683. /**
  62684. * If the grain should be randomized on every frame
  62685. */
  62686. animated: boolean;
  62687. /**
  62688. * Creates a new instance of @see GrainPostProcess
  62689. * @param name The name of the effect.
  62690. * @param options The required width/height ratio to downsize to before computing the render pass.
  62691. * @param camera The camera to apply the render pass to.
  62692. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62693. * @param engine The engine which the post process will be applied. (default: current engine)
  62694. * @param reusable If the post process can be reused on the same frame. (default: false)
  62695. * @param textureType Type of textures used when performing the post process. (default: 0)
  62696. * @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)
  62697. */
  62698. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62699. }
  62700. }
  62701. declare module BABYLON {
  62702. /** @hidden */
  62703. export var highlightsPixelShader: {
  62704. name: string;
  62705. shader: string;
  62706. };
  62707. }
  62708. declare module BABYLON {
  62709. /**
  62710. * Extracts highlights from the image
  62711. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  62712. */
  62713. export class HighlightsPostProcess extends PostProcess {
  62714. /**
  62715. * Extracts highlights from the image
  62716. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  62717. * @param name The name of the effect.
  62718. * @param options The required width/height ratio to downsize to before computing the render pass.
  62719. * @param camera The camera to apply the render pass to.
  62720. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62721. * @param engine The engine which the post process will be applied. (default: current engine)
  62722. * @param reusable If the post process can be reused on the same frame. (default: false)
  62723. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  62724. */
  62725. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  62726. }
  62727. }
  62728. declare module BABYLON {
  62729. /** @hidden */
  62730. export var mrtFragmentDeclaration: {
  62731. name: string;
  62732. shader: string;
  62733. };
  62734. }
  62735. declare module BABYLON {
  62736. /** @hidden */
  62737. export var geometryPixelShader: {
  62738. name: string;
  62739. shader: string;
  62740. };
  62741. }
  62742. declare module BABYLON {
  62743. /** @hidden */
  62744. export var geometryVertexShader: {
  62745. name: string;
  62746. shader: string;
  62747. };
  62748. }
  62749. declare module BABYLON {
  62750. /** @hidden */
  62751. interface ISavedTransformationMatrix {
  62752. world: Matrix;
  62753. viewProjection: Matrix;
  62754. }
  62755. /**
  62756. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  62757. */
  62758. export class GeometryBufferRenderer {
  62759. /**
  62760. * Constant used to retrieve the position texture index in the G-Buffer textures array
  62761. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  62762. */
  62763. static readonly POSITION_TEXTURE_TYPE: number;
  62764. /**
  62765. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  62766. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  62767. */
  62768. static readonly VELOCITY_TEXTURE_TYPE: number;
  62769. /**
  62770. * Dictionary used to store the previous transformation matrices of each rendered mesh
  62771. * in order to compute objects velocities when enableVelocity is set to "true"
  62772. * @hidden
  62773. */
  62774. _previousTransformationMatrices: {
  62775. [index: number]: ISavedTransformationMatrix;
  62776. };
  62777. /**
  62778. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  62779. * in order to compute objects velocities when enableVelocity is set to "true"
  62780. * @hidden
  62781. */
  62782. _previousBonesTransformationMatrices: {
  62783. [index: number]: Float32Array;
  62784. };
  62785. /**
  62786. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  62787. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  62788. */
  62789. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  62790. private _scene;
  62791. private _multiRenderTarget;
  62792. private _ratio;
  62793. private _enablePosition;
  62794. private _enableVelocity;
  62795. private _positionIndex;
  62796. private _velocityIndex;
  62797. protected _effect: Effect;
  62798. protected _cachedDefines: string;
  62799. /**
  62800. * Set the render list (meshes to be rendered) used in the G buffer.
  62801. */
  62802. set renderList(meshes: Mesh[]);
  62803. /**
  62804. * Gets wether or not G buffer are supported by the running hardware.
  62805. * This requires draw buffer supports
  62806. */
  62807. get isSupported(): boolean;
  62808. /**
  62809. * Returns the index of the given texture type in the G-Buffer textures array
  62810. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  62811. * @returns the index of the given texture type in the G-Buffer textures array
  62812. */
  62813. getTextureIndex(textureType: number): number;
  62814. /**
  62815. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  62816. */
  62817. get enablePosition(): boolean;
  62818. /**
  62819. * Sets whether or not objects positions are enabled for the G buffer.
  62820. */
  62821. set enablePosition(enable: boolean);
  62822. /**
  62823. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  62824. */
  62825. get enableVelocity(): boolean;
  62826. /**
  62827. * Sets wether or not objects velocities are enabled for the G buffer.
  62828. */
  62829. set enableVelocity(enable: boolean);
  62830. /**
  62831. * Gets the scene associated with the buffer.
  62832. */
  62833. get scene(): Scene;
  62834. /**
  62835. * Gets the ratio used by the buffer during its creation.
  62836. * How big is the buffer related to the main canvas.
  62837. */
  62838. get ratio(): number;
  62839. /** @hidden */
  62840. static _SceneComponentInitialization: (scene: Scene) => void;
  62841. /**
  62842. * Creates a new G Buffer for the scene
  62843. * @param scene The scene the buffer belongs to
  62844. * @param ratio How big is the buffer related to the main canvas.
  62845. */
  62846. constructor(scene: Scene, ratio?: number);
  62847. /**
  62848. * Checks wether everything is ready to render a submesh to the G buffer.
  62849. * @param subMesh the submesh to check readiness for
  62850. * @param useInstances is the mesh drawn using instance or not
  62851. * @returns true if ready otherwise false
  62852. */
  62853. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62854. /**
  62855. * Gets the current underlying G Buffer.
  62856. * @returns the buffer
  62857. */
  62858. getGBuffer(): MultiRenderTarget;
  62859. /**
  62860. * Gets the number of samples used to render the buffer (anti aliasing).
  62861. */
  62862. get samples(): number;
  62863. /**
  62864. * Sets the number of samples used to render the buffer (anti aliasing).
  62865. */
  62866. set samples(value: number);
  62867. /**
  62868. * Disposes the renderer and frees up associated resources.
  62869. */
  62870. dispose(): void;
  62871. protected _createRenderTargets(): void;
  62872. private _copyBonesTransformationMatrices;
  62873. }
  62874. }
  62875. declare module BABYLON {
  62876. interface Scene {
  62877. /** @hidden (Backing field) */
  62878. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  62879. /**
  62880. * Gets or Sets the current geometry buffer associated to the scene.
  62881. */
  62882. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  62883. /**
  62884. * Enables a GeometryBufferRender and associates it with the scene
  62885. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  62886. * @returns the GeometryBufferRenderer
  62887. */
  62888. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  62889. /**
  62890. * Disables the GeometryBufferRender associated with the scene
  62891. */
  62892. disableGeometryBufferRenderer(): void;
  62893. }
  62894. /**
  62895. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  62896. * in several rendering techniques.
  62897. */
  62898. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  62899. /**
  62900. * The component name helpful to identify the component in the list of scene components.
  62901. */
  62902. readonly name: string;
  62903. /**
  62904. * The scene the component belongs to.
  62905. */
  62906. scene: Scene;
  62907. /**
  62908. * Creates a new instance of the component for the given scene
  62909. * @param scene Defines the scene to register the component in
  62910. */
  62911. constructor(scene: Scene);
  62912. /**
  62913. * Registers the component in a given scene
  62914. */
  62915. register(): void;
  62916. /**
  62917. * Rebuilds the elements related to this component in case of
  62918. * context lost for instance.
  62919. */
  62920. rebuild(): void;
  62921. /**
  62922. * Disposes the component and the associated ressources
  62923. */
  62924. dispose(): void;
  62925. private _gatherRenderTargets;
  62926. }
  62927. }
  62928. declare module BABYLON {
  62929. /** @hidden */
  62930. export var motionBlurPixelShader: {
  62931. name: string;
  62932. shader: string;
  62933. };
  62934. }
  62935. declare module BABYLON {
  62936. /**
  62937. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  62938. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  62939. * As an example, all you have to do is to create the post-process:
  62940. * var mb = new BABYLON.MotionBlurPostProcess(
  62941. * 'mb', // The name of the effect.
  62942. * scene, // The scene containing the objects to blur according to their velocity.
  62943. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  62944. * camera // The camera to apply the render pass to.
  62945. * );
  62946. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  62947. */
  62948. export class MotionBlurPostProcess extends PostProcess {
  62949. /**
  62950. * Defines how much the image is blurred by the movement. Default value is equal to 1
  62951. */
  62952. motionStrength: number;
  62953. /**
  62954. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  62955. */
  62956. get motionBlurSamples(): number;
  62957. /**
  62958. * Sets the number of iterations to be used for motion blur quality
  62959. */
  62960. set motionBlurSamples(samples: number);
  62961. private _motionBlurSamples;
  62962. private _geometryBufferRenderer;
  62963. /**
  62964. * Creates a new instance MotionBlurPostProcess
  62965. * @param name The name of the effect.
  62966. * @param scene The scene containing the objects to blur according to their velocity.
  62967. * @param options The required width/height ratio to downsize to before computing the render pass.
  62968. * @param camera The camera to apply the render pass to.
  62969. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62970. * @param engine The engine which the post process will be applied. (default: current engine)
  62971. * @param reusable If the post process can be reused on the same frame. (default: false)
  62972. * @param textureType Type of textures used when performing the post process. (default: 0)
  62973. * @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)
  62974. */
  62975. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62976. /**
  62977. * Excludes the given skinned mesh from computing bones velocities.
  62978. * 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.
  62979. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  62980. */
  62981. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  62982. /**
  62983. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  62984. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  62985. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  62986. */
  62987. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  62988. /**
  62989. * Disposes the post process.
  62990. * @param camera The camera to dispose the post process on.
  62991. */
  62992. dispose(camera?: Camera): void;
  62993. }
  62994. }
  62995. declare module BABYLON {
  62996. /** @hidden */
  62997. export var refractionPixelShader: {
  62998. name: string;
  62999. shader: string;
  63000. };
  63001. }
  63002. declare module BABYLON {
  63003. /**
  63004. * Post process which applies a refractin texture
  63005. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  63006. */
  63007. export class RefractionPostProcess extends PostProcess {
  63008. /** the base color of the refraction (used to taint the rendering) */
  63009. color: Color3;
  63010. /** simulated refraction depth */
  63011. depth: number;
  63012. /** the coefficient of the base color (0 to remove base color tainting) */
  63013. colorLevel: number;
  63014. private _refTexture;
  63015. private _ownRefractionTexture;
  63016. /**
  63017. * Gets or sets the refraction texture
  63018. * Please note that you are responsible for disposing the texture if you set it manually
  63019. */
  63020. get refractionTexture(): Texture;
  63021. set refractionTexture(value: Texture);
  63022. /**
  63023. * Initializes the RefractionPostProcess
  63024. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  63025. * @param name The name of the effect.
  63026. * @param refractionTextureUrl Url of the refraction texture to use
  63027. * @param color the base color of the refraction (used to taint the rendering)
  63028. * @param depth simulated refraction depth
  63029. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  63030. * @param camera The camera to apply the render pass to.
  63031. * @param options The required width/height ratio to downsize to before computing the render pass.
  63032. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63033. * @param engine The engine which the post process will be applied. (default: current engine)
  63034. * @param reusable If the post process can be reused on the same frame. (default: false)
  63035. */
  63036. constructor(name: string, refractionTextureUrl: string,
  63037. /** the base color of the refraction (used to taint the rendering) */
  63038. color: Color3,
  63039. /** simulated refraction depth */
  63040. depth: number,
  63041. /** the coefficient of the base color (0 to remove base color tainting) */
  63042. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  63043. /**
  63044. * Disposes of the post process
  63045. * @param camera Camera to dispose post process on
  63046. */
  63047. dispose(camera: Camera): void;
  63048. }
  63049. }
  63050. declare module BABYLON {
  63051. /** @hidden */
  63052. export var sharpenPixelShader: {
  63053. name: string;
  63054. shader: string;
  63055. };
  63056. }
  63057. declare module BABYLON {
  63058. /**
  63059. * The SharpenPostProcess applies a sharpen kernel to every pixel
  63060. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  63061. */
  63062. export class SharpenPostProcess extends PostProcess {
  63063. /**
  63064. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  63065. */
  63066. colorAmount: number;
  63067. /**
  63068. * How much sharpness should be applied (default: 0.3)
  63069. */
  63070. edgeAmount: number;
  63071. /**
  63072. * Creates a new instance ConvolutionPostProcess
  63073. * @param name The name of the effect.
  63074. * @param options The required width/height ratio to downsize to before computing the render pass.
  63075. * @param camera The camera to apply the render pass to.
  63076. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63077. * @param engine The engine which the post process will be applied. (default: current engine)
  63078. * @param reusable If the post process can be reused on the same frame. (default: false)
  63079. * @param textureType Type of textures used when performing the post process. (default: 0)
  63080. * @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)
  63081. */
  63082. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63083. }
  63084. }
  63085. declare module BABYLON {
  63086. /**
  63087. * PostProcessRenderPipeline
  63088. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63089. */
  63090. export class PostProcessRenderPipeline {
  63091. private engine;
  63092. private _renderEffects;
  63093. private _renderEffectsForIsolatedPass;
  63094. /**
  63095. * List of inspectable custom properties (used by the Inspector)
  63096. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  63097. */
  63098. inspectableCustomProperties: IInspectable[];
  63099. /**
  63100. * @hidden
  63101. */
  63102. protected _cameras: Camera[];
  63103. /** @hidden */
  63104. _name: string;
  63105. /**
  63106. * Gets pipeline name
  63107. */
  63108. get name(): string;
  63109. /** Gets the list of attached cameras */
  63110. get cameras(): Camera[];
  63111. /**
  63112. * Initializes a PostProcessRenderPipeline
  63113. * @param engine engine to add the pipeline to
  63114. * @param name name of the pipeline
  63115. */
  63116. constructor(engine: Engine, name: string);
  63117. /**
  63118. * Gets the class name
  63119. * @returns "PostProcessRenderPipeline"
  63120. */
  63121. getClassName(): string;
  63122. /**
  63123. * If all the render effects in the pipeline are supported
  63124. */
  63125. get isSupported(): boolean;
  63126. /**
  63127. * Adds an effect to the pipeline
  63128. * @param renderEffect the effect to add
  63129. */
  63130. addEffect(renderEffect: PostProcessRenderEffect): void;
  63131. /** @hidden */
  63132. _rebuild(): void;
  63133. /** @hidden */
  63134. _enableEffect(renderEffectName: string, cameras: Camera): void;
  63135. /** @hidden */
  63136. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  63137. /** @hidden */
  63138. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  63139. /** @hidden */
  63140. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  63141. /** @hidden */
  63142. _attachCameras(cameras: Camera, unique: boolean): void;
  63143. /** @hidden */
  63144. _attachCameras(cameras: Camera[], unique: boolean): void;
  63145. /** @hidden */
  63146. _detachCameras(cameras: Camera): void;
  63147. /** @hidden */
  63148. _detachCameras(cameras: Nullable<Camera[]>): void;
  63149. /** @hidden */
  63150. _update(): void;
  63151. /** @hidden */
  63152. _reset(): void;
  63153. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  63154. /**
  63155. * Disposes of the pipeline
  63156. */
  63157. dispose(): void;
  63158. }
  63159. }
  63160. declare module BABYLON {
  63161. /**
  63162. * PostProcessRenderPipelineManager class
  63163. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63164. */
  63165. export class PostProcessRenderPipelineManager {
  63166. private _renderPipelines;
  63167. /**
  63168. * Initializes a PostProcessRenderPipelineManager
  63169. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63170. */
  63171. constructor();
  63172. /**
  63173. * Gets the list of supported render pipelines
  63174. */
  63175. get supportedPipelines(): PostProcessRenderPipeline[];
  63176. /**
  63177. * Adds a pipeline to the manager
  63178. * @param renderPipeline The pipeline to add
  63179. */
  63180. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  63181. /**
  63182. * Attaches a camera to the pipeline
  63183. * @param renderPipelineName The name of the pipeline to attach to
  63184. * @param cameras the camera to attach
  63185. * @param unique if the camera can be attached multiple times to the pipeline
  63186. */
  63187. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  63188. /**
  63189. * Detaches a camera from the pipeline
  63190. * @param renderPipelineName The name of the pipeline to detach from
  63191. * @param cameras the camera to detach
  63192. */
  63193. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  63194. /**
  63195. * Enables an effect by name on a pipeline
  63196. * @param renderPipelineName the name of the pipeline to enable the effect in
  63197. * @param renderEffectName the name of the effect to enable
  63198. * @param cameras the cameras that the effect should be enabled on
  63199. */
  63200. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  63201. /**
  63202. * Disables an effect by name on a pipeline
  63203. * @param renderPipelineName the name of the pipeline to disable the effect in
  63204. * @param renderEffectName the name of the effect to disable
  63205. * @param cameras the cameras that the effect should be disabled on
  63206. */
  63207. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  63208. /**
  63209. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  63210. */
  63211. update(): void;
  63212. /** @hidden */
  63213. _rebuild(): void;
  63214. /**
  63215. * Disposes of the manager and pipelines
  63216. */
  63217. dispose(): void;
  63218. }
  63219. }
  63220. declare module BABYLON {
  63221. interface Scene {
  63222. /** @hidden (Backing field) */
  63223. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  63224. /**
  63225. * Gets the postprocess render pipeline manager
  63226. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63227. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  63228. */
  63229. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  63230. }
  63231. /**
  63232. * Defines the Render Pipeline scene component responsible to rendering pipelines
  63233. */
  63234. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  63235. /**
  63236. * The component name helpfull to identify the component in the list of scene components.
  63237. */
  63238. readonly name: string;
  63239. /**
  63240. * The scene the component belongs to.
  63241. */
  63242. scene: Scene;
  63243. /**
  63244. * Creates a new instance of the component for the given scene
  63245. * @param scene Defines the scene to register the component in
  63246. */
  63247. constructor(scene: Scene);
  63248. /**
  63249. * Registers the component in a given scene
  63250. */
  63251. register(): void;
  63252. /**
  63253. * Rebuilds the elements related to this component in case of
  63254. * context lost for instance.
  63255. */
  63256. rebuild(): void;
  63257. /**
  63258. * Disposes the component and the associated ressources
  63259. */
  63260. dispose(): void;
  63261. private _gatherRenderTargets;
  63262. }
  63263. }
  63264. declare module BABYLON {
  63265. /**
  63266. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  63267. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  63268. */
  63269. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  63270. private _scene;
  63271. private _camerasToBeAttached;
  63272. /**
  63273. * ID of the sharpen post process,
  63274. */
  63275. private readonly SharpenPostProcessId;
  63276. /**
  63277. * @ignore
  63278. * ID of the image processing post process;
  63279. */
  63280. readonly ImageProcessingPostProcessId: string;
  63281. /**
  63282. * @ignore
  63283. * ID of the Fast Approximate Anti-Aliasing post process;
  63284. */
  63285. readonly FxaaPostProcessId: string;
  63286. /**
  63287. * ID of the chromatic aberration post process,
  63288. */
  63289. private readonly ChromaticAberrationPostProcessId;
  63290. /**
  63291. * ID of the grain post process
  63292. */
  63293. private readonly GrainPostProcessId;
  63294. /**
  63295. * Sharpen post process which will apply a sharpen convolution to enhance edges
  63296. */
  63297. sharpen: SharpenPostProcess;
  63298. private _sharpenEffect;
  63299. private bloom;
  63300. /**
  63301. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  63302. */
  63303. depthOfField: DepthOfFieldEffect;
  63304. /**
  63305. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  63306. */
  63307. fxaa: FxaaPostProcess;
  63308. /**
  63309. * Image post processing pass used to perform operations such as tone mapping or color grading.
  63310. */
  63311. imageProcessing: ImageProcessingPostProcess;
  63312. /**
  63313. * Chromatic aberration post process which will shift rgb colors in the image
  63314. */
  63315. chromaticAberration: ChromaticAberrationPostProcess;
  63316. private _chromaticAberrationEffect;
  63317. /**
  63318. * Grain post process which add noise to the image
  63319. */
  63320. grain: GrainPostProcess;
  63321. private _grainEffect;
  63322. /**
  63323. * Glow post process which adds a glow to emissive areas of the image
  63324. */
  63325. private _glowLayer;
  63326. /**
  63327. * Animations which can be used to tweak settings over a period of time
  63328. */
  63329. animations: Animation[];
  63330. private _imageProcessingConfigurationObserver;
  63331. private _sharpenEnabled;
  63332. private _bloomEnabled;
  63333. private _depthOfFieldEnabled;
  63334. private _depthOfFieldBlurLevel;
  63335. private _fxaaEnabled;
  63336. private _imageProcessingEnabled;
  63337. private _defaultPipelineTextureType;
  63338. private _bloomScale;
  63339. private _chromaticAberrationEnabled;
  63340. private _grainEnabled;
  63341. private _buildAllowed;
  63342. /**
  63343. * Gets active scene
  63344. */
  63345. get scene(): Scene;
  63346. /**
  63347. * Enable or disable the sharpen process from the pipeline
  63348. */
  63349. set sharpenEnabled(enabled: boolean);
  63350. get sharpenEnabled(): boolean;
  63351. private _resizeObserver;
  63352. private _hardwareScaleLevel;
  63353. private _bloomKernel;
  63354. /**
  63355. * Specifies the size of the bloom blur kernel, relative to the final output size
  63356. */
  63357. get bloomKernel(): number;
  63358. set bloomKernel(value: number);
  63359. /**
  63360. * Specifies the weight of the bloom in the final rendering
  63361. */
  63362. private _bloomWeight;
  63363. /**
  63364. * Specifies the luma threshold for the area that will be blurred by the bloom
  63365. */
  63366. private _bloomThreshold;
  63367. private _hdr;
  63368. /**
  63369. * The strength of the bloom.
  63370. */
  63371. set bloomWeight(value: number);
  63372. get bloomWeight(): number;
  63373. /**
  63374. * The strength of the bloom.
  63375. */
  63376. set bloomThreshold(value: number);
  63377. get bloomThreshold(): number;
  63378. /**
  63379. * The scale of the bloom, lower value will provide better performance.
  63380. */
  63381. set bloomScale(value: number);
  63382. get bloomScale(): number;
  63383. /**
  63384. * Enable or disable the bloom from the pipeline
  63385. */
  63386. set bloomEnabled(enabled: boolean);
  63387. get bloomEnabled(): boolean;
  63388. private _rebuildBloom;
  63389. /**
  63390. * If the depth of field is enabled.
  63391. */
  63392. get depthOfFieldEnabled(): boolean;
  63393. set depthOfFieldEnabled(enabled: boolean);
  63394. /**
  63395. * Blur level of the depth of field effect. (Higher blur will effect performance)
  63396. */
  63397. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  63398. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  63399. /**
  63400. * If the anti aliasing is enabled.
  63401. */
  63402. set fxaaEnabled(enabled: boolean);
  63403. get fxaaEnabled(): boolean;
  63404. private _samples;
  63405. /**
  63406. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  63407. */
  63408. set samples(sampleCount: number);
  63409. get samples(): number;
  63410. /**
  63411. * If image processing is enabled.
  63412. */
  63413. set imageProcessingEnabled(enabled: boolean);
  63414. get imageProcessingEnabled(): boolean;
  63415. /**
  63416. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  63417. */
  63418. set glowLayerEnabled(enabled: boolean);
  63419. get glowLayerEnabled(): boolean;
  63420. /**
  63421. * Gets the glow layer (or null if not defined)
  63422. */
  63423. get glowLayer(): Nullable<GlowLayer>;
  63424. /**
  63425. * Enable or disable the chromaticAberration process from the pipeline
  63426. */
  63427. set chromaticAberrationEnabled(enabled: boolean);
  63428. get chromaticAberrationEnabled(): boolean;
  63429. /**
  63430. * Enable or disable the grain process from the pipeline
  63431. */
  63432. set grainEnabled(enabled: boolean);
  63433. get grainEnabled(): boolean;
  63434. /**
  63435. * @constructor
  63436. * @param name - The rendering pipeline name (default: "")
  63437. * @param hdr - If high dynamic range textures should be used (default: true)
  63438. * @param scene - The scene linked to this pipeline (default: the last created scene)
  63439. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  63440. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  63441. */
  63442. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  63443. /**
  63444. * Get the class name
  63445. * @returns "DefaultRenderingPipeline"
  63446. */
  63447. getClassName(): string;
  63448. /**
  63449. * Force the compilation of the entire pipeline.
  63450. */
  63451. prepare(): void;
  63452. private _hasCleared;
  63453. private _prevPostProcess;
  63454. private _prevPrevPostProcess;
  63455. private _setAutoClearAndTextureSharing;
  63456. private _depthOfFieldSceneObserver;
  63457. private _buildPipeline;
  63458. private _disposePostProcesses;
  63459. /**
  63460. * Adds a camera to the pipeline
  63461. * @param camera the camera to be added
  63462. */
  63463. addCamera(camera: Camera): void;
  63464. /**
  63465. * Removes a camera from the pipeline
  63466. * @param camera the camera to remove
  63467. */
  63468. removeCamera(camera: Camera): void;
  63469. /**
  63470. * Dispose of the pipeline and stop all post processes
  63471. */
  63472. dispose(): void;
  63473. /**
  63474. * Serialize the rendering pipeline (Used when exporting)
  63475. * @returns the serialized object
  63476. */
  63477. serialize(): any;
  63478. /**
  63479. * Parse the serialized pipeline
  63480. * @param source Source pipeline.
  63481. * @param scene The scene to load the pipeline to.
  63482. * @param rootUrl The URL of the serialized pipeline.
  63483. * @returns An instantiated pipeline from the serialized object.
  63484. */
  63485. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  63486. }
  63487. }
  63488. declare module BABYLON {
  63489. /** @hidden */
  63490. export var lensHighlightsPixelShader: {
  63491. name: string;
  63492. shader: string;
  63493. };
  63494. }
  63495. declare module BABYLON {
  63496. /** @hidden */
  63497. export var depthOfFieldPixelShader: {
  63498. name: string;
  63499. shader: string;
  63500. };
  63501. }
  63502. declare module BABYLON {
  63503. /**
  63504. * BABYLON.JS Chromatic Aberration GLSL Shader
  63505. * Author: Olivier Guyot
  63506. * Separates very slightly R, G and B colors on the edges of the screen
  63507. * Inspired by Francois Tarlier & Martins Upitis
  63508. */
  63509. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  63510. /**
  63511. * @ignore
  63512. * The chromatic aberration PostProcess id in the pipeline
  63513. */
  63514. LensChromaticAberrationEffect: string;
  63515. /**
  63516. * @ignore
  63517. * The highlights enhancing PostProcess id in the pipeline
  63518. */
  63519. HighlightsEnhancingEffect: string;
  63520. /**
  63521. * @ignore
  63522. * The depth-of-field PostProcess id in the pipeline
  63523. */
  63524. LensDepthOfFieldEffect: string;
  63525. private _scene;
  63526. private _depthTexture;
  63527. private _grainTexture;
  63528. private _chromaticAberrationPostProcess;
  63529. private _highlightsPostProcess;
  63530. private _depthOfFieldPostProcess;
  63531. private _edgeBlur;
  63532. private _grainAmount;
  63533. private _chromaticAberration;
  63534. private _distortion;
  63535. private _highlightsGain;
  63536. private _highlightsThreshold;
  63537. private _dofDistance;
  63538. private _dofAperture;
  63539. private _dofDarken;
  63540. private _dofPentagon;
  63541. private _blurNoise;
  63542. /**
  63543. * @constructor
  63544. *
  63545. * Effect parameters are as follow:
  63546. * {
  63547. * chromatic_aberration: number; // from 0 to x (1 for realism)
  63548. * edge_blur: number; // from 0 to x (1 for realism)
  63549. * distortion: number; // from 0 to x (1 for realism)
  63550. * grain_amount: number; // from 0 to 1
  63551. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  63552. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  63553. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  63554. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  63555. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  63556. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  63557. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  63558. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  63559. * }
  63560. * Note: if an effect parameter is unset, effect is disabled
  63561. *
  63562. * @param name The rendering pipeline name
  63563. * @param parameters - An object containing all parameters (see above)
  63564. * @param scene The scene linked to this pipeline
  63565. * @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)
  63566. * @param cameras The array of cameras that the rendering pipeline will be attached to
  63567. */
  63568. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  63569. /**
  63570. * Get the class name
  63571. * @returns "LensRenderingPipeline"
  63572. */
  63573. getClassName(): string;
  63574. /**
  63575. * Gets associated scene
  63576. */
  63577. get scene(): Scene;
  63578. /**
  63579. * Gets or sets the edge blur
  63580. */
  63581. get edgeBlur(): number;
  63582. set edgeBlur(value: number);
  63583. /**
  63584. * Gets or sets the grain amount
  63585. */
  63586. get grainAmount(): number;
  63587. set grainAmount(value: number);
  63588. /**
  63589. * Gets or sets the chromatic aberration amount
  63590. */
  63591. get chromaticAberration(): number;
  63592. set chromaticAberration(value: number);
  63593. /**
  63594. * Gets or sets the depth of field aperture
  63595. */
  63596. get dofAperture(): number;
  63597. set dofAperture(value: number);
  63598. /**
  63599. * Gets or sets the edge distortion
  63600. */
  63601. get edgeDistortion(): number;
  63602. set edgeDistortion(value: number);
  63603. /**
  63604. * Gets or sets the depth of field distortion
  63605. */
  63606. get dofDistortion(): number;
  63607. set dofDistortion(value: number);
  63608. /**
  63609. * Gets or sets the darken out of focus amount
  63610. */
  63611. get darkenOutOfFocus(): number;
  63612. set darkenOutOfFocus(value: number);
  63613. /**
  63614. * Gets or sets a boolean indicating if blur noise is enabled
  63615. */
  63616. get blurNoise(): boolean;
  63617. set blurNoise(value: boolean);
  63618. /**
  63619. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  63620. */
  63621. get pentagonBokeh(): boolean;
  63622. set pentagonBokeh(value: boolean);
  63623. /**
  63624. * Gets or sets the highlight grain amount
  63625. */
  63626. get highlightsGain(): number;
  63627. set highlightsGain(value: number);
  63628. /**
  63629. * Gets or sets the highlight threshold
  63630. */
  63631. get highlightsThreshold(): number;
  63632. set highlightsThreshold(value: number);
  63633. /**
  63634. * Sets the amount of blur at the edges
  63635. * @param amount blur amount
  63636. */
  63637. setEdgeBlur(amount: number): void;
  63638. /**
  63639. * Sets edge blur to 0
  63640. */
  63641. disableEdgeBlur(): void;
  63642. /**
  63643. * Sets the amout of grain
  63644. * @param amount Amount of grain
  63645. */
  63646. setGrainAmount(amount: number): void;
  63647. /**
  63648. * Set grain amount to 0
  63649. */
  63650. disableGrain(): void;
  63651. /**
  63652. * Sets the chromatic aberration amount
  63653. * @param amount amount of chromatic aberration
  63654. */
  63655. setChromaticAberration(amount: number): void;
  63656. /**
  63657. * Sets chromatic aberration amount to 0
  63658. */
  63659. disableChromaticAberration(): void;
  63660. /**
  63661. * Sets the EdgeDistortion amount
  63662. * @param amount amount of EdgeDistortion
  63663. */
  63664. setEdgeDistortion(amount: number): void;
  63665. /**
  63666. * Sets edge distortion to 0
  63667. */
  63668. disableEdgeDistortion(): void;
  63669. /**
  63670. * Sets the FocusDistance amount
  63671. * @param amount amount of FocusDistance
  63672. */
  63673. setFocusDistance(amount: number): void;
  63674. /**
  63675. * Disables depth of field
  63676. */
  63677. disableDepthOfField(): void;
  63678. /**
  63679. * Sets the Aperture amount
  63680. * @param amount amount of Aperture
  63681. */
  63682. setAperture(amount: number): void;
  63683. /**
  63684. * Sets the DarkenOutOfFocus amount
  63685. * @param amount amount of DarkenOutOfFocus
  63686. */
  63687. setDarkenOutOfFocus(amount: number): void;
  63688. private _pentagonBokehIsEnabled;
  63689. /**
  63690. * Creates a pentagon bokeh effect
  63691. */
  63692. enablePentagonBokeh(): void;
  63693. /**
  63694. * Disables the pentagon bokeh effect
  63695. */
  63696. disablePentagonBokeh(): void;
  63697. /**
  63698. * Enables noise blur
  63699. */
  63700. enableNoiseBlur(): void;
  63701. /**
  63702. * Disables noise blur
  63703. */
  63704. disableNoiseBlur(): void;
  63705. /**
  63706. * Sets the HighlightsGain amount
  63707. * @param amount amount of HighlightsGain
  63708. */
  63709. setHighlightsGain(amount: number): void;
  63710. /**
  63711. * Sets the HighlightsThreshold amount
  63712. * @param amount amount of HighlightsThreshold
  63713. */
  63714. setHighlightsThreshold(amount: number): void;
  63715. /**
  63716. * Disables highlights
  63717. */
  63718. disableHighlights(): void;
  63719. /**
  63720. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  63721. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  63722. */
  63723. dispose(disableDepthRender?: boolean): void;
  63724. private _createChromaticAberrationPostProcess;
  63725. private _createHighlightsPostProcess;
  63726. private _createDepthOfFieldPostProcess;
  63727. private _createGrainTexture;
  63728. }
  63729. }
  63730. declare module BABYLON {
  63731. /** @hidden */
  63732. export var ssao2PixelShader: {
  63733. name: string;
  63734. shader: string;
  63735. };
  63736. }
  63737. declare module BABYLON {
  63738. /** @hidden */
  63739. export var ssaoCombinePixelShader: {
  63740. name: string;
  63741. shader: string;
  63742. };
  63743. }
  63744. declare module BABYLON {
  63745. /**
  63746. * Render pipeline to produce ssao effect
  63747. */
  63748. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  63749. /**
  63750. * @ignore
  63751. * The PassPostProcess id in the pipeline that contains the original scene color
  63752. */
  63753. SSAOOriginalSceneColorEffect: string;
  63754. /**
  63755. * @ignore
  63756. * The SSAO PostProcess id in the pipeline
  63757. */
  63758. SSAORenderEffect: string;
  63759. /**
  63760. * @ignore
  63761. * The horizontal blur PostProcess id in the pipeline
  63762. */
  63763. SSAOBlurHRenderEffect: string;
  63764. /**
  63765. * @ignore
  63766. * The vertical blur PostProcess id in the pipeline
  63767. */
  63768. SSAOBlurVRenderEffect: string;
  63769. /**
  63770. * @ignore
  63771. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  63772. */
  63773. SSAOCombineRenderEffect: string;
  63774. /**
  63775. * The output strength of the SSAO post-process. Default value is 1.0.
  63776. */
  63777. totalStrength: number;
  63778. /**
  63779. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  63780. */
  63781. maxZ: number;
  63782. /**
  63783. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  63784. */
  63785. minZAspect: number;
  63786. private _samples;
  63787. /**
  63788. * Number of samples used for the SSAO calculations. Default value is 8
  63789. */
  63790. set samples(n: number);
  63791. get samples(): number;
  63792. private _textureSamples;
  63793. /**
  63794. * Number of samples to use for antialiasing
  63795. */
  63796. set textureSamples(n: number);
  63797. get textureSamples(): number;
  63798. /**
  63799. * Ratio object used for SSAO ratio and blur ratio
  63800. */
  63801. private _ratio;
  63802. /**
  63803. * Dynamically generated sphere sampler.
  63804. */
  63805. private _sampleSphere;
  63806. /**
  63807. * Blur filter offsets
  63808. */
  63809. private _samplerOffsets;
  63810. private _expensiveBlur;
  63811. /**
  63812. * If bilateral blur should be used
  63813. */
  63814. set expensiveBlur(b: boolean);
  63815. get expensiveBlur(): boolean;
  63816. /**
  63817. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  63818. */
  63819. radius: number;
  63820. /**
  63821. * The base color of the SSAO post-process
  63822. * The final result is "base + ssao" between [0, 1]
  63823. */
  63824. base: number;
  63825. /**
  63826. * Support test.
  63827. */
  63828. static get IsSupported(): boolean;
  63829. private _scene;
  63830. private _depthTexture;
  63831. private _normalTexture;
  63832. private _randomTexture;
  63833. private _originalColorPostProcess;
  63834. private _ssaoPostProcess;
  63835. private _blurHPostProcess;
  63836. private _blurVPostProcess;
  63837. private _ssaoCombinePostProcess;
  63838. /**
  63839. * Gets active scene
  63840. */
  63841. get scene(): Scene;
  63842. /**
  63843. * @constructor
  63844. * @param name The rendering pipeline name
  63845. * @param scene The scene linked to this pipeline
  63846. * @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 }
  63847. * @param cameras The array of cameras that the rendering pipeline will be attached to
  63848. */
  63849. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  63850. /**
  63851. * Get the class name
  63852. * @returns "SSAO2RenderingPipeline"
  63853. */
  63854. getClassName(): string;
  63855. /**
  63856. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  63857. */
  63858. dispose(disableGeometryBufferRenderer?: boolean): void;
  63859. private _createBlurPostProcess;
  63860. /** @hidden */
  63861. _rebuild(): void;
  63862. private _bits;
  63863. private _radicalInverse_VdC;
  63864. private _hammersley;
  63865. private _hemisphereSample_uniform;
  63866. private _generateHemisphere;
  63867. private _createSSAOPostProcess;
  63868. private _createSSAOCombinePostProcess;
  63869. private _createRandomTexture;
  63870. /**
  63871. * Serialize the rendering pipeline (Used when exporting)
  63872. * @returns the serialized object
  63873. */
  63874. serialize(): any;
  63875. /**
  63876. * Parse the serialized pipeline
  63877. * @param source Source pipeline.
  63878. * @param scene The scene to load the pipeline to.
  63879. * @param rootUrl The URL of the serialized pipeline.
  63880. * @returns An instantiated pipeline from the serialized object.
  63881. */
  63882. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  63883. }
  63884. }
  63885. declare module BABYLON {
  63886. /** @hidden */
  63887. export var ssaoPixelShader: {
  63888. name: string;
  63889. shader: string;
  63890. };
  63891. }
  63892. declare module BABYLON {
  63893. /**
  63894. * Render pipeline to produce ssao effect
  63895. */
  63896. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  63897. /**
  63898. * @ignore
  63899. * The PassPostProcess id in the pipeline that contains the original scene color
  63900. */
  63901. SSAOOriginalSceneColorEffect: string;
  63902. /**
  63903. * @ignore
  63904. * The SSAO PostProcess id in the pipeline
  63905. */
  63906. SSAORenderEffect: string;
  63907. /**
  63908. * @ignore
  63909. * The horizontal blur PostProcess id in the pipeline
  63910. */
  63911. SSAOBlurHRenderEffect: string;
  63912. /**
  63913. * @ignore
  63914. * The vertical blur PostProcess id in the pipeline
  63915. */
  63916. SSAOBlurVRenderEffect: string;
  63917. /**
  63918. * @ignore
  63919. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  63920. */
  63921. SSAOCombineRenderEffect: string;
  63922. /**
  63923. * The output strength of the SSAO post-process. Default value is 1.0.
  63924. */
  63925. totalStrength: number;
  63926. /**
  63927. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  63928. */
  63929. radius: number;
  63930. /**
  63931. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  63932. * Must not be equal to fallOff and superior to fallOff.
  63933. * Default value is 0.0075
  63934. */
  63935. area: number;
  63936. /**
  63937. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  63938. * Must not be equal to area and inferior to area.
  63939. * Default value is 0.000001
  63940. */
  63941. fallOff: number;
  63942. /**
  63943. * The base color of the SSAO post-process
  63944. * The final result is "base + ssao" between [0, 1]
  63945. */
  63946. base: number;
  63947. private _scene;
  63948. private _depthTexture;
  63949. private _randomTexture;
  63950. private _originalColorPostProcess;
  63951. private _ssaoPostProcess;
  63952. private _blurHPostProcess;
  63953. private _blurVPostProcess;
  63954. private _ssaoCombinePostProcess;
  63955. private _firstUpdate;
  63956. /**
  63957. * Gets active scene
  63958. */
  63959. get scene(): Scene;
  63960. /**
  63961. * @constructor
  63962. * @param name - The rendering pipeline name
  63963. * @param scene - The scene linked to this pipeline
  63964. * @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 }
  63965. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  63966. */
  63967. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  63968. /**
  63969. * Get the class name
  63970. * @returns "SSAORenderingPipeline"
  63971. */
  63972. getClassName(): string;
  63973. /**
  63974. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  63975. */
  63976. dispose(disableDepthRender?: boolean): void;
  63977. private _createBlurPostProcess;
  63978. /** @hidden */
  63979. _rebuild(): void;
  63980. private _createSSAOPostProcess;
  63981. private _createSSAOCombinePostProcess;
  63982. private _createRandomTexture;
  63983. }
  63984. }
  63985. declare module BABYLON {
  63986. /** @hidden */
  63987. export var standardPixelShader: {
  63988. name: string;
  63989. shader: string;
  63990. };
  63991. }
  63992. declare module BABYLON {
  63993. /**
  63994. * Standard rendering pipeline
  63995. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  63996. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  63997. */
  63998. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  63999. /**
  64000. * Public members
  64001. */
  64002. /**
  64003. * Post-process which contains the original scene color before the pipeline applies all the effects
  64004. */
  64005. originalPostProcess: Nullable<PostProcess>;
  64006. /**
  64007. * Post-process used to down scale an image x4
  64008. */
  64009. downSampleX4PostProcess: Nullable<PostProcess>;
  64010. /**
  64011. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  64012. */
  64013. brightPassPostProcess: Nullable<PostProcess>;
  64014. /**
  64015. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  64016. */
  64017. blurHPostProcesses: PostProcess[];
  64018. /**
  64019. * Post-process array storing all the vertical blur post-processes used by the pipeline
  64020. */
  64021. blurVPostProcesses: PostProcess[];
  64022. /**
  64023. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  64024. */
  64025. textureAdderPostProcess: Nullable<PostProcess>;
  64026. /**
  64027. * Post-process used to create volumetric lighting effect
  64028. */
  64029. volumetricLightPostProcess: Nullable<PostProcess>;
  64030. /**
  64031. * Post-process used to smooth the previous volumetric light post-process on the X axis
  64032. */
  64033. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  64034. /**
  64035. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  64036. */
  64037. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  64038. /**
  64039. * Post-process used to merge the volumetric light effect and the real scene color
  64040. */
  64041. volumetricLightMergePostProces: Nullable<PostProcess>;
  64042. /**
  64043. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  64044. */
  64045. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  64046. /**
  64047. * Base post-process used to calculate the average luminance of the final image for HDR
  64048. */
  64049. luminancePostProcess: Nullable<PostProcess>;
  64050. /**
  64051. * Post-processes used to create down sample post-processes in order to get
  64052. * the average luminance of the final image for HDR
  64053. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  64054. */
  64055. luminanceDownSamplePostProcesses: PostProcess[];
  64056. /**
  64057. * Post-process used to create a HDR effect (light adaptation)
  64058. */
  64059. hdrPostProcess: Nullable<PostProcess>;
  64060. /**
  64061. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  64062. */
  64063. textureAdderFinalPostProcess: Nullable<PostProcess>;
  64064. /**
  64065. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  64066. */
  64067. lensFlareFinalPostProcess: Nullable<PostProcess>;
  64068. /**
  64069. * Post-process used to merge the final HDR post-process and the real scene color
  64070. */
  64071. hdrFinalPostProcess: Nullable<PostProcess>;
  64072. /**
  64073. * Post-process used to create a lens flare effect
  64074. */
  64075. lensFlarePostProcess: Nullable<PostProcess>;
  64076. /**
  64077. * Post-process that merges the result of the lens flare post-process and the real scene color
  64078. */
  64079. lensFlareComposePostProcess: Nullable<PostProcess>;
  64080. /**
  64081. * Post-process used to create a motion blur effect
  64082. */
  64083. motionBlurPostProcess: Nullable<PostProcess>;
  64084. /**
  64085. * Post-process used to create a depth of field effect
  64086. */
  64087. depthOfFieldPostProcess: Nullable<PostProcess>;
  64088. /**
  64089. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  64090. */
  64091. fxaaPostProcess: Nullable<FxaaPostProcess>;
  64092. /**
  64093. * Represents the brightness threshold in order to configure the illuminated surfaces
  64094. */
  64095. brightThreshold: number;
  64096. /**
  64097. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  64098. */
  64099. blurWidth: number;
  64100. /**
  64101. * Sets if the blur for highlighted surfaces must be only horizontal
  64102. */
  64103. horizontalBlur: boolean;
  64104. /**
  64105. * Gets the overall exposure used by the pipeline
  64106. */
  64107. get exposure(): number;
  64108. /**
  64109. * Sets the overall exposure used by the pipeline
  64110. */
  64111. set exposure(value: number);
  64112. /**
  64113. * Texture used typically to simulate "dirty" on camera lens
  64114. */
  64115. lensTexture: Nullable<Texture>;
  64116. /**
  64117. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  64118. */
  64119. volumetricLightCoefficient: number;
  64120. /**
  64121. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  64122. */
  64123. volumetricLightPower: number;
  64124. /**
  64125. * Used the set the blur intensity to smooth the volumetric lights
  64126. */
  64127. volumetricLightBlurScale: number;
  64128. /**
  64129. * Light (spot or directional) used to generate the volumetric lights rays
  64130. * The source light must have a shadow generate so the pipeline can get its
  64131. * depth map
  64132. */
  64133. sourceLight: Nullable<SpotLight | DirectionalLight>;
  64134. /**
  64135. * For eye adaptation, represents the minimum luminance the eye can see
  64136. */
  64137. hdrMinimumLuminance: number;
  64138. /**
  64139. * For eye adaptation, represents the decrease luminance speed
  64140. */
  64141. hdrDecreaseRate: number;
  64142. /**
  64143. * For eye adaptation, represents the increase luminance speed
  64144. */
  64145. hdrIncreaseRate: number;
  64146. /**
  64147. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  64148. */
  64149. get hdrAutoExposure(): boolean;
  64150. /**
  64151. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  64152. */
  64153. set hdrAutoExposure(value: boolean);
  64154. /**
  64155. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  64156. */
  64157. lensColorTexture: Nullable<Texture>;
  64158. /**
  64159. * The overall strengh for the lens flare effect
  64160. */
  64161. lensFlareStrength: number;
  64162. /**
  64163. * Dispersion coefficient for lens flare ghosts
  64164. */
  64165. lensFlareGhostDispersal: number;
  64166. /**
  64167. * Main lens flare halo width
  64168. */
  64169. lensFlareHaloWidth: number;
  64170. /**
  64171. * Based on the lens distortion effect, defines how much the lens flare result
  64172. * is distorted
  64173. */
  64174. lensFlareDistortionStrength: number;
  64175. /**
  64176. * Configures the blur intensity used for for lens flare (halo)
  64177. */
  64178. lensFlareBlurWidth: number;
  64179. /**
  64180. * Lens star texture must be used to simulate rays on the flares and is available
  64181. * in the documentation
  64182. */
  64183. lensStarTexture: Nullable<Texture>;
  64184. /**
  64185. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  64186. * flare effect by taking account of the dirt texture
  64187. */
  64188. lensFlareDirtTexture: Nullable<Texture>;
  64189. /**
  64190. * Represents the focal length for the depth of field effect
  64191. */
  64192. depthOfFieldDistance: number;
  64193. /**
  64194. * Represents the blur intensity for the blurred part of the depth of field effect
  64195. */
  64196. depthOfFieldBlurWidth: number;
  64197. /**
  64198. * Gets how much the image is blurred by the movement while using the motion blur post-process
  64199. */
  64200. get motionStrength(): number;
  64201. /**
  64202. * Sets how much the image is blurred by the movement while using the motion blur post-process
  64203. */
  64204. set motionStrength(strength: number);
  64205. /**
  64206. * Gets wether or not the motion blur post-process is object based or screen based.
  64207. */
  64208. get objectBasedMotionBlur(): boolean;
  64209. /**
  64210. * Sets wether or not the motion blur post-process should be object based or screen based
  64211. */
  64212. set objectBasedMotionBlur(value: boolean);
  64213. /**
  64214. * List of animations for the pipeline (IAnimatable implementation)
  64215. */
  64216. animations: Animation[];
  64217. /**
  64218. * Private members
  64219. */
  64220. private _scene;
  64221. private _currentDepthOfFieldSource;
  64222. private _basePostProcess;
  64223. private _fixedExposure;
  64224. private _currentExposure;
  64225. private _hdrAutoExposure;
  64226. private _hdrCurrentLuminance;
  64227. private _motionStrength;
  64228. private _isObjectBasedMotionBlur;
  64229. private _floatTextureType;
  64230. private _camerasToBeAttached;
  64231. private _ratio;
  64232. private _bloomEnabled;
  64233. private _depthOfFieldEnabled;
  64234. private _vlsEnabled;
  64235. private _lensFlareEnabled;
  64236. private _hdrEnabled;
  64237. private _motionBlurEnabled;
  64238. private _fxaaEnabled;
  64239. private _motionBlurSamples;
  64240. private _volumetricLightStepsCount;
  64241. private _samples;
  64242. /**
  64243. * @ignore
  64244. * Specifies if the bloom pipeline is enabled
  64245. */
  64246. get BloomEnabled(): boolean;
  64247. set BloomEnabled(enabled: boolean);
  64248. /**
  64249. * @ignore
  64250. * Specifies if the depth of field pipeline is enabed
  64251. */
  64252. get DepthOfFieldEnabled(): boolean;
  64253. set DepthOfFieldEnabled(enabled: boolean);
  64254. /**
  64255. * @ignore
  64256. * Specifies if the lens flare pipeline is enabed
  64257. */
  64258. get LensFlareEnabled(): boolean;
  64259. set LensFlareEnabled(enabled: boolean);
  64260. /**
  64261. * @ignore
  64262. * Specifies if the HDR pipeline is enabled
  64263. */
  64264. get HDREnabled(): boolean;
  64265. set HDREnabled(enabled: boolean);
  64266. /**
  64267. * @ignore
  64268. * Specifies if the volumetric lights scattering effect is enabled
  64269. */
  64270. get VLSEnabled(): boolean;
  64271. set VLSEnabled(enabled: boolean);
  64272. /**
  64273. * @ignore
  64274. * Specifies if the motion blur effect is enabled
  64275. */
  64276. get MotionBlurEnabled(): boolean;
  64277. set MotionBlurEnabled(enabled: boolean);
  64278. /**
  64279. * Specifies if anti-aliasing is enabled
  64280. */
  64281. get fxaaEnabled(): boolean;
  64282. set fxaaEnabled(enabled: boolean);
  64283. /**
  64284. * Specifies the number of steps used to calculate the volumetric lights
  64285. * Typically in interval [50, 200]
  64286. */
  64287. get volumetricLightStepsCount(): number;
  64288. set volumetricLightStepsCount(count: number);
  64289. /**
  64290. * Specifies the number of samples used for the motion blur effect
  64291. * Typically in interval [16, 64]
  64292. */
  64293. get motionBlurSamples(): number;
  64294. set motionBlurSamples(samples: number);
  64295. /**
  64296. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  64297. */
  64298. get samples(): number;
  64299. set samples(sampleCount: number);
  64300. /**
  64301. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  64302. * @constructor
  64303. * @param name The rendering pipeline name
  64304. * @param scene The scene linked to this pipeline
  64305. * @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)
  64306. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  64307. * @param cameras The array of cameras that the rendering pipeline will be attached to
  64308. */
  64309. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  64310. private _buildPipeline;
  64311. private _createDownSampleX4PostProcess;
  64312. private _createBrightPassPostProcess;
  64313. private _createBlurPostProcesses;
  64314. private _createTextureAdderPostProcess;
  64315. private _createVolumetricLightPostProcess;
  64316. private _createLuminancePostProcesses;
  64317. private _createHdrPostProcess;
  64318. private _createLensFlarePostProcess;
  64319. private _createDepthOfFieldPostProcess;
  64320. private _createMotionBlurPostProcess;
  64321. private _getDepthTexture;
  64322. private _disposePostProcesses;
  64323. /**
  64324. * Dispose of the pipeline and stop all post processes
  64325. */
  64326. dispose(): void;
  64327. /**
  64328. * Serialize the rendering pipeline (Used when exporting)
  64329. * @returns the serialized object
  64330. */
  64331. serialize(): any;
  64332. /**
  64333. * Parse the serialized pipeline
  64334. * @param source Source pipeline.
  64335. * @param scene The scene to load the pipeline to.
  64336. * @param rootUrl The URL of the serialized pipeline.
  64337. * @returns An instantiated pipeline from the serialized object.
  64338. */
  64339. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  64340. /**
  64341. * Luminance steps
  64342. */
  64343. static LuminanceSteps: number;
  64344. }
  64345. }
  64346. declare module BABYLON {
  64347. /** @hidden */
  64348. export var tonemapPixelShader: {
  64349. name: string;
  64350. shader: string;
  64351. };
  64352. }
  64353. declare module BABYLON {
  64354. /** Defines operator used for tonemapping */
  64355. export enum TonemappingOperator {
  64356. /** Hable */
  64357. Hable = 0,
  64358. /** Reinhard */
  64359. Reinhard = 1,
  64360. /** HejiDawson */
  64361. HejiDawson = 2,
  64362. /** Photographic */
  64363. Photographic = 3
  64364. }
  64365. /**
  64366. * Defines a post process to apply tone mapping
  64367. */
  64368. export class TonemapPostProcess extends PostProcess {
  64369. private _operator;
  64370. /** Defines the required exposure adjustement */
  64371. exposureAdjustment: number;
  64372. /**
  64373. * Creates a new TonemapPostProcess
  64374. * @param name defines the name of the postprocess
  64375. * @param _operator defines the operator to use
  64376. * @param exposureAdjustment defines the required exposure adjustement
  64377. * @param camera defines the camera to use (can be null)
  64378. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  64379. * @param engine defines the hosting engine (can be ignore if camera is set)
  64380. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  64381. */
  64382. constructor(name: string, _operator: TonemappingOperator,
  64383. /** Defines the required exposure adjustement */
  64384. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  64385. }
  64386. }
  64387. declare module BABYLON {
  64388. /** @hidden */
  64389. export var depthVertexShader: {
  64390. name: string;
  64391. shader: string;
  64392. };
  64393. }
  64394. declare module BABYLON {
  64395. /** @hidden */
  64396. export var volumetricLightScatteringPixelShader: {
  64397. name: string;
  64398. shader: string;
  64399. };
  64400. }
  64401. declare module BABYLON {
  64402. /** @hidden */
  64403. export var volumetricLightScatteringPassVertexShader: {
  64404. name: string;
  64405. shader: string;
  64406. };
  64407. }
  64408. declare module BABYLON {
  64409. /** @hidden */
  64410. export var volumetricLightScatteringPassPixelShader: {
  64411. name: string;
  64412. shader: string;
  64413. };
  64414. }
  64415. declare module BABYLON {
  64416. /**
  64417. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  64418. */
  64419. export class VolumetricLightScatteringPostProcess extends PostProcess {
  64420. private _volumetricLightScatteringPass;
  64421. private _volumetricLightScatteringRTT;
  64422. private _viewPort;
  64423. private _screenCoordinates;
  64424. private _cachedDefines;
  64425. /**
  64426. * If not undefined, the mesh position is computed from the attached node position
  64427. */
  64428. attachedNode: {
  64429. position: Vector3;
  64430. };
  64431. /**
  64432. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  64433. */
  64434. customMeshPosition: Vector3;
  64435. /**
  64436. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  64437. */
  64438. useCustomMeshPosition: boolean;
  64439. /**
  64440. * If the post-process should inverse the light scattering direction
  64441. */
  64442. invert: boolean;
  64443. /**
  64444. * The internal mesh used by the post-process
  64445. */
  64446. mesh: Mesh;
  64447. /**
  64448. * @hidden
  64449. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  64450. */
  64451. get useDiffuseColor(): boolean;
  64452. set useDiffuseColor(useDiffuseColor: boolean);
  64453. /**
  64454. * Array containing the excluded meshes not rendered in the internal pass
  64455. */
  64456. excludedMeshes: AbstractMesh[];
  64457. /**
  64458. * Controls the overall intensity of the post-process
  64459. */
  64460. exposure: number;
  64461. /**
  64462. * Dissipates each sample's contribution in range [0, 1]
  64463. */
  64464. decay: number;
  64465. /**
  64466. * Controls the overall intensity of each sample
  64467. */
  64468. weight: number;
  64469. /**
  64470. * Controls the density of each sample
  64471. */
  64472. density: number;
  64473. /**
  64474. * @constructor
  64475. * @param name The post-process name
  64476. * @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)
  64477. * @param camera The camera that the post-process will be attached to
  64478. * @param mesh The mesh used to create the light scattering
  64479. * @param samples The post-process quality, default 100
  64480. * @param samplingModeThe post-process filtering mode
  64481. * @param engine The babylon engine
  64482. * @param reusable If the post-process is reusable
  64483. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  64484. */
  64485. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  64486. /**
  64487. * Returns the string "VolumetricLightScatteringPostProcess"
  64488. * @returns "VolumetricLightScatteringPostProcess"
  64489. */
  64490. getClassName(): string;
  64491. private _isReady;
  64492. /**
  64493. * Sets the new light position for light scattering effect
  64494. * @param position The new custom light position
  64495. */
  64496. setCustomMeshPosition(position: Vector3): void;
  64497. /**
  64498. * Returns the light position for light scattering effect
  64499. * @return Vector3 The custom light position
  64500. */
  64501. getCustomMeshPosition(): Vector3;
  64502. /**
  64503. * Disposes the internal assets and detaches the post-process from the camera
  64504. */
  64505. dispose(camera: Camera): void;
  64506. /**
  64507. * Returns the render target texture used by the post-process
  64508. * @return the render target texture used by the post-process
  64509. */
  64510. getPass(): RenderTargetTexture;
  64511. private _meshExcluded;
  64512. private _createPass;
  64513. private _updateMeshScreenCoordinates;
  64514. /**
  64515. * Creates a default mesh for the Volumeric Light Scattering post-process
  64516. * @param name The mesh name
  64517. * @param scene The scene where to create the mesh
  64518. * @return the default mesh
  64519. */
  64520. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  64521. }
  64522. }
  64523. declare module BABYLON {
  64524. interface Scene {
  64525. /** @hidden (Backing field) */
  64526. _boundingBoxRenderer: BoundingBoxRenderer;
  64527. /** @hidden (Backing field) */
  64528. _forceShowBoundingBoxes: boolean;
  64529. /**
  64530. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  64531. */
  64532. forceShowBoundingBoxes: boolean;
  64533. /**
  64534. * Gets the bounding box renderer associated with the scene
  64535. * @returns a BoundingBoxRenderer
  64536. */
  64537. getBoundingBoxRenderer(): BoundingBoxRenderer;
  64538. }
  64539. interface AbstractMesh {
  64540. /** @hidden (Backing field) */
  64541. _showBoundingBox: boolean;
  64542. /**
  64543. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  64544. */
  64545. showBoundingBox: boolean;
  64546. }
  64547. /**
  64548. * Component responsible of rendering the bounding box of the meshes in a scene.
  64549. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  64550. */
  64551. export class BoundingBoxRenderer implements ISceneComponent {
  64552. /**
  64553. * The component name helpfull to identify the component in the list of scene components.
  64554. */
  64555. readonly name: string;
  64556. /**
  64557. * The scene the component belongs to.
  64558. */
  64559. scene: Scene;
  64560. /**
  64561. * Color of the bounding box lines placed in front of an object
  64562. */
  64563. frontColor: Color3;
  64564. /**
  64565. * Color of the bounding box lines placed behind an object
  64566. */
  64567. backColor: Color3;
  64568. /**
  64569. * Defines if the renderer should show the back lines or not
  64570. */
  64571. showBackLines: boolean;
  64572. /**
  64573. * @hidden
  64574. */
  64575. renderList: SmartArray<BoundingBox>;
  64576. private _colorShader;
  64577. private _vertexBuffers;
  64578. private _indexBuffer;
  64579. private _fillIndexBuffer;
  64580. private _fillIndexData;
  64581. /**
  64582. * Instantiates a new bounding box renderer in a scene.
  64583. * @param scene the scene the renderer renders in
  64584. */
  64585. constructor(scene: Scene);
  64586. /**
  64587. * Registers the component in a given scene
  64588. */
  64589. register(): void;
  64590. private _evaluateSubMesh;
  64591. private _activeMesh;
  64592. private _prepareRessources;
  64593. private _createIndexBuffer;
  64594. /**
  64595. * Rebuilds the elements related to this component in case of
  64596. * context lost for instance.
  64597. */
  64598. rebuild(): void;
  64599. /**
  64600. * @hidden
  64601. */
  64602. reset(): void;
  64603. /**
  64604. * Render the bounding boxes of a specific rendering group
  64605. * @param renderingGroupId defines the rendering group to render
  64606. */
  64607. render(renderingGroupId: number): void;
  64608. /**
  64609. * In case of occlusion queries, we can render the occlusion bounding box through this method
  64610. * @param mesh Define the mesh to render the occlusion bounding box for
  64611. */
  64612. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  64613. /**
  64614. * Dispose and release the resources attached to this renderer.
  64615. */
  64616. dispose(): void;
  64617. }
  64618. }
  64619. declare module BABYLON {
  64620. /** @hidden */
  64621. export var depthPixelShader: {
  64622. name: string;
  64623. shader: string;
  64624. };
  64625. }
  64626. declare module BABYLON {
  64627. /**
  64628. * This represents a depth renderer in Babylon.
  64629. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  64630. */
  64631. export class DepthRenderer {
  64632. private _scene;
  64633. private _depthMap;
  64634. private _effect;
  64635. private readonly _storeNonLinearDepth;
  64636. private readonly _clearColor;
  64637. /** Get if the depth renderer is using packed depth or not */
  64638. readonly isPacked: boolean;
  64639. private _cachedDefines;
  64640. private _camera;
  64641. /**
  64642. * Specifiess that the depth renderer will only be used within
  64643. * the camera it is created for.
  64644. * This can help forcing its rendering during the camera processing.
  64645. */
  64646. useOnlyInActiveCamera: boolean;
  64647. /** @hidden */
  64648. static _SceneComponentInitialization: (scene: Scene) => void;
  64649. /**
  64650. * Instantiates a depth renderer
  64651. * @param scene The scene the renderer belongs to
  64652. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  64653. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  64654. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  64655. */
  64656. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  64657. /**
  64658. * Creates the depth rendering effect and checks if the effect is ready.
  64659. * @param subMesh The submesh to be used to render the depth map of
  64660. * @param useInstances If multiple world instances should be used
  64661. * @returns if the depth renderer is ready to render the depth map
  64662. */
  64663. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  64664. /**
  64665. * Gets the texture which the depth map will be written to.
  64666. * @returns The depth map texture
  64667. */
  64668. getDepthMap(): RenderTargetTexture;
  64669. /**
  64670. * Disposes of the depth renderer.
  64671. */
  64672. dispose(): void;
  64673. }
  64674. }
  64675. declare module BABYLON {
  64676. interface Scene {
  64677. /** @hidden (Backing field) */
  64678. _depthRenderer: {
  64679. [id: string]: DepthRenderer;
  64680. };
  64681. /**
  64682. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  64683. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  64684. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  64685. * @returns the created depth renderer
  64686. */
  64687. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  64688. /**
  64689. * Disables a depth renderer for a given camera
  64690. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  64691. */
  64692. disableDepthRenderer(camera?: Nullable<Camera>): void;
  64693. }
  64694. /**
  64695. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  64696. * in several rendering techniques.
  64697. */
  64698. export class DepthRendererSceneComponent implements ISceneComponent {
  64699. /**
  64700. * The component name helpfull to identify the component in the list of scene components.
  64701. */
  64702. readonly name: string;
  64703. /**
  64704. * The scene the component belongs to.
  64705. */
  64706. scene: Scene;
  64707. /**
  64708. * Creates a new instance of the component for the given scene
  64709. * @param scene Defines the scene to register the component in
  64710. */
  64711. constructor(scene: Scene);
  64712. /**
  64713. * Registers the component in a given scene
  64714. */
  64715. register(): void;
  64716. /**
  64717. * Rebuilds the elements related to this component in case of
  64718. * context lost for instance.
  64719. */
  64720. rebuild(): void;
  64721. /**
  64722. * Disposes the component and the associated ressources
  64723. */
  64724. dispose(): void;
  64725. private _gatherRenderTargets;
  64726. private _gatherActiveCameraRenderTargets;
  64727. }
  64728. }
  64729. declare module BABYLON {
  64730. /** @hidden */
  64731. export var outlinePixelShader: {
  64732. name: string;
  64733. shader: string;
  64734. };
  64735. }
  64736. declare module BABYLON {
  64737. /** @hidden */
  64738. export var outlineVertexShader: {
  64739. name: string;
  64740. shader: string;
  64741. };
  64742. }
  64743. declare module BABYLON {
  64744. interface Scene {
  64745. /** @hidden */
  64746. _outlineRenderer: OutlineRenderer;
  64747. /**
  64748. * Gets the outline renderer associated with the scene
  64749. * @returns a OutlineRenderer
  64750. */
  64751. getOutlineRenderer(): OutlineRenderer;
  64752. }
  64753. interface AbstractMesh {
  64754. /** @hidden (Backing field) */
  64755. _renderOutline: boolean;
  64756. /**
  64757. * Gets or sets a boolean indicating if the outline must be rendered as well
  64758. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  64759. */
  64760. renderOutline: boolean;
  64761. /** @hidden (Backing field) */
  64762. _renderOverlay: boolean;
  64763. /**
  64764. * Gets or sets a boolean indicating if the overlay must be rendered as well
  64765. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  64766. */
  64767. renderOverlay: boolean;
  64768. }
  64769. /**
  64770. * This class is responsible to draw bothe outline/overlay of meshes.
  64771. * It should not be used directly but through the available method on mesh.
  64772. */
  64773. export class OutlineRenderer implements ISceneComponent {
  64774. /**
  64775. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  64776. */
  64777. private static _StencilReference;
  64778. /**
  64779. * The name of the component. Each component must have a unique name.
  64780. */
  64781. name: string;
  64782. /**
  64783. * The scene the component belongs to.
  64784. */
  64785. scene: Scene;
  64786. /**
  64787. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  64788. */
  64789. zOffset: number;
  64790. private _engine;
  64791. private _effect;
  64792. private _cachedDefines;
  64793. private _savedDepthWrite;
  64794. /**
  64795. * Instantiates a new outline renderer. (There could be only one per scene).
  64796. * @param scene Defines the scene it belongs to
  64797. */
  64798. constructor(scene: Scene);
  64799. /**
  64800. * Register the component to one instance of a scene.
  64801. */
  64802. register(): void;
  64803. /**
  64804. * Rebuilds the elements related to this component in case of
  64805. * context lost for instance.
  64806. */
  64807. rebuild(): void;
  64808. /**
  64809. * Disposes the component and the associated ressources.
  64810. */
  64811. dispose(): void;
  64812. /**
  64813. * Renders the outline in the canvas.
  64814. * @param subMesh Defines the sumesh to render
  64815. * @param batch Defines the batch of meshes in case of instances
  64816. * @param useOverlay Defines if the rendering is for the overlay or the outline
  64817. */
  64818. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  64819. /**
  64820. * Returns whether or not the outline renderer is ready for a given submesh.
  64821. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  64822. * @param subMesh Defines the submesh to check readyness for
  64823. * @param useInstances Defines wheter wee are trying to render instances or not
  64824. * @returns true if ready otherwise false
  64825. */
  64826. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  64827. private _beforeRenderingMesh;
  64828. private _afterRenderingMesh;
  64829. }
  64830. }
  64831. declare module BABYLON {
  64832. /**
  64833. * Defines the basic options interface of a Sprite Frame Source Size.
  64834. */
  64835. export interface ISpriteJSONSpriteSourceSize {
  64836. /**
  64837. * number of the original width of the Frame
  64838. */
  64839. w: number;
  64840. /**
  64841. * number of the original height of the Frame
  64842. */
  64843. h: number;
  64844. }
  64845. /**
  64846. * Defines the basic options interface of a Sprite Frame Data.
  64847. */
  64848. export interface ISpriteJSONSpriteFrameData {
  64849. /**
  64850. * number of the x offset of the Frame
  64851. */
  64852. x: number;
  64853. /**
  64854. * number of the y offset of the Frame
  64855. */
  64856. y: number;
  64857. /**
  64858. * number of the width of the Frame
  64859. */
  64860. w: number;
  64861. /**
  64862. * number of the height of the Frame
  64863. */
  64864. h: number;
  64865. }
  64866. /**
  64867. * Defines the basic options interface of a JSON Sprite.
  64868. */
  64869. export interface ISpriteJSONSprite {
  64870. /**
  64871. * string name of the Frame
  64872. */
  64873. filename: string;
  64874. /**
  64875. * ISpriteJSONSpriteFrame basic object of the frame data
  64876. */
  64877. frame: ISpriteJSONSpriteFrameData;
  64878. /**
  64879. * boolean to flag is the frame was rotated.
  64880. */
  64881. rotated: boolean;
  64882. /**
  64883. * boolean to flag is the frame was trimmed.
  64884. */
  64885. trimmed: boolean;
  64886. /**
  64887. * ISpriteJSONSpriteFrame basic object of the source data
  64888. */
  64889. spriteSourceSize: ISpriteJSONSpriteFrameData;
  64890. /**
  64891. * ISpriteJSONSpriteFrame basic object of the source data
  64892. */
  64893. sourceSize: ISpriteJSONSpriteSourceSize;
  64894. }
  64895. /**
  64896. * Defines the basic options interface of a JSON atlas.
  64897. */
  64898. export interface ISpriteJSONAtlas {
  64899. /**
  64900. * Array of objects that contain the frame data.
  64901. */
  64902. frames: Array<ISpriteJSONSprite>;
  64903. /**
  64904. * object basic object containing the sprite meta data.
  64905. */
  64906. meta?: object;
  64907. }
  64908. }
  64909. declare module BABYLON {
  64910. /** @hidden */
  64911. export var spriteMapPixelShader: {
  64912. name: string;
  64913. shader: string;
  64914. };
  64915. }
  64916. declare module BABYLON {
  64917. /** @hidden */
  64918. export var spriteMapVertexShader: {
  64919. name: string;
  64920. shader: string;
  64921. };
  64922. }
  64923. declare module BABYLON {
  64924. /**
  64925. * Defines the basic options interface of a SpriteMap
  64926. */
  64927. export interface ISpriteMapOptions {
  64928. /**
  64929. * Vector2 of the number of cells in the grid.
  64930. */
  64931. stageSize?: Vector2;
  64932. /**
  64933. * Vector2 of the size of the output plane in World Units.
  64934. */
  64935. outputSize?: Vector2;
  64936. /**
  64937. * Vector3 of the position of the output plane in World Units.
  64938. */
  64939. outputPosition?: Vector3;
  64940. /**
  64941. * Vector3 of the rotation of the output plane.
  64942. */
  64943. outputRotation?: Vector3;
  64944. /**
  64945. * number of layers that the system will reserve in resources.
  64946. */
  64947. layerCount?: number;
  64948. /**
  64949. * number of max animation frames a single cell will reserve in resources.
  64950. */
  64951. maxAnimationFrames?: number;
  64952. /**
  64953. * number cell index of the base tile when the system compiles.
  64954. */
  64955. baseTile?: number;
  64956. /**
  64957. * boolean flip the sprite after its been repositioned by the framing data.
  64958. */
  64959. flipU?: boolean;
  64960. /**
  64961. * Vector3 scalar of the global RGB values of the SpriteMap.
  64962. */
  64963. colorMultiply?: Vector3;
  64964. }
  64965. /**
  64966. * Defines the IDisposable interface in order to be cleanable from resources.
  64967. */
  64968. export interface ISpriteMap extends IDisposable {
  64969. /**
  64970. * String name of the SpriteMap.
  64971. */
  64972. name: string;
  64973. /**
  64974. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  64975. */
  64976. atlasJSON: ISpriteJSONAtlas;
  64977. /**
  64978. * Texture of the SpriteMap.
  64979. */
  64980. spriteSheet: Texture;
  64981. /**
  64982. * The parameters to initialize the SpriteMap with.
  64983. */
  64984. options: ISpriteMapOptions;
  64985. }
  64986. /**
  64987. * Class used to manage a grid restricted sprite deployment on an Output plane.
  64988. */
  64989. export class SpriteMap implements ISpriteMap {
  64990. /** The Name of the spriteMap */
  64991. name: string;
  64992. /** The JSON file with the frame and meta data */
  64993. atlasJSON: ISpriteJSONAtlas;
  64994. /** The systems Sprite Sheet Texture */
  64995. spriteSheet: Texture;
  64996. /** Arguments passed with the Constructor */
  64997. options: ISpriteMapOptions;
  64998. /** Public Sprite Storage array, parsed from atlasJSON */
  64999. sprites: Array<ISpriteJSONSprite>;
  65000. /** Returns the Number of Sprites in the System */
  65001. get spriteCount(): number;
  65002. /** Returns the Position of Output Plane*/
  65003. get position(): Vector3;
  65004. /** Returns the Position of Output Plane*/
  65005. set position(v: Vector3);
  65006. /** Returns the Rotation of Output Plane*/
  65007. get rotation(): Vector3;
  65008. /** Returns the Rotation of Output Plane*/
  65009. set rotation(v: Vector3);
  65010. /** Sets the AnimationMap*/
  65011. get animationMap(): RawTexture;
  65012. /** Sets the AnimationMap*/
  65013. set animationMap(v: RawTexture);
  65014. /** Scene that the SpriteMap was created in */
  65015. private _scene;
  65016. /** Texture Buffer of Float32 that holds tile frame data*/
  65017. private _frameMap;
  65018. /** Texture Buffers of Float32 that holds tileMap data*/
  65019. private _tileMaps;
  65020. /** Texture Buffer of Float32 that holds Animation Data*/
  65021. private _animationMap;
  65022. /** Custom ShaderMaterial Central to the System*/
  65023. private _material;
  65024. /** Custom ShaderMaterial Central to the System*/
  65025. private _output;
  65026. /** Systems Time Ticker*/
  65027. private _time;
  65028. /**
  65029. * Creates a new SpriteMap
  65030. * @param name defines the SpriteMaps Name
  65031. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  65032. * @param spriteSheet is the Texture that the Sprites are on.
  65033. * @param options a basic deployment configuration
  65034. * @param scene The Scene that the map is deployed on
  65035. */
  65036. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  65037. /**
  65038. * Returns tileID location
  65039. * @returns Vector2 the cell position ID
  65040. */
  65041. getTileID(): Vector2;
  65042. /**
  65043. * Gets the UV location of the mouse over the SpriteMap.
  65044. * @returns Vector2 the UV position of the mouse interaction
  65045. */
  65046. getMousePosition(): Vector2;
  65047. /**
  65048. * Creates the "frame" texture Buffer
  65049. * -------------------------------------
  65050. * Structure of frames
  65051. * "filename": "Falling-Water-2.png",
  65052. * "frame": {"x":69,"y":103,"w":24,"h":32},
  65053. * "rotated": true,
  65054. * "trimmed": true,
  65055. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  65056. * "sourceSize": {"w":32,"h":32}
  65057. * @returns RawTexture of the frameMap
  65058. */
  65059. private _createFrameBuffer;
  65060. /**
  65061. * Creates the tileMap texture Buffer
  65062. * @param buffer normally and array of numbers, or a false to generate from scratch
  65063. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  65064. * @returns RawTexture of the tileMap
  65065. */
  65066. private _createTileBuffer;
  65067. /**
  65068. * Modifies the data of the tileMaps
  65069. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  65070. * @param pos is the iVector2 Coordinates of the Tile
  65071. * @param tile The SpriteIndex of the new Tile
  65072. */
  65073. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  65074. /**
  65075. * Creates the animationMap texture Buffer
  65076. * @param buffer normally and array of numbers, or a false to generate from scratch
  65077. * @returns RawTexture of the animationMap
  65078. */
  65079. private _createTileAnimationBuffer;
  65080. /**
  65081. * Modifies the data of the animationMap
  65082. * @param cellID is the Index of the Sprite
  65083. * @param _frame is the target Animation frame
  65084. * @param toCell is the Target Index of the next frame of the animation
  65085. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  65086. * @param speed is a global scalar of the time variable on the map.
  65087. */
  65088. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  65089. /**
  65090. * Exports the .tilemaps file
  65091. */
  65092. saveTileMaps(): void;
  65093. /**
  65094. * Imports the .tilemaps file
  65095. * @param url of the .tilemaps file
  65096. */
  65097. loadTileMaps(url: string): void;
  65098. /**
  65099. * Release associated resources
  65100. */
  65101. dispose(): void;
  65102. }
  65103. }
  65104. declare module BABYLON {
  65105. /**
  65106. * Class used to manage multiple sprites of different sizes on the same spritesheet
  65107. * @see http://doc.babylonjs.com/babylon101/sprites
  65108. */
  65109. export class SpritePackedManager extends SpriteManager {
  65110. /** defines the packed manager's name */
  65111. name: string;
  65112. /**
  65113. * Creates a new sprite manager from a packed sprite sheet
  65114. * @param name defines the manager's name
  65115. * @param imgUrl defines the sprite sheet url
  65116. * @param capacity defines the maximum allowed number of sprites
  65117. * @param scene defines the hosting scene
  65118. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  65119. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  65120. * @param samplingMode defines the smapling mode to use with spritesheet
  65121. * @param fromPacked set to true; do not alter
  65122. */
  65123. constructor(
  65124. /** defines the packed manager's name */
  65125. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  65126. }
  65127. }
  65128. declare module BABYLON {
  65129. /**
  65130. * Defines the list of states available for a task inside a AssetsManager
  65131. */
  65132. export enum AssetTaskState {
  65133. /**
  65134. * Initialization
  65135. */
  65136. INIT = 0,
  65137. /**
  65138. * Running
  65139. */
  65140. RUNNING = 1,
  65141. /**
  65142. * Done
  65143. */
  65144. DONE = 2,
  65145. /**
  65146. * Error
  65147. */
  65148. ERROR = 3
  65149. }
  65150. /**
  65151. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  65152. */
  65153. export abstract class AbstractAssetTask {
  65154. /**
  65155. * Task name
  65156. */ name: string;
  65157. /**
  65158. * Callback called when the task is successful
  65159. */
  65160. onSuccess: (task: any) => void;
  65161. /**
  65162. * Callback called when the task is not successful
  65163. */
  65164. onError: (task: any, message?: string, exception?: any) => void;
  65165. /**
  65166. * Creates a new AssetsManager
  65167. * @param name defines the name of the task
  65168. */
  65169. constructor(
  65170. /**
  65171. * Task name
  65172. */ name: string);
  65173. private _isCompleted;
  65174. private _taskState;
  65175. private _errorObject;
  65176. /**
  65177. * Get if the task is completed
  65178. */
  65179. get isCompleted(): boolean;
  65180. /**
  65181. * Gets the current state of the task
  65182. */
  65183. get taskState(): AssetTaskState;
  65184. /**
  65185. * Gets the current error object (if task is in error)
  65186. */
  65187. get errorObject(): {
  65188. message?: string;
  65189. exception?: any;
  65190. };
  65191. /**
  65192. * Internal only
  65193. * @hidden
  65194. */
  65195. _setErrorObject(message?: string, exception?: any): void;
  65196. /**
  65197. * Execute the current task
  65198. * @param scene defines the scene where you want your assets to be loaded
  65199. * @param onSuccess is a callback called when the task is successfully executed
  65200. * @param onError is a callback called if an error occurs
  65201. */
  65202. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65203. /**
  65204. * Execute the current task
  65205. * @param scene defines the scene where you want your assets to be loaded
  65206. * @param onSuccess is a callback called when the task is successfully executed
  65207. * @param onError is a callback called if an error occurs
  65208. */
  65209. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65210. /**
  65211. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  65212. * This can be used with failed tasks that have the reason for failure fixed.
  65213. */
  65214. reset(): void;
  65215. private onErrorCallback;
  65216. private onDoneCallback;
  65217. }
  65218. /**
  65219. * Define the interface used by progress events raised during assets loading
  65220. */
  65221. export interface IAssetsProgressEvent {
  65222. /**
  65223. * Defines the number of remaining tasks to process
  65224. */
  65225. remainingCount: number;
  65226. /**
  65227. * Defines the total number of tasks
  65228. */
  65229. totalCount: number;
  65230. /**
  65231. * Defines the task that was just processed
  65232. */
  65233. task: AbstractAssetTask;
  65234. }
  65235. /**
  65236. * Class used to share progress information about assets loading
  65237. */
  65238. export class AssetsProgressEvent implements IAssetsProgressEvent {
  65239. /**
  65240. * Defines the number of remaining tasks to process
  65241. */
  65242. remainingCount: number;
  65243. /**
  65244. * Defines the total number of tasks
  65245. */
  65246. totalCount: number;
  65247. /**
  65248. * Defines the task that was just processed
  65249. */
  65250. task: AbstractAssetTask;
  65251. /**
  65252. * Creates a AssetsProgressEvent
  65253. * @param remainingCount defines the number of remaining tasks to process
  65254. * @param totalCount defines the total number of tasks
  65255. * @param task defines the task that was just processed
  65256. */
  65257. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  65258. }
  65259. /**
  65260. * Define a task used by AssetsManager to load meshes
  65261. */
  65262. export class MeshAssetTask extends AbstractAssetTask {
  65263. /**
  65264. * Defines the name of the task
  65265. */
  65266. name: string;
  65267. /**
  65268. * Defines the list of mesh's names you want to load
  65269. */
  65270. meshesNames: any;
  65271. /**
  65272. * Defines the root url to use as a base to load your meshes and associated resources
  65273. */
  65274. rootUrl: string;
  65275. /**
  65276. * Defines the filename of the scene to load from
  65277. */
  65278. sceneFilename: string;
  65279. /**
  65280. * Gets the list of loaded meshes
  65281. */
  65282. loadedMeshes: Array<AbstractMesh>;
  65283. /**
  65284. * Gets the list of loaded particle systems
  65285. */
  65286. loadedParticleSystems: Array<IParticleSystem>;
  65287. /**
  65288. * Gets the list of loaded skeletons
  65289. */
  65290. loadedSkeletons: Array<Skeleton>;
  65291. /**
  65292. * Gets the list of loaded animation groups
  65293. */
  65294. loadedAnimationGroups: Array<AnimationGroup>;
  65295. /**
  65296. * Callback called when the task is successful
  65297. */
  65298. onSuccess: (task: MeshAssetTask) => void;
  65299. /**
  65300. * Callback called when the task is successful
  65301. */
  65302. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  65303. /**
  65304. * Creates a new MeshAssetTask
  65305. * @param name defines the name of the task
  65306. * @param meshesNames defines the list of mesh's names you want to load
  65307. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  65308. * @param sceneFilename defines the filename of the scene to load from
  65309. */
  65310. constructor(
  65311. /**
  65312. * Defines the name of the task
  65313. */
  65314. name: string,
  65315. /**
  65316. * Defines the list of mesh's names you want to load
  65317. */
  65318. meshesNames: any,
  65319. /**
  65320. * Defines the root url to use as a base to load your meshes and associated resources
  65321. */
  65322. rootUrl: string,
  65323. /**
  65324. * Defines the filename of the scene to load from
  65325. */
  65326. sceneFilename: string);
  65327. /**
  65328. * Execute the current task
  65329. * @param scene defines the scene where you want your assets to be loaded
  65330. * @param onSuccess is a callback called when the task is successfully executed
  65331. * @param onError is a callback called if an error occurs
  65332. */
  65333. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65334. }
  65335. /**
  65336. * Define a task used by AssetsManager to load text content
  65337. */
  65338. export class TextFileAssetTask extends AbstractAssetTask {
  65339. /**
  65340. * Defines the name of the task
  65341. */
  65342. name: string;
  65343. /**
  65344. * Defines the location of the file to load
  65345. */
  65346. url: string;
  65347. /**
  65348. * Gets the loaded text string
  65349. */
  65350. text: string;
  65351. /**
  65352. * Callback called when the task is successful
  65353. */
  65354. onSuccess: (task: TextFileAssetTask) => void;
  65355. /**
  65356. * Callback called when the task is successful
  65357. */
  65358. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  65359. /**
  65360. * Creates a new TextFileAssetTask object
  65361. * @param name defines the name of the task
  65362. * @param url defines the location of the file to load
  65363. */
  65364. constructor(
  65365. /**
  65366. * Defines the name of the task
  65367. */
  65368. name: string,
  65369. /**
  65370. * Defines the location of the file to load
  65371. */
  65372. url: string);
  65373. /**
  65374. * Execute the current task
  65375. * @param scene defines the scene where you want your assets to be loaded
  65376. * @param onSuccess is a callback called when the task is successfully executed
  65377. * @param onError is a callback called if an error occurs
  65378. */
  65379. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65380. }
  65381. /**
  65382. * Define a task used by AssetsManager to load binary data
  65383. */
  65384. export class BinaryFileAssetTask extends AbstractAssetTask {
  65385. /**
  65386. * Defines the name of the task
  65387. */
  65388. name: string;
  65389. /**
  65390. * Defines the location of the file to load
  65391. */
  65392. url: string;
  65393. /**
  65394. * Gets the lodaded data (as an array buffer)
  65395. */
  65396. data: ArrayBuffer;
  65397. /**
  65398. * Callback called when the task is successful
  65399. */
  65400. onSuccess: (task: BinaryFileAssetTask) => void;
  65401. /**
  65402. * Callback called when the task is successful
  65403. */
  65404. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  65405. /**
  65406. * Creates a new BinaryFileAssetTask object
  65407. * @param name defines the name of the new task
  65408. * @param url defines the location of the file to load
  65409. */
  65410. constructor(
  65411. /**
  65412. * Defines the name of the task
  65413. */
  65414. name: string,
  65415. /**
  65416. * Defines the location of the file to load
  65417. */
  65418. url: string);
  65419. /**
  65420. * Execute the current task
  65421. * @param scene defines the scene where you want your assets to be loaded
  65422. * @param onSuccess is a callback called when the task is successfully executed
  65423. * @param onError is a callback called if an error occurs
  65424. */
  65425. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65426. }
  65427. /**
  65428. * Define a task used by AssetsManager to load images
  65429. */
  65430. export class ImageAssetTask extends AbstractAssetTask {
  65431. /**
  65432. * Defines the name of the task
  65433. */
  65434. name: string;
  65435. /**
  65436. * Defines the location of the image to load
  65437. */
  65438. url: string;
  65439. /**
  65440. * Gets the loaded images
  65441. */
  65442. image: HTMLImageElement;
  65443. /**
  65444. * Callback called when the task is successful
  65445. */
  65446. onSuccess: (task: ImageAssetTask) => void;
  65447. /**
  65448. * Callback called when the task is successful
  65449. */
  65450. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  65451. /**
  65452. * Creates a new ImageAssetTask
  65453. * @param name defines the name of the task
  65454. * @param url defines the location of the image to load
  65455. */
  65456. constructor(
  65457. /**
  65458. * Defines the name of the task
  65459. */
  65460. name: string,
  65461. /**
  65462. * Defines the location of the image to load
  65463. */
  65464. url: string);
  65465. /**
  65466. * Execute the current task
  65467. * @param scene defines the scene where you want your assets to be loaded
  65468. * @param onSuccess is a callback called when the task is successfully executed
  65469. * @param onError is a callback called if an error occurs
  65470. */
  65471. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65472. }
  65473. /**
  65474. * Defines the interface used by texture loading tasks
  65475. */
  65476. export interface ITextureAssetTask<TEX extends BaseTexture> {
  65477. /**
  65478. * Gets the loaded texture
  65479. */
  65480. texture: TEX;
  65481. }
  65482. /**
  65483. * Define a task used by AssetsManager to load 2D textures
  65484. */
  65485. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  65486. /**
  65487. * Defines the name of the task
  65488. */
  65489. name: string;
  65490. /**
  65491. * Defines the location of the file to load
  65492. */
  65493. url: string;
  65494. /**
  65495. * Defines if mipmap should not be generated (default is false)
  65496. */
  65497. noMipmap?: boolean | undefined;
  65498. /**
  65499. * Defines if texture must be inverted on Y axis (default is false)
  65500. */
  65501. invertY?: boolean | undefined;
  65502. /**
  65503. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  65504. */
  65505. samplingMode: number;
  65506. /**
  65507. * Gets the loaded texture
  65508. */
  65509. texture: Texture;
  65510. /**
  65511. * Callback called when the task is successful
  65512. */
  65513. onSuccess: (task: TextureAssetTask) => void;
  65514. /**
  65515. * Callback called when the task is successful
  65516. */
  65517. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  65518. /**
  65519. * Creates a new TextureAssetTask object
  65520. * @param name defines the name of the task
  65521. * @param url defines the location of the file to load
  65522. * @param noMipmap defines if mipmap should not be generated (default is false)
  65523. * @param invertY defines if texture must be inverted on Y axis (default is false)
  65524. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  65525. */
  65526. constructor(
  65527. /**
  65528. * Defines the name of the task
  65529. */
  65530. name: string,
  65531. /**
  65532. * Defines the location of the file to load
  65533. */
  65534. url: string,
  65535. /**
  65536. * Defines if mipmap should not be generated (default is false)
  65537. */
  65538. noMipmap?: boolean | undefined,
  65539. /**
  65540. * Defines if texture must be inverted on Y axis (default is false)
  65541. */
  65542. invertY?: boolean | undefined,
  65543. /**
  65544. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  65545. */
  65546. samplingMode?: number);
  65547. /**
  65548. * Execute the current task
  65549. * @param scene defines the scene where you want your assets to be loaded
  65550. * @param onSuccess is a callback called when the task is successfully executed
  65551. * @param onError is a callback called if an error occurs
  65552. */
  65553. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65554. }
  65555. /**
  65556. * Define a task used by AssetsManager to load cube textures
  65557. */
  65558. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  65559. /**
  65560. * Defines the name of the task
  65561. */
  65562. name: string;
  65563. /**
  65564. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  65565. */
  65566. url: string;
  65567. /**
  65568. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  65569. */
  65570. extensions?: string[] | undefined;
  65571. /**
  65572. * Defines if mipmaps should not be generated (default is false)
  65573. */
  65574. noMipmap?: boolean | undefined;
  65575. /**
  65576. * Defines the explicit list of files (undefined by default)
  65577. */
  65578. files?: string[] | undefined;
  65579. /**
  65580. * Gets the loaded texture
  65581. */
  65582. texture: CubeTexture;
  65583. /**
  65584. * Callback called when the task is successful
  65585. */
  65586. onSuccess: (task: CubeTextureAssetTask) => void;
  65587. /**
  65588. * Callback called when the task is successful
  65589. */
  65590. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  65591. /**
  65592. * Creates a new CubeTextureAssetTask
  65593. * @param name defines the name of the task
  65594. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  65595. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  65596. * @param noMipmap defines if mipmaps should not be generated (default is false)
  65597. * @param files defines the explicit list of files (undefined by default)
  65598. */
  65599. constructor(
  65600. /**
  65601. * Defines the name of the task
  65602. */
  65603. name: string,
  65604. /**
  65605. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  65606. */
  65607. url: string,
  65608. /**
  65609. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  65610. */
  65611. extensions?: string[] | undefined,
  65612. /**
  65613. * Defines if mipmaps should not be generated (default is false)
  65614. */
  65615. noMipmap?: boolean | undefined,
  65616. /**
  65617. * Defines the explicit list of files (undefined by default)
  65618. */
  65619. files?: string[] | undefined);
  65620. /**
  65621. * Execute the current task
  65622. * @param scene defines the scene where you want your assets to be loaded
  65623. * @param onSuccess is a callback called when the task is successfully executed
  65624. * @param onError is a callback called if an error occurs
  65625. */
  65626. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65627. }
  65628. /**
  65629. * Define a task used by AssetsManager to load HDR cube textures
  65630. */
  65631. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  65632. /**
  65633. * Defines the name of the task
  65634. */
  65635. name: string;
  65636. /**
  65637. * Defines the location of the file to load
  65638. */
  65639. url: string;
  65640. /**
  65641. * Defines the desired size (the more it increases the longer the generation will be)
  65642. */
  65643. size: number;
  65644. /**
  65645. * Defines if mipmaps should not be generated (default is false)
  65646. */
  65647. noMipmap: boolean;
  65648. /**
  65649. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  65650. */
  65651. generateHarmonics: boolean;
  65652. /**
  65653. * 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)
  65654. */
  65655. gammaSpace: boolean;
  65656. /**
  65657. * Internal Use Only
  65658. */
  65659. reserved: boolean;
  65660. /**
  65661. * Gets the loaded texture
  65662. */
  65663. texture: HDRCubeTexture;
  65664. /**
  65665. * Callback called when the task is successful
  65666. */
  65667. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  65668. /**
  65669. * Callback called when the task is successful
  65670. */
  65671. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  65672. /**
  65673. * Creates a new HDRCubeTextureAssetTask object
  65674. * @param name defines the name of the task
  65675. * @param url defines the location of the file to load
  65676. * @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.
  65677. * @param noMipmap defines if mipmaps should not be generated (default is false)
  65678. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  65679. * @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)
  65680. * @param reserved Internal use only
  65681. */
  65682. constructor(
  65683. /**
  65684. * Defines the name of the task
  65685. */
  65686. name: string,
  65687. /**
  65688. * Defines the location of the file to load
  65689. */
  65690. url: string,
  65691. /**
  65692. * Defines the desired size (the more it increases the longer the generation will be)
  65693. */
  65694. size: number,
  65695. /**
  65696. * Defines if mipmaps should not be generated (default is false)
  65697. */
  65698. noMipmap?: boolean,
  65699. /**
  65700. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  65701. */
  65702. generateHarmonics?: boolean,
  65703. /**
  65704. * 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)
  65705. */
  65706. gammaSpace?: boolean,
  65707. /**
  65708. * Internal Use Only
  65709. */
  65710. reserved?: boolean);
  65711. /**
  65712. * Execute the current task
  65713. * @param scene defines the scene where you want your assets to be loaded
  65714. * @param onSuccess is a callback called when the task is successfully executed
  65715. * @param onError is a callback called if an error occurs
  65716. */
  65717. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65718. }
  65719. /**
  65720. * Define a task used by AssetsManager to load Equirectangular cube textures
  65721. */
  65722. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  65723. /**
  65724. * Defines the name of the task
  65725. */
  65726. name: string;
  65727. /**
  65728. * Defines the location of the file to load
  65729. */
  65730. url: string;
  65731. /**
  65732. * Defines the desired size (the more it increases the longer the generation will be)
  65733. */
  65734. size: number;
  65735. /**
  65736. * Defines if mipmaps should not be generated (default is false)
  65737. */
  65738. noMipmap: boolean;
  65739. /**
  65740. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  65741. * but the standard material would require them in Gamma space) (default is true)
  65742. */
  65743. gammaSpace: boolean;
  65744. /**
  65745. * Gets the loaded texture
  65746. */
  65747. texture: EquiRectangularCubeTexture;
  65748. /**
  65749. * Callback called when the task is successful
  65750. */
  65751. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  65752. /**
  65753. * Callback called when the task is successful
  65754. */
  65755. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  65756. /**
  65757. * Creates a new EquiRectangularCubeTextureAssetTask object
  65758. * @param name defines the name of the task
  65759. * @param url defines the location of the file to load
  65760. * @param size defines the desired size (the more it increases the longer the generation will be)
  65761. * If the size is omitted this implies you are using a preprocessed cubemap.
  65762. * @param noMipmap defines if mipmaps should not be generated (default is false)
  65763. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  65764. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  65765. * (default is true)
  65766. */
  65767. constructor(
  65768. /**
  65769. * Defines the name of the task
  65770. */
  65771. name: string,
  65772. /**
  65773. * Defines the location of the file to load
  65774. */
  65775. url: string,
  65776. /**
  65777. * Defines the desired size (the more it increases the longer the generation will be)
  65778. */
  65779. size: number,
  65780. /**
  65781. * Defines if mipmaps should not be generated (default is false)
  65782. */
  65783. noMipmap?: boolean,
  65784. /**
  65785. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  65786. * but the standard material would require them in Gamma space) (default is true)
  65787. */
  65788. gammaSpace?: boolean);
  65789. /**
  65790. * Execute the current task
  65791. * @param scene defines the scene where you want your assets to be loaded
  65792. * @param onSuccess is a callback called when the task is successfully executed
  65793. * @param onError is a callback called if an error occurs
  65794. */
  65795. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65796. }
  65797. /**
  65798. * This class can be used to easily import assets into a scene
  65799. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  65800. */
  65801. export class AssetsManager {
  65802. private _scene;
  65803. private _isLoading;
  65804. protected _tasks: AbstractAssetTask[];
  65805. protected _waitingTasksCount: number;
  65806. protected _totalTasksCount: number;
  65807. /**
  65808. * Callback called when all tasks are processed
  65809. */
  65810. onFinish: (tasks: AbstractAssetTask[]) => void;
  65811. /**
  65812. * Callback called when a task is successful
  65813. */
  65814. onTaskSuccess: (task: AbstractAssetTask) => void;
  65815. /**
  65816. * Callback called when a task had an error
  65817. */
  65818. onTaskError: (task: AbstractAssetTask) => void;
  65819. /**
  65820. * Callback called when a task is done (whatever the result is)
  65821. */
  65822. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  65823. /**
  65824. * Observable called when all tasks are processed
  65825. */
  65826. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  65827. /**
  65828. * Observable called when a task had an error
  65829. */
  65830. onTaskErrorObservable: Observable<AbstractAssetTask>;
  65831. /**
  65832. * Observable called when all tasks were executed
  65833. */
  65834. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  65835. /**
  65836. * Observable called when a task is done (whatever the result is)
  65837. */
  65838. onProgressObservable: Observable<IAssetsProgressEvent>;
  65839. /**
  65840. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  65841. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  65842. */
  65843. useDefaultLoadingScreen: boolean;
  65844. /**
  65845. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  65846. * when all assets have been downloaded.
  65847. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  65848. */
  65849. autoHideLoadingUI: boolean;
  65850. /**
  65851. * Creates a new AssetsManager
  65852. * @param scene defines the scene to work on
  65853. */
  65854. constructor(scene: Scene);
  65855. /**
  65856. * Add a MeshAssetTask to the list of active tasks
  65857. * @param taskName defines the name of the new task
  65858. * @param meshesNames defines the name of meshes to load
  65859. * @param rootUrl defines the root url to use to locate files
  65860. * @param sceneFilename defines the filename of the scene file
  65861. * @returns a new MeshAssetTask object
  65862. */
  65863. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  65864. /**
  65865. * Add a TextFileAssetTask to the list of active tasks
  65866. * @param taskName defines the name of the new task
  65867. * @param url defines the url of the file to load
  65868. * @returns a new TextFileAssetTask object
  65869. */
  65870. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  65871. /**
  65872. * Add a BinaryFileAssetTask to the list of active tasks
  65873. * @param taskName defines the name of the new task
  65874. * @param url defines the url of the file to load
  65875. * @returns a new BinaryFileAssetTask object
  65876. */
  65877. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  65878. /**
  65879. * Add a ImageAssetTask to the list of active tasks
  65880. * @param taskName defines the name of the new task
  65881. * @param url defines the url of the file to load
  65882. * @returns a new ImageAssetTask object
  65883. */
  65884. addImageTask(taskName: string, url: string): ImageAssetTask;
  65885. /**
  65886. * Add a TextureAssetTask to the list of active tasks
  65887. * @param taskName defines the name of the new task
  65888. * @param url defines the url of the file to load
  65889. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  65890. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  65891. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  65892. * @returns a new TextureAssetTask object
  65893. */
  65894. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  65895. /**
  65896. * Add a CubeTextureAssetTask to the list of active tasks
  65897. * @param taskName defines the name of the new task
  65898. * @param url defines the url of the file to load
  65899. * @param extensions defines the extension to use to load the cube map (can be null)
  65900. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  65901. * @param files defines the list of files to load (can be null)
  65902. * @returns a new CubeTextureAssetTask object
  65903. */
  65904. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  65905. /**
  65906. *
  65907. * Add a HDRCubeTextureAssetTask to the list of active tasks
  65908. * @param taskName defines the name of the new task
  65909. * @param url defines the url of the file to load
  65910. * @param size defines the size you want for the cubemap (can be null)
  65911. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  65912. * @param generateHarmonics defines if you want to automatically generate (true by default)
  65913. * @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)
  65914. * @param reserved Internal use only
  65915. * @returns a new HDRCubeTextureAssetTask object
  65916. */
  65917. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  65918. /**
  65919. *
  65920. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  65921. * @param taskName defines the name of the new task
  65922. * @param url defines the url of the file to load
  65923. * @param size defines the size you want for the cubemap (can be null)
  65924. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  65925. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  65926. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  65927. * @returns a new EquiRectangularCubeTextureAssetTask object
  65928. */
  65929. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  65930. /**
  65931. * Remove a task from the assets manager.
  65932. * @param task the task to remove
  65933. */
  65934. removeTask(task: AbstractAssetTask): void;
  65935. private _decreaseWaitingTasksCount;
  65936. private _runTask;
  65937. /**
  65938. * Reset the AssetsManager and remove all tasks
  65939. * @return the current instance of the AssetsManager
  65940. */
  65941. reset(): AssetsManager;
  65942. /**
  65943. * Start the loading process
  65944. * @return the current instance of the AssetsManager
  65945. */
  65946. load(): AssetsManager;
  65947. /**
  65948. * Start the loading process as an async operation
  65949. * @return a promise returning the list of failed tasks
  65950. */
  65951. loadAsync(): Promise<void>;
  65952. }
  65953. }
  65954. declare module BABYLON {
  65955. /**
  65956. * Wrapper class for promise with external resolve and reject.
  65957. */
  65958. export class Deferred<T> {
  65959. /**
  65960. * The promise associated with this deferred object.
  65961. */
  65962. readonly promise: Promise<T>;
  65963. private _resolve;
  65964. private _reject;
  65965. /**
  65966. * The resolve method of the promise associated with this deferred object.
  65967. */
  65968. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  65969. /**
  65970. * The reject method of the promise associated with this deferred object.
  65971. */
  65972. get reject(): (reason?: any) => void;
  65973. /**
  65974. * Constructor for this deferred object.
  65975. */
  65976. constructor();
  65977. }
  65978. }
  65979. declare module BABYLON {
  65980. /**
  65981. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  65982. */
  65983. export class MeshExploder {
  65984. private _centerMesh;
  65985. private _meshes;
  65986. private _meshesOrigins;
  65987. private _toCenterVectors;
  65988. private _scaledDirection;
  65989. private _newPosition;
  65990. private _centerPosition;
  65991. /**
  65992. * Explodes meshes from a center mesh.
  65993. * @param meshes The meshes to explode.
  65994. * @param centerMesh The mesh to be center of explosion.
  65995. */
  65996. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  65997. private _setCenterMesh;
  65998. /**
  65999. * Get class name
  66000. * @returns "MeshExploder"
  66001. */
  66002. getClassName(): string;
  66003. /**
  66004. * "Exploded meshes"
  66005. * @returns Array of meshes with the centerMesh at index 0.
  66006. */
  66007. getMeshes(): Array<Mesh>;
  66008. /**
  66009. * Explodes meshes giving a specific direction
  66010. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  66011. */
  66012. explode(direction?: number): void;
  66013. }
  66014. }
  66015. declare module BABYLON {
  66016. /**
  66017. * Class used to help managing file picking and drag'n'drop
  66018. */
  66019. export class FilesInput {
  66020. /**
  66021. * List of files ready to be loaded
  66022. */
  66023. static get FilesToLoad(): {
  66024. [key: string]: File;
  66025. };
  66026. /**
  66027. * Callback called when a file is processed
  66028. */
  66029. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  66030. private _engine;
  66031. private _currentScene;
  66032. private _sceneLoadedCallback;
  66033. private _progressCallback;
  66034. private _additionalRenderLoopLogicCallback;
  66035. private _textureLoadingCallback;
  66036. private _startingProcessingFilesCallback;
  66037. private _onReloadCallback;
  66038. private _errorCallback;
  66039. private _elementToMonitor;
  66040. private _sceneFileToLoad;
  66041. private _filesToLoad;
  66042. /**
  66043. * Creates a new FilesInput
  66044. * @param engine defines the rendering engine
  66045. * @param scene defines the hosting scene
  66046. * @param sceneLoadedCallback callback called when scene is loaded
  66047. * @param progressCallback callback called to track progress
  66048. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  66049. * @param textureLoadingCallback callback called when a texture is loading
  66050. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  66051. * @param onReloadCallback callback called when a reload is requested
  66052. * @param errorCallback callback call if an error occurs
  66053. */
  66054. 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);
  66055. private _dragEnterHandler;
  66056. private _dragOverHandler;
  66057. private _dropHandler;
  66058. /**
  66059. * Calls this function to listen to drag'n'drop events on a specific DOM element
  66060. * @param elementToMonitor defines the DOM element to track
  66061. */
  66062. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  66063. /**
  66064. * Release all associated resources
  66065. */
  66066. dispose(): void;
  66067. private renderFunction;
  66068. private drag;
  66069. private drop;
  66070. private _traverseFolder;
  66071. private _processFiles;
  66072. /**
  66073. * Load files from a drop event
  66074. * @param event defines the drop event to use as source
  66075. */
  66076. loadFiles(event: any): void;
  66077. private _processReload;
  66078. /**
  66079. * Reload the current scene from the loaded files
  66080. */
  66081. reload(): void;
  66082. }
  66083. }
  66084. declare module BABYLON {
  66085. /**
  66086. * Defines the root class used to create scene optimization to use with SceneOptimizer
  66087. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66088. */
  66089. export class SceneOptimization {
  66090. /**
  66091. * Defines the priority of this optimization (0 by default which means first in the list)
  66092. */
  66093. priority: number;
  66094. /**
  66095. * Gets a string describing the action executed by the current optimization
  66096. * @returns description string
  66097. */
  66098. getDescription(): string;
  66099. /**
  66100. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66101. * @param scene defines the current scene where to apply this optimization
  66102. * @param optimizer defines the current optimizer
  66103. * @returns true if everything that can be done was applied
  66104. */
  66105. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66106. /**
  66107. * Creates the SceneOptimization object
  66108. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  66109. * @param desc defines the description associated with the optimization
  66110. */
  66111. constructor(
  66112. /**
  66113. * Defines the priority of this optimization (0 by default which means first in the list)
  66114. */
  66115. priority?: number);
  66116. }
  66117. /**
  66118. * Defines an optimization used to reduce the size of render target textures
  66119. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66120. */
  66121. export class TextureOptimization extends SceneOptimization {
  66122. /**
  66123. * Defines the priority of this optimization (0 by default which means first in the list)
  66124. */
  66125. priority: number;
  66126. /**
  66127. * 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
  66128. */
  66129. maximumSize: number;
  66130. /**
  66131. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  66132. */
  66133. step: number;
  66134. /**
  66135. * Gets a string describing the action executed by the current optimization
  66136. * @returns description string
  66137. */
  66138. getDescription(): string;
  66139. /**
  66140. * Creates the TextureOptimization object
  66141. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  66142. * @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
  66143. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  66144. */
  66145. constructor(
  66146. /**
  66147. * Defines the priority of this optimization (0 by default which means first in the list)
  66148. */
  66149. priority?: number,
  66150. /**
  66151. * 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
  66152. */
  66153. maximumSize?: number,
  66154. /**
  66155. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  66156. */
  66157. step?: number);
  66158. /**
  66159. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66160. * @param scene defines the current scene where to apply this optimization
  66161. * @param optimizer defines the current optimizer
  66162. * @returns true if everything that can be done was applied
  66163. */
  66164. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66165. }
  66166. /**
  66167. * Defines an optimization used to increase or decrease the rendering resolution
  66168. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66169. */
  66170. export class HardwareScalingOptimization extends SceneOptimization {
  66171. /**
  66172. * Defines the priority of this optimization (0 by default which means first in the list)
  66173. */
  66174. priority: number;
  66175. /**
  66176. * Defines the maximum scale to use (2 by default)
  66177. */
  66178. maximumScale: number;
  66179. /**
  66180. * Defines the step to use between two passes (0.5 by default)
  66181. */
  66182. step: number;
  66183. private _currentScale;
  66184. private _directionOffset;
  66185. /**
  66186. * Gets a string describing the action executed by the current optimization
  66187. * @return description string
  66188. */
  66189. getDescription(): string;
  66190. /**
  66191. * Creates the HardwareScalingOptimization object
  66192. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  66193. * @param maximumScale defines the maximum scale to use (2 by default)
  66194. * @param step defines the step to use between two passes (0.5 by default)
  66195. */
  66196. constructor(
  66197. /**
  66198. * Defines the priority of this optimization (0 by default which means first in the list)
  66199. */
  66200. priority?: number,
  66201. /**
  66202. * Defines the maximum scale to use (2 by default)
  66203. */
  66204. maximumScale?: number,
  66205. /**
  66206. * Defines the step to use between two passes (0.5 by default)
  66207. */
  66208. step?: number);
  66209. /**
  66210. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66211. * @param scene defines the current scene where to apply this optimization
  66212. * @param optimizer defines the current optimizer
  66213. * @returns true if everything that can be done was applied
  66214. */
  66215. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66216. }
  66217. /**
  66218. * Defines an optimization used to remove shadows
  66219. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66220. */
  66221. export class ShadowsOptimization extends SceneOptimization {
  66222. /**
  66223. * Gets a string describing the action executed by the current optimization
  66224. * @return description string
  66225. */
  66226. getDescription(): string;
  66227. /**
  66228. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66229. * @param scene defines the current scene where to apply this optimization
  66230. * @param optimizer defines the current optimizer
  66231. * @returns true if everything that can be done was applied
  66232. */
  66233. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66234. }
  66235. /**
  66236. * Defines an optimization used to turn post-processes off
  66237. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66238. */
  66239. export class PostProcessesOptimization extends SceneOptimization {
  66240. /**
  66241. * Gets a string describing the action executed by the current optimization
  66242. * @return description string
  66243. */
  66244. getDescription(): string;
  66245. /**
  66246. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66247. * @param scene defines the current scene where to apply this optimization
  66248. * @param optimizer defines the current optimizer
  66249. * @returns true if everything that can be done was applied
  66250. */
  66251. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66252. }
  66253. /**
  66254. * Defines an optimization used to turn lens flares off
  66255. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66256. */
  66257. export class LensFlaresOptimization extends SceneOptimization {
  66258. /**
  66259. * Gets a string describing the action executed by the current optimization
  66260. * @return description string
  66261. */
  66262. getDescription(): string;
  66263. /**
  66264. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66265. * @param scene defines the current scene where to apply this optimization
  66266. * @param optimizer defines the current optimizer
  66267. * @returns true if everything that can be done was applied
  66268. */
  66269. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66270. }
  66271. /**
  66272. * Defines an optimization based on user defined callback.
  66273. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66274. */
  66275. export class CustomOptimization extends SceneOptimization {
  66276. /**
  66277. * Callback called to apply the custom optimization.
  66278. */
  66279. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  66280. /**
  66281. * Callback called to get custom description
  66282. */
  66283. onGetDescription: () => string;
  66284. /**
  66285. * Gets a string describing the action executed by the current optimization
  66286. * @returns description string
  66287. */
  66288. getDescription(): string;
  66289. /**
  66290. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66291. * @param scene defines the current scene where to apply this optimization
  66292. * @param optimizer defines the current optimizer
  66293. * @returns true if everything that can be done was applied
  66294. */
  66295. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66296. }
  66297. /**
  66298. * Defines an optimization used to turn particles off
  66299. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66300. */
  66301. export class ParticlesOptimization extends SceneOptimization {
  66302. /**
  66303. * Gets a string describing the action executed by the current optimization
  66304. * @return description string
  66305. */
  66306. getDescription(): string;
  66307. /**
  66308. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66309. * @param scene defines the current scene where to apply this optimization
  66310. * @param optimizer defines the current optimizer
  66311. * @returns true if everything that can be done was applied
  66312. */
  66313. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66314. }
  66315. /**
  66316. * Defines an optimization used to turn render targets off
  66317. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66318. */
  66319. export class RenderTargetsOptimization extends SceneOptimization {
  66320. /**
  66321. * Gets a string describing the action executed by the current optimization
  66322. * @return description string
  66323. */
  66324. getDescription(): string;
  66325. /**
  66326. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66327. * @param scene defines the current scene where to apply this optimization
  66328. * @param optimizer defines the current optimizer
  66329. * @returns true if everything that can be done was applied
  66330. */
  66331. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66332. }
  66333. /**
  66334. * Defines an optimization used to merge meshes with compatible materials
  66335. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66336. */
  66337. export class MergeMeshesOptimization extends SceneOptimization {
  66338. private static _UpdateSelectionTree;
  66339. /**
  66340. * Gets or sets a boolean which defines if optimization octree has to be updated
  66341. */
  66342. static get UpdateSelectionTree(): boolean;
  66343. /**
  66344. * Gets or sets a boolean which defines if optimization octree has to be updated
  66345. */
  66346. static set UpdateSelectionTree(value: boolean);
  66347. /**
  66348. * Gets a string describing the action executed by the current optimization
  66349. * @return description string
  66350. */
  66351. getDescription(): string;
  66352. private _canBeMerged;
  66353. /**
  66354. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66355. * @param scene defines the current scene where to apply this optimization
  66356. * @param optimizer defines the current optimizer
  66357. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  66358. * @returns true if everything that can be done was applied
  66359. */
  66360. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  66361. }
  66362. /**
  66363. * Defines a list of options used by SceneOptimizer
  66364. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66365. */
  66366. export class SceneOptimizerOptions {
  66367. /**
  66368. * Defines the target frame rate to reach (60 by default)
  66369. */
  66370. targetFrameRate: number;
  66371. /**
  66372. * Defines the interval between two checkes (2000ms by default)
  66373. */
  66374. trackerDuration: number;
  66375. /**
  66376. * Gets the list of optimizations to apply
  66377. */
  66378. optimizations: SceneOptimization[];
  66379. /**
  66380. * Creates a new list of options used by SceneOptimizer
  66381. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  66382. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  66383. */
  66384. constructor(
  66385. /**
  66386. * Defines the target frame rate to reach (60 by default)
  66387. */
  66388. targetFrameRate?: number,
  66389. /**
  66390. * Defines the interval between two checkes (2000ms by default)
  66391. */
  66392. trackerDuration?: number);
  66393. /**
  66394. * Add a new optimization
  66395. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  66396. * @returns the current SceneOptimizerOptions
  66397. */
  66398. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  66399. /**
  66400. * Add a new custom optimization
  66401. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  66402. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  66403. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  66404. * @returns the current SceneOptimizerOptions
  66405. */
  66406. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  66407. /**
  66408. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  66409. * @param targetFrameRate defines the target frame rate (60 by default)
  66410. * @returns a SceneOptimizerOptions object
  66411. */
  66412. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  66413. /**
  66414. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  66415. * @param targetFrameRate defines the target frame rate (60 by default)
  66416. * @returns a SceneOptimizerOptions object
  66417. */
  66418. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  66419. /**
  66420. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  66421. * @param targetFrameRate defines the target frame rate (60 by default)
  66422. * @returns a SceneOptimizerOptions object
  66423. */
  66424. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  66425. }
  66426. /**
  66427. * Class used to run optimizations in order to reach a target frame rate
  66428. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66429. */
  66430. export class SceneOptimizer implements IDisposable {
  66431. private _isRunning;
  66432. private _options;
  66433. private _scene;
  66434. private _currentPriorityLevel;
  66435. private _targetFrameRate;
  66436. private _trackerDuration;
  66437. private _currentFrameRate;
  66438. private _sceneDisposeObserver;
  66439. private _improvementMode;
  66440. /**
  66441. * Defines an observable called when the optimizer reaches the target frame rate
  66442. */
  66443. onSuccessObservable: Observable<SceneOptimizer>;
  66444. /**
  66445. * Defines an observable called when the optimizer enables an optimization
  66446. */
  66447. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  66448. /**
  66449. * Defines an observable called when the optimizer is not able to reach the target frame rate
  66450. */
  66451. onFailureObservable: Observable<SceneOptimizer>;
  66452. /**
  66453. * Gets a boolean indicating if the optimizer is in improvement mode
  66454. */
  66455. get isInImprovementMode(): boolean;
  66456. /**
  66457. * Gets the current priority level (0 at start)
  66458. */
  66459. get currentPriorityLevel(): number;
  66460. /**
  66461. * Gets the current frame rate checked by the SceneOptimizer
  66462. */
  66463. get currentFrameRate(): number;
  66464. /**
  66465. * Gets or sets the current target frame rate (60 by default)
  66466. */
  66467. get targetFrameRate(): number;
  66468. /**
  66469. * Gets or sets the current target frame rate (60 by default)
  66470. */
  66471. set targetFrameRate(value: number);
  66472. /**
  66473. * Gets or sets the current interval between two checks (every 2000ms by default)
  66474. */
  66475. get trackerDuration(): number;
  66476. /**
  66477. * Gets or sets the current interval between two checks (every 2000ms by default)
  66478. */
  66479. set trackerDuration(value: number);
  66480. /**
  66481. * Gets the list of active optimizations
  66482. */
  66483. get optimizations(): SceneOptimization[];
  66484. /**
  66485. * Creates a new SceneOptimizer
  66486. * @param scene defines the scene to work on
  66487. * @param options defines the options to use with the SceneOptimizer
  66488. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  66489. * @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)
  66490. */
  66491. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  66492. /**
  66493. * Stops the current optimizer
  66494. */
  66495. stop(): void;
  66496. /**
  66497. * Reset the optimizer to initial step (current priority level = 0)
  66498. */
  66499. reset(): void;
  66500. /**
  66501. * Start the optimizer. By default it will try to reach a specific framerate
  66502. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  66503. */
  66504. start(): void;
  66505. private _checkCurrentState;
  66506. /**
  66507. * Release all resources
  66508. */
  66509. dispose(): void;
  66510. /**
  66511. * Helper function to create a SceneOptimizer with one single line of code
  66512. * @param scene defines the scene to work on
  66513. * @param options defines the options to use with the SceneOptimizer
  66514. * @param onSuccess defines a callback to call on success
  66515. * @param onFailure defines a callback to call on failure
  66516. * @returns the new SceneOptimizer object
  66517. */
  66518. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  66519. }
  66520. }
  66521. declare module BABYLON {
  66522. /**
  66523. * Class used to serialize a scene into a string
  66524. */
  66525. export class SceneSerializer {
  66526. /**
  66527. * Clear cache used by a previous serialization
  66528. */
  66529. static ClearCache(): void;
  66530. /**
  66531. * Serialize a scene into a JSON compatible object
  66532. * @param scene defines the scene to serialize
  66533. * @returns a JSON compatible object
  66534. */
  66535. static Serialize(scene: Scene): any;
  66536. /**
  66537. * Serialize a mesh into a JSON compatible object
  66538. * @param toSerialize defines the mesh to serialize
  66539. * @param withParents defines if parents must be serialized as well
  66540. * @param withChildren defines if children must be serialized as well
  66541. * @returns a JSON compatible object
  66542. */
  66543. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  66544. }
  66545. }
  66546. declare module BABYLON {
  66547. /**
  66548. * Class used to host texture specific utilities
  66549. */
  66550. export class TextureTools {
  66551. /**
  66552. * Uses the GPU to create a copy texture rescaled at a given size
  66553. * @param texture Texture to copy from
  66554. * @param width defines the desired width
  66555. * @param height defines the desired height
  66556. * @param useBilinearMode defines if bilinear mode has to be used
  66557. * @return the generated texture
  66558. */
  66559. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  66560. }
  66561. }
  66562. declare module BABYLON {
  66563. /**
  66564. * This represents the different options available for the video capture.
  66565. */
  66566. export interface VideoRecorderOptions {
  66567. /** Defines the mime type of the video. */
  66568. mimeType: string;
  66569. /** Defines the FPS the video should be recorded at. */
  66570. fps: number;
  66571. /** Defines the chunk size for the recording data. */
  66572. recordChunckSize: number;
  66573. /** The audio tracks to attach to the recording. */
  66574. audioTracks?: MediaStreamTrack[];
  66575. }
  66576. /**
  66577. * This can help with recording videos from BabylonJS.
  66578. * This is based on the available WebRTC functionalities of the browser.
  66579. *
  66580. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  66581. */
  66582. export class VideoRecorder {
  66583. private static readonly _defaultOptions;
  66584. /**
  66585. * Returns whether or not the VideoRecorder is available in your browser.
  66586. * @param engine Defines the Babylon Engine.
  66587. * @returns true if supported otherwise false.
  66588. */
  66589. static IsSupported(engine: Engine): boolean;
  66590. private readonly _options;
  66591. private _canvas;
  66592. private _mediaRecorder;
  66593. private _recordedChunks;
  66594. private _fileName;
  66595. private _resolve;
  66596. private _reject;
  66597. /**
  66598. * True when a recording is already in progress.
  66599. */
  66600. get isRecording(): boolean;
  66601. /**
  66602. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  66603. * @param engine Defines the BabylonJS Engine you wish to record.
  66604. * @param options Defines options that can be used to customize the capture.
  66605. */
  66606. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  66607. /**
  66608. * Stops the current recording before the default capture timeout passed in the startRecording function.
  66609. */
  66610. stopRecording(): void;
  66611. /**
  66612. * Starts recording the canvas for a max duration specified in parameters.
  66613. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  66614. * If null no automatic download will start and you can rely on the promise to get the data back.
  66615. * @param maxDuration Defines the maximum recording time in seconds.
  66616. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  66617. * @return A promise callback at the end of the recording with the video data in Blob.
  66618. */
  66619. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  66620. /**
  66621. * Releases internal resources used during the recording.
  66622. */
  66623. dispose(): void;
  66624. private _handleDataAvailable;
  66625. private _handleError;
  66626. private _handleStop;
  66627. }
  66628. }
  66629. declare module BABYLON {
  66630. /**
  66631. * Class containing a set of static utilities functions for screenshots
  66632. */
  66633. export class ScreenshotTools {
  66634. /**
  66635. * Captures a screenshot of the current rendering
  66636. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  66637. * @param engine defines the rendering engine
  66638. * @param camera defines the source camera
  66639. * @param size This parameter can be set to a single number or to an object with the
  66640. * following (optional) properties: precision, width, height. If a single number is passed,
  66641. * it will be used for both width and height. If an object is passed, the screenshot size
  66642. * will be derived from the parameters. The precision property is a multiplier allowing
  66643. * rendering at a higher or lower resolution
  66644. * @param successCallback defines the callback receives a single parameter which contains the
  66645. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  66646. * src parameter of an <img> to display it
  66647. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  66648. * Check your browser for supported MIME types
  66649. */
  66650. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  66651. /**
  66652. * Captures a screenshot of the current rendering
  66653. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  66654. * @param engine defines the rendering engine
  66655. * @param camera defines the source camera
  66656. * @param size This parameter can be set to a single number or to an object with the
  66657. * following (optional) properties: precision, width, height. If a single number is passed,
  66658. * it will be used for both width and height. If an object is passed, the screenshot size
  66659. * will be derived from the parameters. The precision property is a multiplier allowing
  66660. * rendering at a higher or lower resolution
  66661. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  66662. * Check your browser for supported MIME types
  66663. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  66664. * to the src parameter of an <img> to display it
  66665. */
  66666. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  66667. /**
  66668. * Generates an image screenshot from the specified camera.
  66669. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  66670. * @param engine The engine to use for rendering
  66671. * @param camera The camera to use for rendering
  66672. * @param size This parameter can be set to a single number or to an object with the
  66673. * following (optional) properties: precision, width, height. If a single number is passed,
  66674. * it will be used for both width and height. If an object is passed, the screenshot size
  66675. * will be derived from the parameters. The precision property is a multiplier allowing
  66676. * rendering at a higher or lower resolution
  66677. * @param successCallback The callback receives a single parameter which contains the
  66678. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  66679. * src parameter of an <img> to display it
  66680. * @param mimeType The MIME type of the screenshot image (default: image/png).
  66681. * Check your browser for supported MIME types
  66682. * @param samples Texture samples (default: 1)
  66683. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  66684. * @param fileName A name for for the downloaded file.
  66685. */
  66686. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  66687. /**
  66688. * Generates an image screenshot from the specified camera.
  66689. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  66690. * @param engine The engine to use for rendering
  66691. * @param camera The camera to use for rendering
  66692. * @param size This parameter can be set to a single number or to an object with the
  66693. * following (optional) properties: precision, width, height. If a single number is passed,
  66694. * it will be used for both width and height. If an object is passed, the screenshot size
  66695. * will be derived from the parameters. The precision property is a multiplier allowing
  66696. * rendering at a higher or lower resolution
  66697. * @param mimeType The MIME type of the screenshot image (default: image/png).
  66698. * Check your browser for supported MIME types
  66699. * @param samples Texture samples (default: 1)
  66700. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  66701. * @param fileName A name for for the downloaded file.
  66702. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  66703. * to the src parameter of an <img> to display it
  66704. */
  66705. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  66706. /**
  66707. * Gets height and width for screenshot size
  66708. * @private
  66709. */
  66710. private static _getScreenshotSize;
  66711. }
  66712. }
  66713. declare module BABYLON {
  66714. /**
  66715. * Interface for a data buffer
  66716. */
  66717. export interface IDataBuffer {
  66718. /**
  66719. * Reads bytes from the data buffer.
  66720. * @param byteOffset The byte offset to read
  66721. * @param byteLength The byte length to read
  66722. * @returns A promise that resolves when the bytes are read
  66723. */
  66724. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  66725. /**
  66726. * The byte length of the buffer.
  66727. */
  66728. readonly byteLength: number;
  66729. }
  66730. /**
  66731. * Utility class for reading from a data buffer
  66732. */
  66733. export class DataReader {
  66734. /**
  66735. * The data buffer associated with this data reader.
  66736. */
  66737. readonly buffer: IDataBuffer;
  66738. /**
  66739. * The current byte offset from the beginning of the data buffer.
  66740. */
  66741. byteOffset: number;
  66742. private _dataView;
  66743. private _dataByteOffset;
  66744. /**
  66745. * Constructor
  66746. * @param buffer The buffer to read
  66747. */
  66748. constructor(buffer: IDataBuffer);
  66749. /**
  66750. * Loads the given byte length.
  66751. * @param byteLength The byte length to load
  66752. * @returns A promise that resolves when the load is complete
  66753. */
  66754. loadAsync(byteLength: number): Promise<void>;
  66755. /**
  66756. * Read a unsigned 32-bit integer from the currently loaded data range.
  66757. * @returns The 32-bit integer read
  66758. */
  66759. readUint32(): number;
  66760. /**
  66761. * Read a byte array from the currently loaded data range.
  66762. * @param byteLength The byte length to read
  66763. * @returns The byte array read
  66764. */
  66765. readUint8Array(byteLength: number): Uint8Array;
  66766. /**
  66767. * Read a string from the currently loaded data range.
  66768. * @param byteLength The byte length to read
  66769. * @returns The string read
  66770. */
  66771. readString(byteLength: number): string;
  66772. /**
  66773. * Skips the given byte length the currently loaded data range.
  66774. * @param byteLength The byte length to skip
  66775. */
  66776. skipBytes(byteLength: number): void;
  66777. }
  66778. }
  66779. declare module BABYLON {
  66780. /**
  66781. * A cursor which tracks a point on a path
  66782. */
  66783. export class PathCursor {
  66784. private path;
  66785. /**
  66786. * Stores path cursor callbacks for when an onchange event is triggered
  66787. */
  66788. private _onchange;
  66789. /**
  66790. * The value of the path cursor
  66791. */
  66792. value: number;
  66793. /**
  66794. * The animation array of the path cursor
  66795. */
  66796. animations: Animation[];
  66797. /**
  66798. * Initializes the path cursor
  66799. * @param path The path to track
  66800. */
  66801. constructor(path: Path2);
  66802. /**
  66803. * Gets the cursor point on the path
  66804. * @returns A point on the path cursor at the cursor location
  66805. */
  66806. getPoint(): Vector3;
  66807. /**
  66808. * Moves the cursor ahead by the step amount
  66809. * @param step The amount to move the cursor forward
  66810. * @returns This path cursor
  66811. */
  66812. moveAhead(step?: number): PathCursor;
  66813. /**
  66814. * Moves the cursor behind by the step amount
  66815. * @param step The amount to move the cursor back
  66816. * @returns This path cursor
  66817. */
  66818. moveBack(step?: number): PathCursor;
  66819. /**
  66820. * Moves the cursor by the step amount
  66821. * If the step amount is greater than one, an exception is thrown
  66822. * @param step The amount to move the cursor
  66823. * @returns This path cursor
  66824. */
  66825. move(step: number): PathCursor;
  66826. /**
  66827. * Ensures that the value is limited between zero and one
  66828. * @returns This path cursor
  66829. */
  66830. private ensureLimits;
  66831. /**
  66832. * Runs onchange callbacks on change (used by the animation engine)
  66833. * @returns This path cursor
  66834. */
  66835. private raiseOnChange;
  66836. /**
  66837. * Executes a function on change
  66838. * @param f A path cursor onchange callback
  66839. * @returns This path cursor
  66840. */
  66841. onchange(f: (cursor: PathCursor) => void): PathCursor;
  66842. }
  66843. }
  66844. declare module BABYLON {
  66845. /** @hidden */
  66846. export var blurPixelShader: {
  66847. name: string;
  66848. shader: string;
  66849. };
  66850. }
  66851. declare module BABYLON {
  66852. /** @hidden */
  66853. export var pointCloudVertexDeclaration: {
  66854. name: string;
  66855. shader: string;
  66856. };
  66857. }
  66858. // Mixins
  66859. interface Window {
  66860. mozIndexedDB: IDBFactory;
  66861. webkitIndexedDB: IDBFactory;
  66862. msIndexedDB: IDBFactory;
  66863. webkitURL: typeof URL;
  66864. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  66865. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  66866. WebGLRenderingContext: WebGLRenderingContext;
  66867. MSGesture: MSGesture;
  66868. CANNON: any;
  66869. AudioContext: AudioContext;
  66870. webkitAudioContext: AudioContext;
  66871. PointerEvent: any;
  66872. Math: Math;
  66873. Uint8Array: Uint8ArrayConstructor;
  66874. Float32Array: Float32ArrayConstructor;
  66875. mozURL: typeof URL;
  66876. msURL: typeof URL;
  66877. VRFrameData: any; // WebVR, from specs 1.1
  66878. DracoDecoderModule: any;
  66879. setImmediate(handler: (...args: any[]) => void): number;
  66880. }
  66881. interface HTMLCanvasElement {
  66882. requestPointerLock(): void;
  66883. msRequestPointerLock?(): void;
  66884. mozRequestPointerLock?(): void;
  66885. webkitRequestPointerLock?(): void;
  66886. /** Track wether a record is in progress */
  66887. isRecording: boolean;
  66888. /** Capture Stream method defined by some browsers */
  66889. captureStream(fps?: number): MediaStream;
  66890. }
  66891. interface CanvasRenderingContext2D {
  66892. msImageSmoothingEnabled: boolean;
  66893. }
  66894. interface MouseEvent {
  66895. mozMovementX: number;
  66896. mozMovementY: number;
  66897. webkitMovementX: number;
  66898. webkitMovementY: number;
  66899. msMovementX: number;
  66900. msMovementY: number;
  66901. }
  66902. interface Navigator {
  66903. mozGetVRDevices: (any: any) => any;
  66904. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  66905. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  66906. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  66907. webkitGetGamepads(): Gamepad[];
  66908. msGetGamepads(): Gamepad[];
  66909. webkitGamepads(): Gamepad[];
  66910. }
  66911. interface HTMLVideoElement {
  66912. mozSrcObject: any;
  66913. }
  66914. interface Math {
  66915. fround(x: number): number;
  66916. imul(a: number, b: number): number;
  66917. }
  66918. interface WebGLRenderingContext {
  66919. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  66920. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  66921. vertexAttribDivisor(index: number, divisor: number): void;
  66922. createVertexArray(): any;
  66923. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  66924. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  66925. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  66926. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  66927. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  66928. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  66929. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  66930. // Queries
  66931. createQuery(): WebGLQuery;
  66932. deleteQuery(query: WebGLQuery): void;
  66933. beginQuery(target: number, query: WebGLQuery): void;
  66934. endQuery(target: number): void;
  66935. getQueryParameter(query: WebGLQuery, pname: number): any;
  66936. getQuery(target: number, pname: number): any;
  66937. MAX_SAMPLES: number;
  66938. RGBA8: number;
  66939. READ_FRAMEBUFFER: number;
  66940. DRAW_FRAMEBUFFER: number;
  66941. UNIFORM_BUFFER: number;
  66942. HALF_FLOAT_OES: number;
  66943. RGBA16F: number;
  66944. RGBA32F: number;
  66945. R32F: number;
  66946. RG32F: number;
  66947. RGB32F: number;
  66948. R16F: number;
  66949. RG16F: number;
  66950. RGB16F: number;
  66951. RED: number;
  66952. RG: number;
  66953. R8: number;
  66954. RG8: number;
  66955. UNSIGNED_INT_24_8: number;
  66956. DEPTH24_STENCIL8: number;
  66957. MIN: number;
  66958. MAX: number;
  66959. /* Multiple Render Targets */
  66960. drawBuffers(buffers: number[]): void;
  66961. readBuffer(src: number): void;
  66962. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  66963. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  66964. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  66965. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  66966. // Occlusion Query
  66967. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  66968. ANY_SAMPLES_PASSED: number;
  66969. QUERY_RESULT_AVAILABLE: number;
  66970. QUERY_RESULT: number;
  66971. }
  66972. interface WebGLProgram {
  66973. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  66974. }
  66975. interface EXT_disjoint_timer_query {
  66976. QUERY_COUNTER_BITS_EXT: number;
  66977. TIME_ELAPSED_EXT: number;
  66978. TIMESTAMP_EXT: number;
  66979. GPU_DISJOINT_EXT: number;
  66980. QUERY_RESULT_EXT: number;
  66981. QUERY_RESULT_AVAILABLE_EXT: number;
  66982. queryCounterEXT(query: WebGLQuery, target: number): void;
  66983. createQueryEXT(): WebGLQuery;
  66984. beginQueryEXT(target: number, query: WebGLQuery): void;
  66985. endQueryEXT(target: number): void;
  66986. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  66987. deleteQueryEXT(query: WebGLQuery): void;
  66988. }
  66989. interface WebGLUniformLocation {
  66990. _currentState: any;
  66991. }
  66992. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  66993. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  66994. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  66995. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  66996. interface WebGLRenderingContext {
  66997. readonly RASTERIZER_DISCARD: number;
  66998. readonly DEPTH_COMPONENT24: number;
  66999. readonly TEXTURE_3D: number;
  67000. readonly TEXTURE_2D_ARRAY: number;
  67001. readonly TEXTURE_COMPARE_FUNC: number;
  67002. readonly TEXTURE_COMPARE_MODE: number;
  67003. readonly COMPARE_REF_TO_TEXTURE: number;
  67004. readonly TEXTURE_WRAP_R: number;
  67005. readonly HALF_FLOAT: number;
  67006. readonly RGB8: number;
  67007. readonly RED_INTEGER: number;
  67008. readonly RG_INTEGER: number;
  67009. readonly RGB_INTEGER: number;
  67010. readonly RGBA_INTEGER: number;
  67011. readonly R8_SNORM: number;
  67012. readonly RG8_SNORM: number;
  67013. readonly RGB8_SNORM: number;
  67014. readonly RGBA8_SNORM: number;
  67015. readonly R8I: number;
  67016. readonly RG8I: number;
  67017. readonly RGB8I: number;
  67018. readonly RGBA8I: number;
  67019. readonly R8UI: number;
  67020. readonly RG8UI: number;
  67021. readonly RGB8UI: number;
  67022. readonly RGBA8UI: number;
  67023. readonly R16I: number;
  67024. readonly RG16I: number;
  67025. readonly RGB16I: number;
  67026. readonly RGBA16I: number;
  67027. readonly R16UI: number;
  67028. readonly RG16UI: number;
  67029. readonly RGB16UI: number;
  67030. readonly RGBA16UI: number;
  67031. readonly R32I: number;
  67032. readonly RG32I: number;
  67033. readonly RGB32I: number;
  67034. readonly RGBA32I: number;
  67035. readonly R32UI: number;
  67036. readonly RG32UI: number;
  67037. readonly RGB32UI: number;
  67038. readonly RGBA32UI: number;
  67039. readonly RGB10_A2UI: number;
  67040. readonly R11F_G11F_B10F: number;
  67041. readonly RGB9_E5: number;
  67042. readonly RGB10_A2: number;
  67043. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  67044. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  67045. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  67046. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  67047. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  67048. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  67049. 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;
  67050. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  67051. readonly TRANSFORM_FEEDBACK: number;
  67052. readonly INTERLEAVED_ATTRIBS: number;
  67053. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  67054. createTransformFeedback(): WebGLTransformFeedback;
  67055. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  67056. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  67057. beginTransformFeedback(primitiveMode: number): void;
  67058. endTransformFeedback(): void;
  67059. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  67060. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  67061. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  67062. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  67063. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  67064. }
  67065. interface ImageBitmap {
  67066. readonly width: number;
  67067. readonly height: number;
  67068. close(): void;
  67069. }
  67070. interface WebGLQuery extends WebGLObject {
  67071. }
  67072. declare var WebGLQuery: {
  67073. prototype: WebGLQuery;
  67074. new(): WebGLQuery;
  67075. };
  67076. interface WebGLSampler extends WebGLObject {
  67077. }
  67078. declare var WebGLSampler: {
  67079. prototype: WebGLSampler;
  67080. new(): WebGLSampler;
  67081. };
  67082. interface WebGLSync extends WebGLObject {
  67083. }
  67084. declare var WebGLSync: {
  67085. prototype: WebGLSync;
  67086. new(): WebGLSync;
  67087. };
  67088. interface WebGLTransformFeedback extends WebGLObject {
  67089. }
  67090. declare var WebGLTransformFeedback: {
  67091. prototype: WebGLTransformFeedback;
  67092. new(): WebGLTransformFeedback;
  67093. };
  67094. interface WebGLVertexArrayObject extends WebGLObject {
  67095. }
  67096. declare var WebGLVertexArrayObject: {
  67097. prototype: WebGLVertexArrayObject;
  67098. new(): WebGLVertexArrayObject;
  67099. };
  67100. // Type definitions for WebVR API
  67101. // Project: https://w3c.github.io/webvr/
  67102. // Definitions by: six a <https://github.com/lostfictions>
  67103. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  67104. interface VRDisplay extends EventTarget {
  67105. /**
  67106. * Dictionary of capabilities describing the VRDisplay.
  67107. */
  67108. readonly capabilities: VRDisplayCapabilities;
  67109. /**
  67110. * z-depth defining the far plane of the eye view frustum
  67111. * enables mapping of values in the render target depth
  67112. * attachment to scene coordinates. Initially set to 10000.0.
  67113. */
  67114. depthFar: number;
  67115. /**
  67116. * z-depth defining the near plane of the eye view frustum
  67117. * enables mapping of values in the render target depth
  67118. * attachment to scene coordinates. Initially set to 0.01.
  67119. */
  67120. depthNear: number;
  67121. /**
  67122. * An identifier for this distinct VRDisplay. Used as an
  67123. * association point in the Gamepad API.
  67124. */
  67125. readonly displayId: number;
  67126. /**
  67127. * A display name, a user-readable name identifying it.
  67128. */
  67129. readonly displayName: string;
  67130. readonly isConnected: boolean;
  67131. readonly isPresenting: boolean;
  67132. /**
  67133. * If this VRDisplay supports room-scale experiences, the optional
  67134. * stage attribute contains details on the room-scale parameters.
  67135. */
  67136. readonly stageParameters: VRStageParameters | null;
  67137. /**
  67138. * Passing the value returned by `requestAnimationFrame` to
  67139. * `cancelAnimationFrame` will unregister the callback.
  67140. * @param handle Define the hanle of the request to cancel
  67141. */
  67142. cancelAnimationFrame(handle: number): void;
  67143. /**
  67144. * Stops presenting to the VRDisplay.
  67145. * @returns a promise to know when it stopped
  67146. */
  67147. exitPresent(): Promise<void>;
  67148. /**
  67149. * Return the current VREyeParameters for the given eye.
  67150. * @param whichEye Define the eye we want the parameter for
  67151. * @returns the eye parameters
  67152. */
  67153. getEyeParameters(whichEye: string): VREyeParameters;
  67154. /**
  67155. * Populates the passed VRFrameData with the information required to render
  67156. * the current frame.
  67157. * @param frameData Define the data structure to populate
  67158. * @returns true if ok otherwise false
  67159. */
  67160. getFrameData(frameData: VRFrameData): boolean;
  67161. /**
  67162. * Get the layers currently being presented.
  67163. * @returns the list of VR layers
  67164. */
  67165. getLayers(): VRLayer[];
  67166. /**
  67167. * Return a VRPose containing the future predicted pose of the VRDisplay
  67168. * when the current frame will be presented. The value returned will not
  67169. * change until JavaScript has returned control to the browser.
  67170. *
  67171. * The VRPose will contain the position, orientation, velocity,
  67172. * and acceleration of each of these properties.
  67173. * @returns the pose object
  67174. */
  67175. getPose(): VRPose;
  67176. /**
  67177. * Return the current instantaneous pose of the VRDisplay, with no
  67178. * prediction applied.
  67179. * @returns the current instantaneous pose
  67180. */
  67181. getImmediatePose(): VRPose;
  67182. /**
  67183. * The callback passed to `requestAnimationFrame` will be called
  67184. * any time a new frame should be rendered. When the VRDisplay is
  67185. * presenting the callback will be called at the native refresh
  67186. * rate of the HMD. When not presenting this function acts
  67187. * identically to how window.requestAnimationFrame acts. Content should
  67188. * make no assumptions of frame rate or vsync behavior as the HMD runs
  67189. * asynchronously from other displays and at differing refresh rates.
  67190. * @param callback Define the eaction to run next frame
  67191. * @returns the request handle it
  67192. */
  67193. requestAnimationFrame(callback: FrameRequestCallback): number;
  67194. /**
  67195. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  67196. * Repeat calls while already presenting will update the VRLayers being displayed.
  67197. * @param layers Define the list of layer to present
  67198. * @returns a promise to know when the request has been fulfilled
  67199. */
  67200. requestPresent(layers: VRLayer[]): Promise<void>;
  67201. /**
  67202. * Reset the pose for this display, treating its current position and
  67203. * orientation as the "origin/zero" values. VRPose.position,
  67204. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  67205. * updated when calling resetPose(). This should be called in only
  67206. * sitting-space experiences.
  67207. */
  67208. resetPose(): void;
  67209. /**
  67210. * The VRLayer provided to the VRDisplay will be captured and presented
  67211. * in the HMD. Calling this function has the same effect on the source
  67212. * canvas as any other operation that uses its source image, and canvases
  67213. * created without preserveDrawingBuffer set to true will be cleared.
  67214. * @param pose Define the pose to submit
  67215. */
  67216. submitFrame(pose?: VRPose): void;
  67217. }
  67218. declare var VRDisplay: {
  67219. prototype: VRDisplay;
  67220. new(): VRDisplay;
  67221. };
  67222. interface VRLayer {
  67223. leftBounds?: number[] | Float32Array | null;
  67224. rightBounds?: number[] | Float32Array | null;
  67225. source?: HTMLCanvasElement | null;
  67226. }
  67227. interface VRDisplayCapabilities {
  67228. readonly canPresent: boolean;
  67229. readonly hasExternalDisplay: boolean;
  67230. readonly hasOrientation: boolean;
  67231. readonly hasPosition: boolean;
  67232. readonly maxLayers: number;
  67233. }
  67234. interface VREyeParameters {
  67235. /** @deprecated */
  67236. readonly fieldOfView: VRFieldOfView;
  67237. readonly offset: Float32Array;
  67238. readonly renderHeight: number;
  67239. readonly renderWidth: number;
  67240. }
  67241. interface VRFieldOfView {
  67242. readonly downDegrees: number;
  67243. readonly leftDegrees: number;
  67244. readonly rightDegrees: number;
  67245. readonly upDegrees: number;
  67246. }
  67247. interface VRFrameData {
  67248. readonly leftProjectionMatrix: Float32Array;
  67249. readonly leftViewMatrix: Float32Array;
  67250. readonly pose: VRPose;
  67251. readonly rightProjectionMatrix: Float32Array;
  67252. readonly rightViewMatrix: Float32Array;
  67253. readonly timestamp: number;
  67254. }
  67255. interface VRPose {
  67256. readonly angularAcceleration: Float32Array | null;
  67257. readonly angularVelocity: Float32Array | null;
  67258. readonly linearAcceleration: Float32Array | null;
  67259. readonly linearVelocity: Float32Array | null;
  67260. readonly orientation: Float32Array | null;
  67261. readonly position: Float32Array | null;
  67262. readonly timestamp: number;
  67263. }
  67264. interface VRStageParameters {
  67265. sittingToStandingTransform?: Float32Array;
  67266. sizeX?: number;
  67267. sizeY?: number;
  67268. }
  67269. interface Navigator {
  67270. getVRDisplays(): Promise<VRDisplay[]>;
  67271. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  67272. }
  67273. interface Window {
  67274. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  67275. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  67276. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  67277. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  67278. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  67279. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  67280. }
  67281. interface Gamepad {
  67282. readonly displayId: number;
  67283. }
  67284. type XRSessionMode =
  67285. | "inline"
  67286. | "immersive-vr"
  67287. | "immersive-ar";
  67288. type XRReferenceSpaceType =
  67289. | "viewer"
  67290. | "local"
  67291. | "local-floor"
  67292. | "bounded-floor"
  67293. | "unbounded";
  67294. type XREnvironmentBlendMode =
  67295. | "opaque"
  67296. | "additive"
  67297. | "alpha-blend";
  67298. type XRVisibilityState =
  67299. | "visible"
  67300. | "visible-blurred"
  67301. | "hidden";
  67302. type XRHandedness =
  67303. | "none"
  67304. | "left"
  67305. | "right";
  67306. type XRTargetRayMode =
  67307. | "gaze"
  67308. | "tracked-pointer"
  67309. | "screen";
  67310. type XREye =
  67311. | "none"
  67312. | "left"
  67313. | "right";
  67314. interface XRSpace extends EventTarget {
  67315. }
  67316. interface XRRenderState {
  67317. depthNear?: number;
  67318. depthFar?: number;
  67319. inlineVerticalFieldOfView?: number;
  67320. baseLayer?: XRWebGLLayer;
  67321. }
  67322. interface XRInputSource {
  67323. handedness: XRHandedness;
  67324. targetRayMode: XRTargetRayMode;
  67325. targetRaySpace: XRSpace;
  67326. gripSpace: XRSpace | undefined;
  67327. gamepad: Gamepad | undefined;
  67328. profiles: Array<string>;
  67329. }
  67330. interface XRSession extends XRAnchorCreator {
  67331. addEventListener: Function;
  67332. removeEventListener: Function;
  67333. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  67334. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  67335. requestAnimationFrame: Function;
  67336. end(): Promise<void>;
  67337. renderState: XRRenderState;
  67338. inputSources: Array<XRInputSource>;
  67339. // AR hit test
  67340. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  67341. updateWorldTrackingState(options: {
  67342. planeDetectionState?: { enabled: boolean; }
  67343. }): void;
  67344. }
  67345. interface XRReferenceSpace extends XRSpace {
  67346. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  67347. onreset: any;
  67348. }
  67349. type XRPlaneSet = Set<XRPlane>;
  67350. type XRAnchorSet = Set<XRAnchor>;
  67351. interface XRFrame {
  67352. session: XRSession;
  67353. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  67354. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  67355. // Anchors
  67356. trackedAnchors?: XRAnchorSet;
  67357. // Planes
  67358. worldInformation: {
  67359. detectedPlanes?: XRPlaneSet;
  67360. };
  67361. }
  67362. interface XRViewerPose extends XRPose {
  67363. views: Array<XRView>;
  67364. }
  67365. interface XRPose {
  67366. transform: XRRigidTransform;
  67367. emulatedPosition: boolean;
  67368. }
  67369. interface XRWebGLLayerOptions {
  67370. antialias?: boolean;
  67371. depth?: boolean;
  67372. stencil?: boolean;
  67373. alpha?: boolean;
  67374. multiview?: boolean;
  67375. framebufferScaleFactor?: number;
  67376. }
  67377. declare var XRWebGLLayer: {
  67378. prototype: XRWebGLLayer;
  67379. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  67380. };
  67381. interface XRWebGLLayer {
  67382. framebuffer: WebGLFramebuffer;
  67383. framebufferWidth: number;
  67384. framebufferHeight: number;
  67385. getViewport: Function;
  67386. }
  67387. declare class XRRigidTransform {
  67388. constructor(matrix: Float32Array);
  67389. position: DOMPointReadOnly;
  67390. orientation: DOMPointReadOnly;
  67391. matrix: Float32Array;
  67392. inverse: XRRigidTransform;
  67393. }
  67394. interface XRView {
  67395. eye: XREye;
  67396. projectionMatrix: Float32Array;
  67397. transform: XRRigidTransform;
  67398. }
  67399. interface XRInputSourceChangeEvent {
  67400. session: XRSession;
  67401. removed: Array<XRInputSource>;
  67402. added: Array<XRInputSource>;
  67403. }
  67404. interface XRInputSourceEvent extends Event {
  67405. readonly frame: XRFrame;
  67406. readonly inputSource: XRInputSource;
  67407. }
  67408. // Experimental(er) features
  67409. declare class XRRay {
  67410. constructor(transformOrOrigin: XRRigidTransform | DOMPointReadOnly, direction?: DOMPointReadOnly);
  67411. origin: DOMPointReadOnly;
  67412. direction: DOMPointReadOnly;
  67413. matrix: Float32Array;
  67414. }
  67415. interface XRHitResult {
  67416. hitMatrix: Float32Array;
  67417. }
  67418. interface XRAnchor {
  67419. // remove?
  67420. id?: string;
  67421. anchorSpace: XRSpace;
  67422. lastChangedTime: number;
  67423. detach(): void;
  67424. }
  67425. interface XRPlane extends XRAnchorCreator {
  67426. orientation: "Horizontal" | "Vertical";
  67427. planeSpace: XRSpace;
  67428. polygon: Array<DOMPointReadOnly>;
  67429. lastChangedTime: number;
  67430. }
  67431. interface XRAnchorCreator {
  67432. // AR Anchors
  67433. createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
  67434. }
  67435. /**
  67436. * @ignore
  67437. */
  67438. declare module BABYLON.GLTF2.Exporter {
  67439. }
  67440. /**
  67441. * @ignore
  67442. */
  67443. declare module BABYLON.GLTF1 {
  67444. }
  67445. declare module BABYLON.GUI {
  67446. /**
  67447. * Class used to specific a value and its associated unit
  67448. */
  67449. export class ValueAndUnit {
  67450. /** defines the unit to store */
  67451. unit: number;
  67452. /** defines a boolean indicating if the value can be negative */
  67453. negativeValueAllowed: boolean;
  67454. private _value;
  67455. private _originalUnit;
  67456. /**
  67457. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  67458. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  67459. */
  67460. ignoreAdaptiveScaling: boolean;
  67461. /**
  67462. * Creates a new ValueAndUnit
  67463. * @param value defines the value to store
  67464. * @param unit defines the unit to store
  67465. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  67466. */
  67467. constructor(value: number,
  67468. /** defines the unit to store */
  67469. unit?: number,
  67470. /** defines a boolean indicating if the value can be negative */
  67471. negativeValueAllowed?: boolean);
  67472. /** Gets a boolean indicating if the value is a percentage */
  67473. get isPercentage(): boolean;
  67474. /** Gets a boolean indicating if the value is store as pixel */
  67475. get isPixel(): boolean;
  67476. /** Gets direct internal value */
  67477. get internalValue(): number;
  67478. /**
  67479. * Gets value as pixel
  67480. * @param host defines the root host
  67481. * @param refValue defines the reference value for percentages
  67482. * @returns the value as pixel
  67483. */
  67484. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  67485. /**
  67486. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  67487. * @param value defines the value to store
  67488. * @param unit defines the unit to store
  67489. * @returns the current ValueAndUnit
  67490. */
  67491. updateInPlace(value: number, unit?: number): ValueAndUnit;
  67492. /**
  67493. * Gets the value accordingly to its unit
  67494. * @param host defines the root host
  67495. * @returns the value
  67496. */
  67497. getValue(host: AdvancedDynamicTexture): number;
  67498. /**
  67499. * Gets a string representation of the value
  67500. * @param host defines the root host
  67501. * @param decimals defines an optional number of decimals to display
  67502. * @returns a string
  67503. */
  67504. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  67505. /**
  67506. * Store a value parsed from a string
  67507. * @param source defines the source string
  67508. * @returns true if the value was successfully parsed
  67509. */
  67510. fromString(source: string | number): boolean;
  67511. private static _Regex;
  67512. private static _UNITMODE_PERCENTAGE;
  67513. private static _UNITMODE_PIXEL;
  67514. /** UNITMODE_PERCENTAGE */
  67515. static get UNITMODE_PERCENTAGE(): number;
  67516. /** UNITMODE_PIXEL */
  67517. static get UNITMODE_PIXEL(): number;
  67518. }
  67519. }
  67520. declare module BABYLON.GUI {
  67521. /**
  67522. * Define a style used by control to automatically setup properties based on a template.
  67523. * Only support font related properties so far
  67524. */
  67525. export class Style implements BABYLON.IDisposable {
  67526. private _fontFamily;
  67527. private _fontStyle;
  67528. private _fontWeight;
  67529. /** @hidden */
  67530. _host: AdvancedDynamicTexture;
  67531. /** @hidden */
  67532. _fontSize: ValueAndUnit;
  67533. /**
  67534. * BABYLON.Observable raised when the style values are changed
  67535. */
  67536. onChangedObservable: BABYLON.Observable<Style>;
  67537. /**
  67538. * Creates a new style object
  67539. * @param host defines the AdvancedDynamicTexture which hosts this style
  67540. */
  67541. constructor(host: AdvancedDynamicTexture);
  67542. /**
  67543. * Gets or sets the font size
  67544. */
  67545. get fontSize(): string | number;
  67546. set fontSize(value: string | number);
  67547. /**
  67548. * Gets or sets the font family
  67549. */
  67550. get fontFamily(): string;
  67551. set fontFamily(value: string);
  67552. /**
  67553. * Gets or sets the font style
  67554. */
  67555. get fontStyle(): string;
  67556. set fontStyle(value: string);
  67557. /** Gets or sets font weight */
  67558. get fontWeight(): string;
  67559. set fontWeight(value: string);
  67560. /** Dispose all associated resources */
  67561. dispose(): void;
  67562. }
  67563. }
  67564. declare module BABYLON.GUI {
  67565. /**
  67566. * Class used to transport BABYLON.Vector2 information for pointer events
  67567. */
  67568. export class Vector2WithInfo extends BABYLON.Vector2 {
  67569. /** defines the current mouse button index */
  67570. buttonIndex: number;
  67571. /**
  67572. * Creates a new Vector2WithInfo
  67573. * @param source defines the vector2 data to transport
  67574. * @param buttonIndex defines the current mouse button index
  67575. */
  67576. constructor(source: BABYLON.Vector2,
  67577. /** defines the current mouse button index */
  67578. buttonIndex?: number);
  67579. }
  67580. /** Class used to provide 2D matrix features */
  67581. export class Matrix2D {
  67582. /** Gets the internal array of 6 floats used to store matrix data */
  67583. m: Float32Array;
  67584. /**
  67585. * Creates a new matrix
  67586. * @param m00 defines value for (0, 0)
  67587. * @param m01 defines value for (0, 1)
  67588. * @param m10 defines value for (1, 0)
  67589. * @param m11 defines value for (1, 1)
  67590. * @param m20 defines value for (2, 0)
  67591. * @param m21 defines value for (2, 1)
  67592. */
  67593. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  67594. /**
  67595. * Fills the matrix from direct values
  67596. * @param m00 defines value for (0, 0)
  67597. * @param m01 defines value for (0, 1)
  67598. * @param m10 defines value for (1, 0)
  67599. * @param m11 defines value for (1, 1)
  67600. * @param m20 defines value for (2, 0)
  67601. * @param m21 defines value for (2, 1)
  67602. * @returns the current modified matrix
  67603. */
  67604. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  67605. /**
  67606. * Gets matrix determinant
  67607. * @returns the determinant
  67608. */
  67609. determinant(): number;
  67610. /**
  67611. * Inverses the matrix and stores it in a target matrix
  67612. * @param result defines the target matrix
  67613. * @returns the current matrix
  67614. */
  67615. invertToRef(result: Matrix2D): Matrix2D;
  67616. /**
  67617. * Multiplies the current matrix with another one
  67618. * @param other defines the second operand
  67619. * @param result defines the target matrix
  67620. * @returns the current matrix
  67621. */
  67622. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  67623. /**
  67624. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  67625. * @param x defines the x coordinate to transform
  67626. * @param y defines the x coordinate to transform
  67627. * @param result defines the target vector2
  67628. * @returns the current matrix
  67629. */
  67630. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  67631. /**
  67632. * Creates an identity matrix
  67633. * @returns a new matrix
  67634. */
  67635. static Identity(): Matrix2D;
  67636. /**
  67637. * Creates a translation matrix and stores it in a target matrix
  67638. * @param x defines the x coordinate of the translation
  67639. * @param y defines the y coordinate of the translation
  67640. * @param result defines the target matrix
  67641. */
  67642. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  67643. /**
  67644. * Creates a scaling matrix and stores it in a target matrix
  67645. * @param x defines the x coordinate of the scaling
  67646. * @param y defines the y coordinate of the scaling
  67647. * @param result defines the target matrix
  67648. */
  67649. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  67650. /**
  67651. * Creates a rotation matrix and stores it in a target matrix
  67652. * @param angle defines the rotation angle
  67653. * @param result defines the target matrix
  67654. */
  67655. static RotationToRef(angle: number, result: Matrix2D): void;
  67656. private static _TempPreTranslationMatrix;
  67657. private static _TempPostTranslationMatrix;
  67658. private static _TempRotationMatrix;
  67659. private static _TempScalingMatrix;
  67660. private static _TempCompose0;
  67661. private static _TempCompose1;
  67662. private static _TempCompose2;
  67663. /**
  67664. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  67665. * @param tx defines the x coordinate of the translation
  67666. * @param ty defines the y coordinate of the translation
  67667. * @param angle defines the rotation angle
  67668. * @param scaleX defines the x coordinate of the scaling
  67669. * @param scaleY defines the y coordinate of the scaling
  67670. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  67671. * @param result defines the target matrix
  67672. */
  67673. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  67674. }
  67675. }
  67676. declare module BABYLON.GUI {
  67677. /**
  67678. * Class used to store 2D control sizes
  67679. */
  67680. export class Measure {
  67681. /** defines left coordinate */
  67682. left: number;
  67683. /** defines top coordinate */
  67684. top: number;
  67685. /** defines width dimension */
  67686. width: number;
  67687. /** defines height dimension */
  67688. height: number;
  67689. /**
  67690. * Creates a new measure
  67691. * @param left defines left coordinate
  67692. * @param top defines top coordinate
  67693. * @param width defines width dimension
  67694. * @param height defines height dimension
  67695. */
  67696. constructor(
  67697. /** defines left coordinate */
  67698. left: number,
  67699. /** defines top coordinate */
  67700. top: number,
  67701. /** defines width dimension */
  67702. width: number,
  67703. /** defines height dimension */
  67704. height: number);
  67705. /**
  67706. * Copy from another measure
  67707. * @param other defines the other measure to copy from
  67708. */
  67709. copyFrom(other: Measure): void;
  67710. /**
  67711. * Copy from a group of 4 floats
  67712. * @param left defines left coordinate
  67713. * @param top defines top coordinate
  67714. * @param width defines width dimension
  67715. * @param height defines height dimension
  67716. */
  67717. copyFromFloats(left: number, top: number, width: number, height: number): void;
  67718. /**
  67719. * Computes the axis aligned bounding box measure for two given measures
  67720. * @param a Input measure
  67721. * @param b Input measure
  67722. * @param result the resulting bounding measure
  67723. */
  67724. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  67725. /**
  67726. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  67727. * @param transform the matrix to transform the measure before computing the AABB
  67728. * @param result the resulting AABB
  67729. */
  67730. transformToRef(transform: Matrix2D, result: Measure): void;
  67731. /**
  67732. * Check equality between this measure and another one
  67733. * @param other defines the other measures
  67734. * @returns true if both measures are equals
  67735. */
  67736. isEqualsTo(other: Measure): boolean;
  67737. /**
  67738. * Creates an empty measure
  67739. * @returns a new measure
  67740. */
  67741. static Empty(): Measure;
  67742. }
  67743. }
  67744. declare module BABYLON.GUI {
  67745. /**
  67746. * Interface used to define a control that can receive focus
  67747. */
  67748. export interface IFocusableControl {
  67749. /**
  67750. * Function called when the control receives the focus
  67751. */
  67752. onFocus(): void;
  67753. /**
  67754. * Function called when the control loses the focus
  67755. */
  67756. onBlur(): void;
  67757. /**
  67758. * Function called to let the control handle keyboard events
  67759. * @param evt defines the current keyboard event
  67760. */
  67761. processKeyboard(evt: KeyboardEvent): void;
  67762. /**
  67763. * Function called to get the list of controls that should not steal the focus from this control
  67764. * @returns an array of controls
  67765. */
  67766. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  67767. }
  67768. /**
  67769. * Class used to create texture to support 2D GUI elements
  67770. * @see http://doc.babylonjs.com/how_to/gui
  67771. */
  67772. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  67773. private _isDirty;
  67774. private _renderObserver;
  67775. private _resizeObserver;
  67776. private _preKeyboardObserver;
  67777. private _pointerMoveObserver;
  67778. private _pointerObserver;
  67779. private _canvasPointerOutObserver;
  67780. private _background;
  67781. /** @hidden */
  67782. _rootContainer: Container;
  67783. /** @hidden */
  67784. _lastPickedControl: Control;
  67785. /** @hidden */
  67786. _lastControlOver: {
  67787. [pointerId: number]: Control;
  67788. };
  67789. /** @hidden */
  67790. _lastControlDown: {
  67791. [pointerId: number]: Control;
  67792. };
  67793. /** @hidden */
  67794. _capturingControl: {
  67795. [pointerId: number]: Control;
  67796. };
  67797. /** @hidden */
  67798. _shouldBlockPointer: boolean;
  67799. /** @hidden */
  67800. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  67801. /** @hidden */
  67802. _linkedControls: Control[];
  67803. private _isFullscreen;
  67804. private _fullscreenViewport;
  67805. private _idealWidth;
  67806. private _idealHeight;
  67807. private _useSmallestIdeal;
  67808. private _renderAtIdealSize;
  67809. private _focusedControl;
  67810. private _blockNextFocusCheck;
  67811. private _renderScale;
  67812. private _rootElement;
  67813. private _cursorChanged;
  67814. /**
  67815. * Define type to string to ensure compatibility across browsers
  67816. * Safari doesn't support DataTransfer constructor
  67817. */
  67818. private _clipboardData;
  67819. /**
  67820. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  67821. */
  67822. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  67823. /**
  67824. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  67825. */
  67826. onControlPickedObservable: BABYLON.Observable<Control>;
  67827. /**
  67828. * BABYLON.Observable event triggered before layout is evaluated
  67829. */
  67830. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  67831. /**
  67832. * BABYLON.Observable event triggered after the layout was evaluated
  67833. */
  67834. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  67835. /**
  67836. * BABYLON.Observable event triggered before the texture is rendered
  67837. */
  67838. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  67839. /**
  67840. * BABYLON.Observable event triggered after the texture was rendered
  67841. */
  67842. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  67843. /**
  67844. * Gets or sets a boolean defining if alpha is stored as premultiplied
  67845. */
  67846. premulAlpha: boolean;
  67847. /**
  67848. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  67849. * Useful when you want more antialiasing
  67850. */
  67851. get renderScale(): number;
  67852. set renderScale(value: number);
  67853. /** Gets or sets the background color */
  67854. get background(): string;
  67855. set background(value: string);
  67856. /**
  67857. * Gets or sets the ideal width used to design controls.
  67858. * The GUI will then rescale everything accordingly
  67859. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  67860. */
  67861. get idealWidth(): number;
  67862. set idealWidth(value: number);
  67863. /**
  67864. * Gets or sets the ideal height used to design controls.
  67865. * The GUI will then rescale everything accordingly
  67866. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  67867. */
  67868. get idealHeight(): number;
  67869. set idealHeight(value: number);
  67870. /**
  67871. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  67872. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  67873. */
  67874. get useSmallestIdeal(): boolean;
  67875. set useSmallestIdeal(value: boolean);
  67876. /**
  67877. * Gets or sets a boolean indicating if adaptive scaling must be used
  67878. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  67879. */
  67880. get renderAtIdealSize(): boolean;
  67881. set renderAtIdealSize(value: boolean);
  67882. /**
  67883. * Gets the underlying layer used to render the texture when in fullscreen mode
  67884. */
  67885. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  67886. /**
  67887. * Gets the root container control
  67888. */
  67889. get rootContainer(): Container;
  67890. /**
  67891. * Returns an array containing the root container.
  67892. * This is mostly used to let the Inspector introspects the ADT
  67893. * @returns an array containing the rootContainer
  67894. */
  67895. getChildren(): Array<Container>;
  67896. /**
  67897. * Will return all controls that are inside this texture
  67898. * @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
  67899. * @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
  67900. * @return all child controls
  67901. */
  67902. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  67903. /**
  67904. * Gets or sets the current focused control
  67905. */
  67906. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  67907. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  67908. /**
  67909. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  67910. */
  67911. get isForeground(): boolean;
  67912. set isForeground(value: boolean);
  67913. /**
  67914. * Gets or set information about clipboardData
  67915. */
  67916. get clipboardData(): string;
  67917. set clipboardData(value: string);
  67918. /**
  67919. * Creates a new AdvancedDynamicTexture
  67920. * @param name defines the name of the texture
  67921. * @param width defines the width of the texture
  67922. * @param height defines the height of the texture
  67923. * @param scene defines the hosting scene
  67924. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  67925. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  67926. */
  67927. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  67928. /**
  67929. * Get the current class name of the texture useful for serialization or dynamic coding.
  67930. * @returns "AdvancedDynamicTexture"
  67931. */
  67932. getClassName(): string;
  67933. /**
  67934. * Function used to execute a function on all controls
  67935. * @param func defines the function to execute
  67936. * @param container defines the container where controls belong. If null the root container will be used
  67937. */
  67938. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  67939. private _useInvalidateRectOptimization;
  67940. /**
  67941. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  67942. */
  67943. get useInvalidateRectOptimization(): boolean;
  67944. set useInvalidateRectOptimization(value: boolean);
  67945. private _invalidatedRectangle;
  67946. /**
  67947. * Invalidates a rectangle area on the gui texture
  67948. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  67949. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  67950. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  67951. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  67952. */
  67953. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  67954. /**
  67955. * Marks the texture as dirty forcing a complete update
  67956. */
  67957. markAsDirty(): void;
  67958. /**
  67959. * Helper function used to create a new style
  67960. * @returns a new style
  67961. * @see http://doc.babylonjs.com/how_to/gui#styles
  67962. */
  67963. createStyle(): Style;
  67964. /**
  67965. * Adds a new control to the root container
  67966. * @param control defines the control to add
  67967. * @returns the current texture
  67968. */
  67969. addControl(control: Control): AdvancedDynamicTexture;
  67970. /**
  67971. * Removes a control from the root container
  67972. * @param control defines the control to remove
  67973. * @returns the current texture
  67974. */
  67975. removeControl(control: Control): AdvancedDynamicTexture;
  67976. /**
  67977. * Release all resources
  67978. */
  67979. dispose(): void;
  67980. private _onResize;
  67981. /** @hidden */
  67982. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  67983. /**
  67984. * Get screen coordinates for a vector3
  67985. * @param position defines the position to project
  67986. * @param worldMatrix defines the world matrix to use
  67987. * @returns the projected position
  67988. */
  67989. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  67990. private _checkUpdate;
  67991. private _clearMeasure;
  67992. private _render;
  67993. /** @hidden */
  67994. _changeCursor(cursor: string): void;
  67995. /** @hidden */
  67996. _registerLastControlDown(control: Control, pointerId: number): void;
  67997. private _doPicking;
  67998. /** @hidden */
  67999. _cleanControlAfterRemovalFromList(list: {
  68000. [pointerId: number]: Control;
  68001. }, control: Control): void;
  68002. /** @hidden */
  68003. _cleanControlAfterRemoval(control: Control): void;
  68004. /** Attach to all scene events required to support pointer events */
  68005. attach(): void;
  68006. /** @hidden */
  68007. private onClipboardCopy;
  68008. /** @hidden */
  68009. private onClipboardCut;
  68010. /** @hidden */
  68011. private onClipboardPaste;
  68012. /**
  68013. * Register the clipboard Events onto the canvas
  68014. */
  68015. registerClipboardEvents(): void;
  68016. /**
  68017. * Unregister the clipboard Events from the canvas
  68018. */
  68019. unRegisterClipboardEvents(): void;
  68020. /**
  68021. * Connect the texture to a hosting mesh to enable interactions
  68022. * @param mesh defines the mesh to attach to
  68023. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  68024. */
  68025. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  68026. /**
  68027. * Move the focus to a specific control
  68028. * @param control defines the control which will receive the focus
  68029. */
  68030. moveFocusToControl(control: IFocusableControl): void;
  68031. private _manageFocus;
  68032. private _attachToOnPointerOut;
  68033. /**
  68034. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  68035. * @param mesh defines the mesh which will receive the texture
  68036. * @param width defines the texture width (1024 by default)
  68037. * @param height defines the texture height (1024 by default)
  68038. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  68039. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  68040. * @returns a new AdvancedDynamicTexture
  68041. */
  68042. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  68043. /**
  68044. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  68045. * In this mode the texture will rely on a layer for its rendering.
  68046. * This allows it to be treated like any other layer.
  68047. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  68048. * LayerMask is set through advancedTexture.layer.layerMask
  68049. * @param name defines name for the texture
  68050. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  68051. * @param scene defines the hsoting scene
  68052. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  68053. * @returns a new AdvancedDynamicTexture
  68054. */
  68055. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  68056. }
  68057. }
  68058. declare module BABYLON.GUI {
  68059. /**
  68060. * Root class used for all 2D controls
  68061. * @see http://doc.babylonjs.com/how_to/gui#controls
  68062. */
  68063. export class Control {
  68064. /** defines the name of the control */
  68065. name?: string | undefined;
  68066. /**
  68067. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  68068. */
  68069. static AllowAlphaInheritance: boolean;
  68070. private _alpha;
  68071. private _alphaSet;
  68072. private _zIndex;
  68073. /** @hidden */
  68074. _host: AdvancedDynamicTexture;
  68075. /** Gets or sets the control parent */
  68076. parent: BABYLON.Nullable<Container>;
  68077. /** @hidden */
  68078. _currentMeasure: Measure;
  68079. private _fontFamily;
  68080. private _fontStyle;
  68081. private _fontWeight;
  68082. private _fontSize;
  68083. private _font;
  68084. /** @hidden */
  68085. _width: ValueAndUnit;
  68086. /** @hidden */
  68087. _height: ValueAndUnit;
  68088. /** @hidden */
  68089. protected _fontOffset: {
  68090. ascent: number;
  68091. height: number;
  68092. descent: number;
  68093. };
  68094. private _color;
  68095. private _style;
  68096. private _styleObserver;
  68097. /** @hidden */
  68098. protected _horizontalAlignment: number;
  68099. /** @hidden */
  68100. protected _verticalAlignment: number;
  68101. /** @hidden */
  68102. protected _isDirty: boolean;
  68103. /** @hidden */
  68104. protected _wasDirty: boolean;
  68105. /** @hidden */
  68106. _tempParentMeasure: Measure;
  68107. /** @hidden */
  68108. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  68109. /** @hidden */
  68110. protected _cachedParentMeasure: Measure;
  68111. private _paddingLeft;
  68112. private _paddingRight;
  68113. private _paddingTop;
  68114. private _paddingBottom;
  68115. /** @hidden */
  68116. _left: ValueAndUnit;
  68117. /** @hidden */
  68118. _top: ValueAndUnit;
  68119. private _scaleX;
  68120. private _scaleY;
  68121. private _rotation;
  68122. private _transformCenterX;
  68123. private _transformCenterY;
  68124. /** @hidden */
  68125. _transformMatrix: Matrix2D;
  68126. /** @hidden */
  68127. protected _invertTransformMatrix: Matrix2D;
  68128. /** @hidden */
  68129. protected _transformedPosition: BABYLON.Vector2;
  68130. private _isMatrixDirty;
  68131. private _cachedOffsetX;
  68132. private _cachedOffsetY;
  68133. private _isVisible;
  68134. private _isHighlighted;
  68135. /** @hidden */
  68136. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  68137. private _fontSet;
  68138. private _dummyVector2;
  68139. private _downCount;
  68140. private _enterCount;
  68141. private _doNotRender;
  68142. private _downPointerIds;
  68143. protected _isEnabled: boolean;
  68144. protected _disabledColor: string;
  68145. /** @hidden */
  68146. protected _rebuildLayout: boolean;
  68147. /** @hidden */
  68148. _isClipped: boolean;
  68149. /** @hidden */
  68150. _automaticSize: boolean;
  68151. /** @hidden */
  68152. _tag: any;
  68153. /**
  68154. * 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
  68155. */
  68156. uniqueId: number;
  68157. /**
  68158. * Gets or sets an object used to store user defined information for the node
  68159. */
  68160. metadata: any;
  68161. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  68162. isHitTestVisible: boolean;
  68163. /** Gets or sets a boolean indicating if the control can block pointer events */
  68164. isPointerBlocker: boolean;
  68165. /** Gets or sets a boolean indicating if the control can be focusable */
  68166. isFocusInvisible: boolean;
  68167. /**
  68168. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  68169. * 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
  68170. */
  68171. clipChildren: boolean;
  68172. /**
  68173. * Gets or sets a boolean indicating that control content must be clipped
  68174. * 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
  68175. */
  68176. clipContent: boolean;
  68177. /**
  68178. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  68179. */
  68180. useBitmapCache: boolean;
  68181. private _cacheData;
  68182. private _shadowOffsetX;
  68183. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  68184. get shadowOffsetX(): number;
  68185. set shadowOffsetX(value: number);
  68186. private _shadowOffsetY;
  68187. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  68188. get shadowOffsetY(): number;
  68189. set shadowOffsetY(value: number);
  68190. private _shadowBlur;
  68191. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  68192. get shadowBlur(): number;
  68193. set shadowBlur(value: number);
  68194. private _shadowColor;
  68195. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  68196. get shadowColor(): string;
  68197. set shadowColor(value: string);
  68198. /** Gets or sets the cursor to use when the control is hovered */
  68199. hoverCursor: string;
  68200. /** @hidden */
  68201. protected _linkOffsetX: ValueAndUnit;
  68202. /** @hidden */
  68203. protected _linkOffsetY: ValueAndUnit;
  68204. /** Gets the control type name */
  68205. get typeName(): string;
  68206. /**
  68207. * Get the current class name of the control.
  68208. * @returns current class name
  68209. */
  68210. getClassName(): string;
  68211. /**
  68212. * An event triggered when the pointer move over the control.
  68213. */
  68214. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  68215. /**
  68216. * An event triggered when the pointer move out of the control.
  68217. */
  68218. onPointerOutObservable: BABYLON.Observable<Control>;
  68219. /**
  68220. * An event triggered when the pointer taps the control
  68221. */
  68222. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  68223. /**
  68224. * An event triggered when pointer up
  68225. */
  68226. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  68227. /**
  68228. * An event triggered when a control is clicked on
  68229. */
  68230. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  68231. /**
  68232. * An event triggered when pointer enters the control
  68233. */
  68234. onPointerEnterObservable: BABYLON.Observable<Control>;
  68235. /**
  68236. * An event triggered when the control is marked as dirty
  68237. */
  68238. onDirtyObservable: BABYLON.Observable<Control>;
  68239. /**
  68240. * An event triggered before drawing the control
  68241. */
  68242. onBeforeDrawObservable: BABYLON.Observable<Control>;
  68243. /**
  68244. * An event triggered after the control was drawn
  68245. */
  68246. onAfterDrawObservable: BABYLON.Observable<Control>;
  68247. /**
  68248. * Get the hosting AdvancedDynamicTexture
  68249. */
  68250. get host(): AdvancedDynamicTexture;
  68251. /** Gets or set information about font offsets (used to render and align text) */
  68252. get fontOffset(): {
  68253. ascent: number;
  68254. height: number;
  68255. descent: number;
  68256. };
  68257. set fontOffset(offset: {
  68258. ascent: number;
  68259. height: number;
  68260. descent: number;
  68261. });
  68262. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  68263. get alpha(): number;
  68264. set alpha(value: number);
  68265. /**
  68266. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  68267. */
  68268. get isHighlighted(): boolean;
  68269. set isHighlighted(value: boolean);
  68270. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  68271. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  68272. */
  68273. get scaleX(): number;
  68274. set scaleX(value: number);
  68275. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  68276. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  68277. */
  68278. get scaleY(): number;
  68279. set scaleY(value: number);
  68280. /** Gets or sets the rotation angle (0 by default)
  68281. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  68282. */
  68283. get rotation(): number;
  68284. set rotation(value: number);
  68285. /** Gets or sets the transformation center on Y axis (0 by default)
  68286. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  68287. */
  68288. get transformCenterY(): number;
  68289. set transformCenterY(value: number);
  68290. /** Gets or sets the transformation center on X axis (0 by default)
  68291. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  68292. */
  68293. get transformCenterX(): number;
  68294. set transformCenterX(value: number);
  68295. /**
  68296. * Gets or sets the horizontal alignment
  68297. * @see http://doc.babylonjs.com/how_to/gui#alignments
  68298. */
  68299. get horizontalAlignment(): number;
  68300. set horizontalAlignment(value: number);
  68301. /**
  68302. * Gets or sets the vertical alignment
  68303. * @see http://doc.babylonjs.com/how_to/gui#alignments
  68304. */
  68305. get verticalAlignment(): number;
  68306. set verticalAlignment(value: number);
  68307. /**
  68308. * Gets or sets control width
  68309. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  68310. */
  68311. get width(): string | number;
  68312. set width(value: string | number);
  68313. /**
  68314. * Gets or sets the control width in pixel
  68315. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  68316. */
  68317. get widthInPixels(): number;
  68318. set widthInPixels(value: number);
  68319. /**
  68320. * Gets or sets control height
  68321. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  68322. */
  68323. get height(): string | number;
  68324. set height(value: string | number);
  68325. /**
  68326. * Gets or sets control height in pixel
  68327. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  68328. */
  68329. get heightInPixels(): number;
  68330. set heightInPixels(value: number);
  68331. /** Gets or set font family */
  68332. get fontFamily(): string;
  68333. set fontFamily(value: string);
  68334. /** Gets or sets font style */
  68335. get fontStyle(): string;
  68336. set fontStyle(value: string);
  68337. /** Gets or sets font weight */
  68338. get fontWeight(): string;
  68339. set fontWeight(value: string);
  68340. /**
  68341. * Gets or sets style
  68342. * @see http://doc.babylonjs.com/how_to/gui#styles
  68343. */
  68344. get style(): BABYLON.Nullable<Style>;
  68345. set style(value: BABYLON.Nullable<Style>);
  68346. /** @hidden */
  68347. get _isFontSizeInPercentage(): boolean;
  68348. /** Gets or sets font size in pixels */
  68349. get fontSizeInPixels(): number;
  68350. set fontSizeInPixels(value: number);
  68351. /** Gets or sets font size */
  68352. get fontSize(): string | number;
  68353. set fontSize(value: string | number);
  68354. /** Gets or sets foreground color */
  68355. get color(): string;
  68356. set color(value: string);
  68357. /** Gets or sets z index which is used to reorder controls on the z axis */
  68358. get zIndex(): number;
  68359. set zIndex(value: number);
  68360. /** Gets or sets a boolean indicating if the control can be rendered */
  68361. get notRenderable(): boolean;
  68362. set notRenderable(value: boolean);
  68363. /** Gets or sets a boolean indicating if the control is visible */
  68364. get isVisible(): boolean;
  68365. set isVisible(value: boolean);
  68366. /** Gets a boolean indicating that the control needs to update its rendering */
  68367. get isDirty(): boolean;
  68368. /**
  68369. * Gets the current linked mesh (or null if none)
  68370. */
  68371. get linkedMesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  68372. /**
  68373. * Gets or sets a value indicating the padding to use on the left of the control
  68374. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  68375. */
  68376. get paddingLeft(): string | number;
  68377. set paddingLeft(value: string | number);
  68378. /**
  68379. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  68380. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  68381. */
  68382. get paddingLeftInPixels(): number;
  68383. set paddingLeftInPixels(value: number);
  68384. /**
  68385. * Gets or sets a value indicating the padding to use on the right of the control
  68386. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  68387. */
  68388. get paddingRight(): string | number;
  68389. set paddingRight(value: string | number);
  68390. /**
  68391. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  68392. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  68393. */
  68394. get paddingRightInPixels(): number;
  68395. set paddingRightInPixels(value: number);
  68396. /**
  68397. * Gets or sets a value indicating the padding to use on the top of the control
  68398. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  68399. */
  68400. get paddingTop(): string | number;
  68401. set paddingTop(value: string | number);
  68402. /**
  68403. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  68404. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  68405. */
  68406. get paddingTopInPixels(): number;
  68407. set paddingTopInPixels(value: number);
  68408. /**
  68409. * Gets or sets a value indicating the padding to use on the bottom of the control
  68410. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  68411. */
  68412. get paddingBottom(): string | number;
  68413. set paddingBottom(value: string | number);
  68414. /**
  68415. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  68416. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  68417. */
  68418. get paddingBottomInPixels(): number;
  68419. set paddingBottomInPixels(value: number);
  68420. /**
  68421. * Gets or sets a value indicating the left coordinate of the control
  68422. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  68423. */
  68424. get left(): string | number;
  68425. set left(value: string | number);
  68426. /**
  68427. * Gets or sets a value indicating the left coordinate in pixels of the control
  68428. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  68429. */
  68430. get leftInPixels(): number;
  68431. set leftInPixels(value: number);
  68432. /**
  68433. * Gets or sets a value indicating the top coordinate of the control
  68434. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  68435. */
  68436. get top(): string | number;
  68437. set top(value: string | number);
  68438. /**
  68439. * Gets or sets a value indicating the top coordinate in pixels of the control
  68440. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  68441. */
  68442. get topInPixels(): number;
  68443. set topInPixels(value: number);
  68444. /**
  68445. * Gets or sets a value indicating the offset on X axis to the linked mesh
  68446. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  68447. */
  68448. get linkOffsetX(): string | number;
  68449. set linkOffsetX(value: string | number);
  68450. /**
  68451. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  68452. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  68453. */
  68454. get linkOffsetXInPixels(): number;
  68455. set linkOffsetXInPixels(value: number);
  68456. /**
  68457. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  68458. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  68459. */
  68460. get linkOffsetY(): string | number;
  68461. set linkOffsetY(value: string | number);
  68462. /**
  68463. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  68464. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  68465. */
  68466. get linkOffsetYInPixels(): number;
  68467. set linkOffsetYInPixels(value: number);
  68468. /** Gets the center coordinate on X axis */
  68469. get centerX(): number;
  68470. /** Gets the center coordinate on Y axis */
  68471. get centerY(): number;
  68472. /** Gets or sets if control is Enabled*/
  68473. get isEnabled(): boolean;
  68474. set isEnabled(value: boolean);
  68475. /** Gets or sets background color of control if it's disabled*/
  68476. get disabledColor(): string;
  68477. set disabledColor(value: string);
  68478. /**
  68479. * Creates a new control
  68480. * @param name defines the name of the control
  68481. */
  68482. constructor(
  68483. /** defines the name of the control */
  68484. name?: string | undefined);
  68485. /** @hidden */
  68486. protected _getTypeName(): string;
  68487. /**
  68488. * Gets the first ascendant in the hierarchy of the given type
  68489. * @param className defines the required type
  68490. * @returns the ascendant or null if not found
  68491. */
  68492. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  68493. /** @hidden */
  68494. _resetFontCache(): void;
  68495. /**
  68496. * Determines if a container is an ascendant of the current control
  68497. * @param container defines the container to look for
  68498. * @returns true if the container is one of the ascendant of the control
  68499. */
  68500. isAscendant(container: Control): boolean;
  68501. /**
  68502. * Gets coordinates in local control space
  68503. * @param globalCoordinates defines the coordinates to transform
  68504. * @returns the new coordinates in local space
  68505. */
  68506. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  68507. /**
  68508. * Gets coordinates in local control space
  68509. * @param globalCoordinates defines the coordinates to transform
  68510. * @param result defines the target vector2 where to store the result
  68511. * @returns the current control
  68512. */
  68513. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  68514. /**
  68515. * Gets coordinates in parent local control space
  68516. * @param globalCoordinates defines the coordinates to transform
  68517. * @returns the new coordinates in parent local space
  68518. */
  68519. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  68520. /**
  68521. * Move the current control to a vector3 position projected onto the screen.
  68522. * @param position defines the target position
  68523. * @param scene defines the hosting scene
  68524. */
  68525. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  68526. /**
  68527. * Will store all controls that have this control as ascendant in a given array
  68528. * @param results defines the array where to store the descendants
  68529. * @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
  68530. * @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
  68531. */
  68532. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  68533. /**
  68534. * Will return all controls that have this control as ascendant
  68535. * @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
  68536. * @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
  68537. * @return all child controls
  68538. */
  68539. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  68540. /**
  68541. * Link current control with a target mesh
  68542. * @param mesh defines the mesh to link with
  68543. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  68544. */
  68545. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  68546. /** @hidden */
  68547. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  68548. /** @hidden */
  68549. _offsetLeft(offset: number): void;
  68550. /** @hidden */
  68551. _offsetTop(offset: number): void;
  68552. /** @hidden */
  68553. _markMatrixAsDirty(): void;
  68554. /** @hidden */
  68555. _flagDescendantsAsMatrixDirty(): void;
  68556. /** @hidden */
  68557. _intersectsRect(rect: Measure): boolean;
  68558. /** @hidden */
  68559. protected invalidateRect(): void;
  68560. /** @hidden */
  68561. _markAsDirty(force?: boolean): void;
  68562. /** @hidden */
  68563. _markAllAsDirty(): void;
  68564. /** @hidden */
  68565. _link(host: AdvancedDynamicTexture): void;
  68566. /** @hidden */
  68567. protected _transform(context?: CanvasRenderingContext2D): void;
  68568. /** @hidden */
  68569. _renderHighlight(context: CanvasRenderingContext2D): void;
  68570. /** @hidden */
  68571. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  68572. /** @hidden */
  68573. protected _applyStates(context: CanvasRenderingContext2D): void;
  68574. /** @hidden */
  68575. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  68576. /** @hidden */
  68577. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  68578. protected _evaluateClippingState(parentMeasure: Measure): void;
  68579. /** @hidden */
  68580. _measure(): void;
  68581. /** @hidden */
  68582. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  68583. /** @hidden */
  68584. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  68585. /** @hidden */
  68586. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  68587. /** @hidden */
  68588. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  68589. private static _ClipMeasure;
  68590. private _tmpMeasureA;
  68591. private _clip;
  68592. /** @hidden */
  68593. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  68594. /** @hidden */
  68595. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  68596. /**
  68597. * Tests if a given coordinates belong to the current control
  68598. * @param x defines x coordinate to test
  68599. * @param y defines y coordinate to test
  68600. * @returns true if the coordinates are inside the control
  68601. */
  68602. contains(x: number, y: number): boolean;
  68603. /** @hidden */
  68604. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  68605. /** @hidden */
  68606. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  68607. /** @hidden */
  68608. _onPointerEnter(target: Control): boolean;
  68609. /** @hidden */
  68610. _onPointerOut(target: Control, force?: boolean): void;
  68611. /** @hidden */
  68612. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  68613. /** @hidden */
  68614. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  68615. /** @hidden */
  68616. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  68617. /** @hidden */
  68618. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number): boolean;
  68619. private _prepareFont;
  68620. /** Releases associated resources */
  68621. dispose(): void;
  68622. private static _HORIZONTAL_ALIGNMENT_LEFT;
  68623. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  68624. private static _HORIZONTAL_ALIGNMENT_CENTER;
  68625. private static _VERTICAL_ALIGNMENT_TOP;
  68626. private static _VERTICAL_ALIGNMENT_BOTTOM;
  68627. private static _VERTICAL_ALIGNMENT_CENTER;
  68628. /** HORIZONTAL_ALIGNMENT_LEFT */
  68629. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  68630. /** HORIZONTAL_ALIGNMENT_RIGHT */
  68631. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  68632. /** HORIZONTAL_ALIGNMENT_CENTER */
  68633. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  68634. /** VERTICAL_ALIGNMENT_TOP */
  68635. static get VERTICAL_ALIGNMENT_TOP(): number;
  68636. /** VERTICAL_ALIGNMENT_BOTTOM */
  68637. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  68638. /** VERTICAL_ALIGNMENT_CENTER */
  68639. static get VERTICAL_ALIGNMENT_CENTER(): number;
  68640. private static _FontHeightSizes;
  68641. /** @hidden */
  68642. static _GetFontOffset(font: string): {
  68643. ascent: number;
  68644. height: number;
  68645. descent: number;
  68646. };
  68647. /**
  68648. * Creates a stack panel that can be used to render headers
  68649. * @param control defines the control to associate with the header
  68650. * @param text defines the text of the header
  68651. * @param size defines the size of the header
  68652. * @param options defines options used to configure the header
  68653. * @returns a new StackPanel
  68654. * @ignore
  68655. * @hidden
  68656. */
  68657. static AddHeader: (control: Control, text: string, size: string | number, options: {
  68658. isHorizontal: boolean;
  68659. controlFirst: boolean;
  68660. }) => any;
  68661. /** @hidden */
  68662. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  68663. }
  68664. }
  68665. declare module BABYLON.GUI {
  68666. /**
  68667. * Root class for 2D containers
  68668. * @see http://doc.babylonjs.com/how_to/gui#containers
  68669. */
  68670. export class Container extends Control {
  68671. name?: string | undefined;
  68672. /** @hidden */
  68673. protected _children: Control[];
  68674. /** @hidden */
  68675. protected _measureForChildren: Measure;
  68676. /** @hidden */
  68677. protected _background: string;
  68678. /** @hidden */
  68679. protected _adaptWidthToChildren: boolean;
  68680. /** @hidden */
  68681. protected _adaptHeightToChildren: boolean;
  68682. /**
  68683. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  68684. */
  68685. logLayoutCycleErrors: boolean;
  68686. /**
  68687. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  68688. */
  68689. maxLayoutCycle: number;
  68690. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  68691. get adaptHeightToChildren(): boolean;
  68692. set adaptHeightToChildren(value: boolean);
  68693. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  68694. get adaptWidthToChildren(): boolean;
  68695. set adaptWidthToChildren(value: boolean);
  68696. /** Gets or sets background color */
  68697. get background(): string;
  68698. set background(value: string);
  68699. /** Gets the list of children */
  68700. get children(): Control[];
  68701. /**
  68702. * Creates a new Container
  68703. * @param name defines the name of the container
  68704. */
  68705. constructor(name?: string | undefined);
  68706. protected _getTypeName(): string;
  68707. _flagDescendantsAsMatrixDirty(): void;
  68708. /**
  68709. * Gets a child using its name
  68710. * @param name defines the child name to look for
  68711. * @returns the child control if found
  68712. */
  68713. getChildByName(name: string): BABYLON.Nullable<Control>;
  68714. /**
  68715. * Gets a child using its type and its name
  68716. * @param name defines the child name to look for
  68717. * @param type defines the child type to look for
  68718. * @returns the child control if found
  68719. */
  68720. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  68721. /**
  68722. * Search for a specific control in children
  68723. * @param control defines the control to look for
  68724. * @returns true if the control is in child list
  68725. */
  68726. containsControl(control: Control): boolean;
  68727. /**
  68728. * Adds a new control to the current container
  68729. * @param control defines the control to add
  68730. * @returns the current container
  68731. */
  68732. addControl(control: BABYLON.Nullable<Control>): Container;
  68733. /**
  68734. * Removes all controls from the current container
  68735. * @returns the current container
  68736. */
  68737. clearControls(): Container;
  68738. /**
  68739. * Removes a control from the current container
  68740. * @param control defines the control to remove
  68741. * @returns the current container
  68742. */
  68743. removeControl(control: Control): Container;
  68744. /** @hidden */
  68745. _reOrderControl(control: Control): void;
  68746. /** @hidden */
  68747. _offsetLeft(offset: number): void;
  68748. /** @hidden */
  68749. _offsetTop(offset: number): void;
  68750. /** @hidden */
  68751. _markAllAsDirty(): void;
  68752. /** @hidden */
  68753. protected _localDraw(context: CanvasRenderingContext2D): void;
  68754. /** @hidden */
  68755. _link(host: AdvancedDynamicTexture): void;
  68756. /** @hidden */
  68757. protected _beforeLayout(): void;
  68758. /** @hidden */
  68759. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  68760. /** @hidden */
  68761. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  68762. protected _postMeasure(): void;
  68763. /** @hidden */
  68764. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  68765. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  68766. /** @hidden */
  68767. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  68768. /** @hidden */
  68769. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  68770. /** Releases associated resources */
  68771. dispose(): void;
  68772. }
  68773. }
  68774. declare module BABYLON.GUI {
  68775. /** Class used to create rectangle container */
  68776. export class Rectangle extends Container {
  68777. name?: string | undefined;
  68778. private _thickness;
  68779. private _cornerRadius;
  68780. /** Gets or sets border thickness */
  68781. get thickness(): number;
  68782. set thickness(value: number);
  68783. /** Gets or sets the corner radius angle */
  68784. get cornerRadius(): number;
  68785. set cornerRadius(value: number);
  68786. /**
  68787. * Creates a new Rectangle
  68788. * @param name defines the control name
  68789. */
  68790. constructor(name?: string | undefined);
  68791. protected _getTypeName(): string;
  68792. protected _localDraw(context: CanvasRenderingContext2D): void;
  68793. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  68794. private _drawRoundedRect;
  68795. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  68796. }
  68797. }
  68798. declare module BABYLON.GUI {
  68799. /**
  68800. * Enum that determines the text-wrapping mode to use.
  68801. */
  68802. export enum TextWrapping {
  68803. /**
  68804. * Clip the text when it's larger than Control.width; this is the default mode.
  68805. */
  68806. Clip = 0,
  68807. /**
  68808. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  68809. */
  68810. WordWrap = 1,
  68811. /**
  68812. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  68813. */
  68814. Ellipsis = 2
  68815. }
  68816. /**
  68817. * Class used to create text block control
  68818. */
  68819. export class TextBlock extends Control {
  68820. /**
  68821. * Defines the name of the control
  68822. */
  68823. name?: string | undefined;
  68824. private _text;
  68825. private _textWrapping;
  68826. private _textHorizontalAlignment;
  68827. private _textVerticalAlignment;
  68828. private _lines;
  68829. private _resizeToFit;
  68830. private _lineSpacing;
  68831. private _outlineWidth;
  68832. private _outlineColor;
  68833. /**
  68834. * An event triggered after the text is changed
  68835. */
  68836. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  68837. /**
  68838. * An event triggered after the text was broken up into lines
  68839. */
  68840. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  68841. /**
  68842. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  68843. */
  68844. get lines(): any[];
  68845. /**
  68846. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  68847. */
  68848. get resizeToFit(): boolean;
  68849. /**
  68850. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  68851. */
  68852. set resizeToFit(value: boolean);
  68853. /**
  68854. * Gets or sets a boolean indicating if text must be wrapped
  68855. */
  68856. get textWrapping(): TextWrapping | boolean;
  68857. /**
  68858. * Gets or sets a boolean indicating if text must be wrapped
  68859. */
  68860. set textWrapping(value: TextWrapping | boolean);
  68861. /**
  68862. * Gets or sets text to display
  68863. */
  68864. get text(): string;
  68865. /**
  68866. * Gets or sets text to display
  68867. */
  68868. set text(value: string);
  68869. /**
  68870. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  68871. */
  68872. get textHorizontalAlignment(): number;
  68873. /**
  68874. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  68875. */
  68876. set textHorizontalAlignment(value: number);
  68877. /**
  68878. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  68879. */
  68880. get textVerticalAlignment(): number;
  68881. /**
  68882. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  68883. */
  68884. set textVerticalAlignment(value: number);
  68885. /**
  68886. * Gets or sets line spacing value
  68887. */
  68888. set lineSpacing(value: string | number);
  68889. /**
  68890. * Gets or sets line spacing value
  68891. */
  68892. get lineSpacing(): string | number;
  68893. /**
  68894. * Gets or sets outlineWidth of the text to display
  68895. */
  68896. get outlineWidth(): number;
  68897. /**
  68898. * Gets or sets outlineWidth of the text to display
  68899. */
  68900. set outlineWidth(value: number);
  68901. /**
  68902. * Gets or sets outlineColor of the text to display
  68903. */
  68904. get outlineColor(): string;
  68905. /**
  68906. * Gets or sets outlineColor of the text to display
  68907. */
  68908. set outlineColor(value: string);
  68909. /**
  68910. * Creates a new TextBlock object
  68911. * @param name defines the name of the control
  68912. * @param text defines the text to display (emptry string by default)
  68913. */
  68914. constructor(
  68915. /**
  68916. * Defines the name of the control
  68917. */
  68918. name?: string | undefined, text?: string);
  68919. protected _getTypeName(): string;
  68920. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  68921. private _drawText;
  68922. /** @hidden */
  68923. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  68924. protected _applyStates(context: CanvasRenderingContext2D): void;
  68925. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  68926. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  68927. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  68928. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  68929. protected _renderLines(context: CanvasRenderingContext2D): void;
  68930. /**
  68931. * Given a width constraint applied on the text block, find the expected height
  68932. * @returns expected height
  68933. */
  68934. computeExpectedHeight(): number;
  68935. dispose(): void;
  68936. }
  68937. }
  68938. declare module BABYLON.GUI {
  68939. /**
  68940. * Class used to create 2D images
  68941. */
  68942. export class Image extends Control {
  68943. name?: string | undefined;
  68944. private _workingCanvas;
  68945. private _domImage;
  68946. private _imageWidth;
  68947. private _imageHeight;
  68948. private _loaded;
  68949. private _stretch;
  68950. private _source;
  68951. private _autoScale;
  68952. private _sourceLeft;
  68953. private _sourceTop;
  68954. private _sourceWidth;
  68955. private _sourceHeight;
  68956. private _cellWidth;
  68957. private _cellHeight;
  68958. private _cellId;
  68959. private _populateNinePatchSlicesFromImage;
  68960. private _sliceLeft;
  68961. private _sliceRight;
  68962. private _sliceTop;
  68963. private _sliceBottom;
  68964. private _detectPointerOnOpaqueOnly;
  68965. /**
  68966. * BABYLON.Observable notified when the content is loaded
  68967. */
  68968. onImageLoadedObservable: BABYLON.Observable<Image>;
  68969. /**
  68970. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  68971. */
  68972. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  68973. /**
  68974. * Gets a boolean indicating that the content is loaded
  68975. */
  68976. get isLoaded(): boolean;
  68977. /**
  68978. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  68979. */
  68980. get populateNinePatchSlicesFromImage(): boolean;
  68981. set populateNinePatchSlicesFromImage(value: boolean);
  68982. /**
  68983. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  68984. * Beware using this as this will comsume more memory as the image has to be stored twice
  68985. */
  68986. get detectPointerOnOpaqueOnly(): boolean;
  68987. set detectPointerOnOpaqueOnly(value: boolean);
  68988. /**
  68989. * Gets or sets the left value for slicing (9-patch)
  68990. */
  68991. get sliceLeft(): number;
  68992. set sliceLeft(value: number);
  68993. /**
  68994. * Gets or sets the right value for slicing (9-patch)
  68995. */
  68996. get sliceRight(): number;
  68997. set sliceRight(value: number);
  68998. /**
  68999. * Gets or sets the top value for slicing (9-patch)
  69000. */
  69001. get sliceTop(): number;
  69002. set sliceTop(value: number);
  69003. /**
  69004. * Gets or sets the bottom value for slicing (9-patch)
  69005. */
  69006. get sliceBottom(): number;
  69007. set sliceBottom(value: number);
  69008. /**
  69009. * Gets or sets the left coordinate in the source image
  69010. */
  69011. get sourceLeft(): number;
  69012. set sourceLeft(value: number);
  69013. /**
  69014. * Gets or sets the top coordinate in the source image
  69015. */
  69016. get sourceTop(): number;
  69017. set sourceTop(value: number);
  69018. /**
  69019. * Gets or sets the width to capture in the source image
  69020. */
  69021. get sourceWidth(): number;
  69022. set sourceWidth(value: number);
  69023. /**
  69024. * Gets or sets the height to capture in the source image
  69025. */
  69026. get sourceHeight(): number;
  69027. set sourceHeight(value: number);
  69028. /**
  69029. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  69030. * @see http://doc.babylonjs.com/how_to/gui#image
  69031. */
  69032. get autoScale(): boolean;
  69033. set autoScale(value: boolean);
  69034. /** Gets or sets the streching mode used by the image */
  69035. get stretch(): number;
  69036. set stretch(value: number);
  69037. /** @hidden */
  69038. _rotate90(n: number): Image;
  69039. /**
  69040. * Gets or sets the internal DOM image used to render the control
  69041. */
  69042. set domImage(value: HTMLImageElement);
  69043. get domImage(): HTMLImageElement;
  69044. private _onImageLoaded;
  69045. private _extractNinePatchSliceDataFromImage;
  69046. /**
  69047. * Gets or sets image source url
  69048. */
  69049. set source(value: BABYLON.Nullable<string>);
  69050. /**
  69051. * Checks for svg document with icon id present
  69052. */
  69053. private _svgCheck;
  69054. /**
  69055. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  69056. * given external svg file and icon id
  69057. */
  69058. private _getSVGAttribs;
  69059. /**
  69060. * Gets or sets the cell width to use when animation sheet is enabled
  69061. * @see http://doc.babylonjs.com/how_to/gui#image
  69062. */
  69063. get cellWidth(): number;
  69064. set cellWidth(value: number);
  69065. /**
  69066. * Gets or sets the cell height to use when animation sheet is enabled
  69067. * @see http://doc.babylonjs.com/how_to/gui#image
  69068. */
  69069. get cellHeight(): number;
  69070. set cellHeight(value: number);
  69071. /**
  69072. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  69073. * @see http://doc.babylonjs.com/how_to/gui#image
  69074. */
  69075. get cellId(): number;
  69076. set cellId(value: number);
  69077. /**
  69078. * Creates a new Image
  69079. * @param name defines the control name
  69080. * @param url defines the image url
  69081. */
  69082. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  69083. /**
  69084. * Tests if a given coordinates belong to the current control
  69085. * @param x defines x coordinate to test
  69086. * @param y defines y coordinate to test
  69087. * @returns true if the coordinates are inside the control
  69088. */
  69089. contains(x: number, y: number): boolean;
  69090. protected _getTypeName(): string;
  69091. /** Force the control to synchronize with its content */
  69092. synchronizeSizeWithContent(): void;
  69093. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  69094. private _prepareWorkingCanvasForOpaqueDetection;
  69095. private _drawImage;
  69096. _draw(context: CanvasRenderingContext2D): void;
  69097. private _renderCornerPatch;
  69098. private _renderNinePatch;
  69099. dispose(): void;
  69100. /** STRETCH_NONE */
  69101. static readonly STRETCH_NONE: number;
  69102. /** STRETCH_FILL */
  69103. static readonly STRETCH_FILL: number;
  69104. /** STRETCH_UNIFORM */
  69105. static readonly STRETCH_UNIFORM: number;
  69106. /** STRETCH_EXTEND */
  69107. static readonly STRETCH_EXTEND: number;
  69108. /** NINE_PATCH */
  69109. static readonly STRETCH_NINE_PATCH: number;
  69110. }
  69111. }
  69112. declare module BABYLON.GUI {
  69113. /**
  69114. * Class used to create 2D buttons
  69115. */
  69116. export class Button extends Rectangle {
  69117. name?: string | undefined;
  69118. /**
  69119. * Function called to generate a pointer enter animation
  69120. */
  69121. pointerEnterAnimation: () => void;
  69122. /**
  69123. * Function called to generate a pointer out animation
  69124. */
  69125. pointerOutAnimation: () => void;
  69126. /**
  69127. * Function called to generate a pointer down animation
  69128. */
  69129. pointerDownAnimation: () => void;
  69130. /**
  69131. * Function called to generate a pointer up animation
  69132. */
  69133. pointerUpAnimation: () => void;
  69134. /**
  69135. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  69136. */
  69137. delegatePickingToChildren: boolean;
  69138. private _image;
  69139. /**
  69140. * Returns the image part of the button (if any)
  69141. */
  69142. get image(): BABYLON.Nullable<Image>;
  69143. private _textBlock;
  69144. /**
  69145. * Returns the image part of the button (if any)
  69146. */
  69147. get textBlock(): BABYLON.Nullable<TextBlock>;
  69148. /**
  69149. * Creates a new Button
  69150. * @param name defines the name of the button
  69151. */
  69152. constructor(name?: string | undefined);
  69153. protected _getTypeName(): string;
  69154. /** @hidden */
  69155. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  69156. /** @hidden */
  69157. _onPointerEnter(target: Control): boolean;
  69158. /** @hidden */
  69159. _onPointerOut(target: Control, force?: boolean): void;
  69160. /** @hidden */
  69161. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  69162. /** @hidden */
  69163. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  69164. /**
  69165. * Creates a new button made with an image and a text
  69166. * @param name defines the name of the button
  69167. * @param text defines the text of the button
  69168. * @param imageUrl defines the url of the image
  69169. * @returns a new Button
  69170. */
  69171. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  69172. /**
  69173. * Creates a new button made with an image
  69174. * @param name defines the name of the button
  69175. * @param imageUrl defines the url of the image
  69176. * @returns a new Button
  69177. */
  69178. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  69179. /**
  69180. * Creates a new button made with a text
  69181. * @param name defines the name of the button
  69182. * @param text defines the text of the button
  69183. * @returns a new Button
  69184. */
  69185. static CreateSimpleButton(name: string, text: string): Button;
  69186. /**
  69187. * Creates a new button made with an image and a centered text
  69188. * @param name defines the name of the button
  69189. * @param text defines the text of the button
  69190. * @param imageUrl defines the url of the image
  69191. * @returns a new Button
  69192. */
  69193. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  69194. }
  69195. }
  69196. declare module BABYLON.GUI {
  69197. /**
  69198. * Class used to create a 2D stack panel container
  69199. */
  69200. export class StackPanel extends Container {
  69201. name?: string | undefined;
  69202. private _isVertical;
  69203. private _manualWidth;
  69204. private _manualHeight;
  69205. private _doNotTrackManualChanges;
  69206. /**
  69207. * Gets or sets a boolean indicating that layou warnings should be ignored
  69208. */
  69209. ignoreLayoutWarnings: boolean;
  69210. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  69211. get isVertical(): boolean;
  69212. set isVertical(value: boolean);
  69213. /**
  69214. * Gets or sets panel width.
  69215. * This value should not be set when in horizontal mode as it will be computed automatically
  69216. */
  69217. set width(value: string | number);
  69218. get width(): string | number;
  69219. /**
  69220. * Gets or sets panel height.
  69221. * This value should not be set when in vertical mode as it will be computed automatically
  69222. */
  69223. set height(value: string | number);
  69224. get height(): string | number;
  69225. /**
  69226. * Creates a new StackPanel
  69227. * @param name defines control name
  69228. */
  69229. constructor(name?: string | undefined);
  69230. protected _getTypeName(): string;
  69231. /** @hidden */
  69232. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  69233. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  69234. protected _postMeasure(): void;
  69235. }
  69236. }
  69237. declare module BABYLON.GUI {
  69238. /**
  69239. * Class used to represent a 2D checkbox
  69240. */
  69241. export class Checkbox extends Control {
  69242. name?: string | undefined;
  69243. private _isChecked;
  69244. private _background;
  69245. private _checkSizeRatio;
  69246. private _thickness;
  69247. /** Gets or sets border thickness */
  69248. get thickness(): number;
  69249. set thickness(value: number);
  69250. /**
  69251. * BABYLON.Observable raised when isChecked property changes
  69252. */
  69253. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  69254. /** Gets or sets a value indicating the ratio between overall size and check size */
  69255. get checkSizeRatio(): number;
  69256. set checkSizeRatio(value: number);
  69257. /** Gets or sets background color */
  69258. get background(): string;
  69259. set background(value: string);
  69260. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  69261. get isChecked(): boolean;
  69262. set isChecked(value: boolean);
  69263. /**
  69264. * Creates a new CheckBox
  69265. * @param name defines the control name
  69266. */
  69267. constructor(name?: string | undefined);
  69268. protected _getTypeName(): string;
  69269. /** @hidden */
  69270. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  69271. /** @hidden */
  69272. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  69273. /**
  69274. * Utility function to easily create a checkbox with a header
  69275. * @param title defines the label to use for the header
  69276. * @param onValueChanged defines the callback to call when value changes
  69277. * @returns a StackPanel containing the checkbox and a textBlock
  69278. */
  69279. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  69280. }
  69281. }
  69282. declare module BABYLON.GUI {
  69283. /**
  69284. * Class used to store key control properties
  69285. */
  69286. export class KeyPropertySet {
  69287. /** Width */
  69288. width?: string;
  69289. /** Height */
  69290. height?: string;
  69291. /** Left padding */
  69292. paddingLeft?: string;
  69293. /** Right padding */
  69294. paddingRight?: string;
  69295. /** Top padding */
  69296. paddingTop?: string;
  69297. /** Bottom padding */
  69298. paddingBottom?: string;
  69299. /** Foreground color */
  69300. color?: string;
  69301. /** Background color */
  69302. background?: string;
  69303. }
  69304. /**
  69305. * Class used to create virtual keyboard
  69306. */
  69307. export class VirtualKeyboard extends StackPanel {
  69308. /** BABYLON.Observable raised when a key is pressed */
  69309. onKeyPressObservable: BABYLON.Observable<string>;
  69310. /** Gets or sets default key button width */
  69311. defaultButtonWidth: string;
  69312. /** Gets or sets default key button height */
  69313. defaultButtonHeight: string;
  69314. /** Gets or sets default key button left padding */
  69315. defaultButtonPaddingLeft: string;
  69316. /** Gets or sets default key button right padding */
  69317. defaultButtonPaddingRight: string;
  69318. /** Gets or sets default key button top padding */
  69319. defaultButtonPaddingTop: string;
  69320. /** Gets or sets default key button bottom padding */
  69321. defaultButtonPaddingBottom: string;
  69322. /** Gets or sets default key button foreground color */
  69323. defaultButtonColor: string;
  69324. /** Gets or sets default key button background color */
  69325. defaultButtonBackground: string;
  69326. /** Gets or sets shift button foreground color */
  69327. shiftButtonColor: string;
  69328. /** Gets or sets shift button thickness*/
  69329. selectedShiftThickness: number;
  69330. /** Gets shift key state */
  69331. shiftState: number;
  69332. protected _getTypeName(): string;
  69333. private _createKey;
  69334. /**
  69335. * Adds a new row of keys
  69336. * @param keys defines the list of keys to add
  69337. * @param propertySets defines the associated property sets
  69338. */
  69339. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  69340. /**
  69341. * Set the shift key to a specific state
  69342. * @param shiftState defines the new shift state
  69343. */
  69344. applyShiftState(shiftState: number): void;
  69345. private _currentlyConnectedInputText;
  69346. private _connectedInputTexts;
  69347. private _onKeyPressObserver;
  69348. /** Gets the input text control currently attached to the keyboard */
  69349. get connectedInputText(): BABYLON.Nullable<InputText>;
  69350. /**
  69351. * Connects the keyboard with an input text control
  69352. *
  69353. * @param input defines the target control
  69354. */
  69355. connect(input: InputText): void;
  69356. /**
  69357. * Disconnects the keyboard from connected InputText controls
  69358. *
  69359. * @param input optionally defines a target control, otherwise all are disconnected
  69360. */
  69361. disconnect(input?: InputText): void;
  69362. private _removeConnectedInputObservables;
  69363. /**
  69364. * Release all resources
  69365. */
  69366. dispose(): void;
  69367. /**
  69368. * Creates a new keyboard using a default layout
  69369. *
  69370. * @param name defines control name
  69371. * @returns a new VirtualKeyboard
  69372. */
  69373. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  69374. }
  69375. }
  69376. declare module BABYLON.GUI {
  69377. /**
  69378. * Class used to create input text control
  69379. */
  69380. export class InputText extends Control implements IFocusableControl {
  69381. name?: string | undefined;
  69382. private _text;
  69383. private _placeholderText;
  69384. private _background;
  69385. private _focusedBackground;
  69386. private _focusedColor;
  69387. private _placeholderColor;
  69388. private _thickness;
  69389. private _margin;
  69390. private _autoStretchWidth;
  69391. private _maxWidth;
  69392. private _isFocused;
  69393. private _blinkTimeout;
  69394. private _blinkIsEven;
  69395. private _cursorOffset;
  69396. private _scrollLeft;
  69397. private _textWidth;
  69398. private _clickedCoordinate;
  69399. private _deadKey;
  69400. private _addKey;
  69401. private _currentKey;
  69402. private _isTextHighlightOn;
  69403. private _textHighlightColor;
  69404. private _highligherOpacity;
  69405. private _highlightedText;
  69406. private _startHighlightIndex;
  69407. private _endHighlightIndex;
  69408. private _cursorIndex;
  69409. private _onFocusSelectAll;
  69410. private _isPointerDown;
  69411. private _onClipboardObserver;
  69412. private _onPointerDblTapObserver;
  69413. /** @hidden */
  69414. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  69415. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  69416. promptMessage: string;
  69417. /** Force disable prompt on mobile device */
  69418. disableMobilePrompt: boolean;
  69419. /** BABYLON.Observable raised when the text changes */
  69420. onTextChangedObservable: BABYLON.Observable<InputText>;
  69421. /** BABYLON.Observable raised just before an entered character is to be added */
  69422. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  69423. /** BABYLON.Observable raised when the control gets the focus */
  69424. onFocusObservable: BABYLON.Observable<InputText>;
  69425. /** BABYLON.Observable raised when the control loses the focus */
  69426. onBlurObservable: BABYLON.Observable<InputText>;
  69427. /**Observable raised when the text is highlighted */
  69428. onTextHighlightObservable: BABYLON.Observable<InputText>;
  69429. /**Observable raised when copy event is triggered */
  69430. onTextCopyObservable: BABYLON.Observable<InputText>;
  69431. /** BABYLON.Observable raised when cut event is triggered */
  69432. onTextCutObservable: BABYLON.Observable<InputText>;
  69433. /** BABYLON.Observable raised when paste event is triggered */
  69434. onTextPasteObservable: BABYLON.Observable<InputText>;
  69435. /** BABYLON.Observable raised when a key event was processed */
  69436. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  69437. /** Gets or sets the maximum width allowed by the control */
  69438. get maxWidth(): string | number;
  69439. /** Gets the maximum width allowed by the control in pixels */
  69440. get maxWidthInPixels(): number;
  69441. set maxWidth(value: string | number);
  69442. /** Gets or sets the text highlighter transparency; default: 0.4 */
  69443. get highligherOpacity(): number;
  69444. set highligherOpacity(value: number);
  69445. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  69446. get onFocusSelectAll(): boolean;
  69447. set onFocusSelectAll(value: boolean);
  69448. /** Gets or sets the text hightlight color */
  69449. get textHighlightColor(): string;
  69450. set textHighlightColor(value: string);
  69451. /** Gets or sets control margin */
  69452. get margin(): string;
  69453. /** Gets control margin in pixels */
  69454. get marginInPixels(): number;
  69455. set margin(value: string);
  69456. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  69457. get autoStretchWidth(): boolean;
  69458. set autoStretchWidth(value: boolean);
  69459. /** Gets or sets border thickness */
  69460. get thickness(): number;
  69461. set thickness(value: number);
  69462. /** Gets or sets the background color when focused */
  69463. get focusedBackground(): string;
  69464. set focusedBackground(value: string);
  69465. /** Gets or sets the background color when focused */
  69466. get focusedColor(): string;
  69467. set focusedColor(value: string);
  69468. /** Gets or sets the background color */
  69469. get background(): string;
  69470. set background(value: string);
  69471. /** Gets or sets the placeholder color */
  69472. get placeholderColor(): string;
  69473. set placeholderColor(value: string);
  69474. /** Gets or sets the text displayed when the control is empty */
  69475. get placeholderText(): string;
  69476. set placeholderText(value: string);
  69477. /** Gets or sets the dead key flag */
  69478. get deadKey(): boolean;
  69479. set deadKey(flag: boolean);
  69480. /** Gets or sets the highlight text */
  69481. get highlightedText(): string;
  69482. set highlightedText(text: string);
  69483. /** Gets or sets if the current key should be added */
  69484. get addKey(): boolean;
  69485. set addKey(flag: boolean);
  69486. /** Gets or sets the value of the current key being entered */
  69487. get currentKey(): string;
  69488. set currentKey(key: string);
  69489. /** Gets or sets the text displayed in the control */
  69490. get text(): string;
  69491. set text(value: string);
  69492. /** Gets or sets control width */
  69493. get width(): string | number;
  69494. set width(value: string | number);
  69495. /**
  69496. * Creates a new InputText
  69497. * @param name defines the control name
  69498. * @param text defines the text of the control
  69499. */
  69500. constructor(name?: string | undefined, text?: string);
  69501. /** @hidden */
  69502. onBlur(): void;
  69503. /** @hidden */
  69504. onFocus(): void;
  69505. protected _getTypeName(): string;
  69506. /**
  69507. * Function called to get the list of controls that should not steal the focus from this control
  69508. * @returns an array of controls
  69509. */
  69510. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  69511. /** @hidden */
  69512. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  69513. /** @hidden */
  69514. private _updateValueFromCursorIndex;
  69515. /** @hidden */
  69516. private _processDblClick;
  69517. /** @hidden */
  69518. private _selectAllText;
  69519. /**
  69520. * Handles the keyboard event
  69521. * @param evt Defines the KeyboardEvent
  69522. */
  69523. processKeyboard(evt: KeyboardEvent): void;
  69524. /** @hidden */
  69525. private _onCopyText;
  69526. /** @hidden */
  69527. private _onCutText;
  69528. /** @hidden */
  69529. private _onPasteText;
  69530. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  69531. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  69532. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  69533. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  69534. protected _beforeRenderText(text: string): string;
  69535. dispose(): void;
  69536. }
  69537. }
  69538. declare module BABYLON.GUI {
  69539. /**
  69540. * Class used to create a 2D grid container
  69541. */
  69542. export class Grid extends Container {
  69543. name?: string | undefined;
  69544. private _rowDefinitions;
  69545. private _columnDefinitions;
  69546. private _cells;
  69547. private _childControls;
  69548. /**
  69549. * Gets the number of columns
  69550. */
  69551. get columnCount(): number;
  69552. /**
  69553. * Gets the number of rows
  69554. */
  69555. get rowCount(): number;
  69556. /** Gets the list of children */
  69557. get children(): Control[];
  69558. /** Gets the list of cells (e.g. the containers) */
  69559. get cells(): {
  69560. [key: string]: Container;
  69561. };
  69562. /**
  69563. * Gets the definition of a specific row
  69564. * @param index defines the index of the row
  69565. * @returns the row definition
  69566. */
  69567. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  69568. /**
  69569. * Gets the definition of a specific column
  69570. * @param index defines the index of the column
  69571. * @returns the column definition
  69572. */
  69573. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  69574. /**
  69575. * Adds a new row to the grid
  69576. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  69577. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  69578. * @returns the current grid
  69579. */
  69580. addRowDefinition(height: number, isPixel?: boolean): Grid;
  69581. /**
  69582. * Adds a new column to the grid
  69583. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  69584. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  69585. * @returns the current grid
  69586. */
  69587. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  69588. /**
  69589. * Update a row definition
  69590. * @param index defines the index of the row to update
  69591. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  69592. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  69593. * @returns the current grid
  69594. */
  69595. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  69596. /**
  69597. * Update a column definition
  69598. * @param index defines the index of the column to update
  69599. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  69600. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  69601. * @returns the current grid
  69602. */
  69603. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  69604. /**
  69605. * Gets the list of children stored in a specific cell
  69606. * @param row defines the row to check
  69607. * @param column defines the column to check
  69608. * @returns the list of controls
  69609. */
  69610. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  69611. /**
  69612. * Gets a string representing the child cell info (row x column)
  69613. * @param child defines the control to get info from
  69614. * @returns a string containing the child cell info (row x column)
  69615. */
  69616. getChildCellInfo(child: Control): string;
  69617. private _removeCell;
  69618. private _offsetCell;
  69619. /**
  69620. * Remove a column definition at specified index
  69621. * @param index defines the index of the column to remove
  69622. * @returns the current grid
  69623. */
  69624. removeColumnDefinition(index: number): Grid;
  69625. /**
  69626. * Remove a row definition at specified index
  69627. * @param index defines the index of the row to remove
  69628. * @returns the current grid
  69629. */
  69630. removeRowDefinition(index: number): Grid;
  69631. /**
  69632. * Adds a new control to the current grid
  69633. * @param control defines the control to add
  69634. * @param row defines the row where to add the control (0 by default)
  69635. * @param column defines the column where to add the control (0 by default)
  69636. * @returns the current grid
  69637. */
  69638. addControl(control: Control, row?: number, column?: number): Grid;
  69639. /**
  69640. * Removes a control from the current container
  69641. * @param control defines the control to remove
  69642. * @returns the current container
  69643. */
  69644. removeControl(control: Control): Container;
  69645. /**
  69646. * Creates a new Grid
  69647. * @param name defines control name
  69648. */
  69649. constructor(name?: string | undefined);
  69650. protected _getTypeName(): string;
  69651. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  69652. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  69653. _flagDescendantsAsMatrixDirty(): void;
  69654. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  69655. /** Releases associated resources */
  69656. dispose(): void;
  69657. }
  69658. }
  69659. declare module BABYLON.GUI {
  69660. /** Class used to create color pickers */
  69661. export class ColorPicker extends Control {
  69662. name?: string | undefined;
  69663. private static _Epsilon;
  69664. private _colorWheelCanvas;
  69665. private _value;
  69666. private _tmpColor;
  69667. private _pointerStartedOnSquare;
  69668. private _pointerStartedOnWheel;
  69669. private _squareLeft;
  69670. private _squareTop;
  69671. private _squareSize;
  69672. private _h;
  69673. private _s;
  69674. private _v;
  69675. private _lastPointerDownID;
  69676. /**
  69677. * BABYLON.Observable raised when the value changes
  69678. */
  69679. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  69680. /** Gets or sets the color of the color picker */
  69681. get value(): BABYLON.Color3;
  69682. set value(value: BABYLON.Color3);
  69683. /**
  69684. * Gets or sets control width
  69685. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  69686. */
  69687. get width(): string | number;
  69688. set width(value: string | number);
  69689. /**
  69690. * Gets or sets control height
  69691. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  69692. */
  69693. get height(): string | number;
  69694. /** Gets or sets control height */
  69695. set height(value: string | number);
  69696. /** Gets or sets control size */
  69697. get size(): string | number;
  69698. set size(value: string | number);
  69699. /**
  69700. * Creates a new ColorPicker
  69701. * @param name defines the control name
  69702. */
  69703. constructor(name?: string | undefined);
  69704. protected _getTypeName(): string;
  69705. /** @hidden */
  69706. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  69707. private _updateSquareProps;
  69708. private _drawGradientSquare;
  69709. private _drawCircle;
  69710. private _createColorWheelCanvas;
  69711. /** @hidden */
  69712. _draw(context: CanvasRenderingContext2D): void;
  69713. private _pointerIsDown;
  69714. private _updateValueFromPointer;
  69715. private _isPointOnSquare;
  69716. private _isPointOnWheel;
  69717. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  69718. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  69719. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  69720. /**
  69721. * This function expands the color picker by creating a color picker dialog with manual
  69722. * color value input and the ability to save colors into an array to be used later in
  69723. * subsequent launches of the dialogue.
  69724. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  69725. * @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.
  69726. * @returns picked color as a hex string and the saved colors array as hex strings.
  69727. */
  69728. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  69729. pickerWidth?: string;
  69730. pickerHeight?: string;
  69731. headerHeight?: string;
  69732. lastColor?: string;
  69733. swatchLimit?: number;
  69734. numSwatchesPerLine?: number;
  69735. savedColors?: Array<string>;
  69736. }): Promise<{
  69737. savedColors?: string[];
  69738. pickedColor: string;
  69739. }>;
  69740. }
  69741. }
  69742. declare module BABYLON.GUI {
  69743. /** Class used to create 2D ellipse containers */
  69744. export class Ellipse extends Container {
  69745. name?: string | undefined;
  69746. private _thickness;
  69747. /** Gets or sets border thickness */
  69748. get thickness(): number;
  69749. set thickness(value: number);
  69750. /**
  69751. * Creates a new Ellipse
  69752. * @param name defines the control name
  69753. */
  69754. constructor(name?: string | undefined);
  69755. protected _getTypeName(): string;
  69756. protected _localDraw(context: CanvasRenderingContext2D): void;
  69757. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  69758. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  69759. }
  69760. }
  69761. declare module BABYLON.GUI {
  69762. /**
  69763. * Class used to create a password control
  69764. */
  69765. export class InputPassword extends InputText {
  69766. protected _beforeRenderText(text: string): string;
  69767. }
  69768. }
  69769. declare module BABYLON.GUI {
  69770. /** Class used to render 2D lines */
  69771. export class Line extends Control {
  69772. name?: string | undefined;
  69773. private _lineWidth;
  69774. private _x1;
  69775. private _y1;
  69776. private _x2;
  69777. private _y2;
  69778. private _dash;
  69779. private _connectedControl;
  69780. private _connectedControlDirtyObserver;
  69781. /** Gets or sets the dash pattern */
  69782. get dash(): Array<number>;
  69783. set dash(value: Array<number>);
  69784. /** Gets or sets the control connected with the line end */
  69785. get connectedControl(): Control;
  69786. set connectedControl(value: Control);
  69787. /** Gets or sets start coordinates on X axis */
  69788. get x1(): string | number;
  69789. set x1(value: string | number);
  69790. /** Gets or sets start coordinates on Y axis */
  69791. get y1(): string | number;
  69792. set y1(value: string | number);
  69793. /** Gets or sets end coordinates on X axis */
  69794. get x2(): string | number;
  69795. set x2(value: string | number);
  69796. /** Gets or sets end coordinates on Y axis */
  69797. get y2(): string | number;
  69798. set y2(value: string | number);
  69799. /** Gets or sets line width */
  69800. get lineWidth(): number;
  69801. set lineWidth(value: number);
  69802. /** Gets or sets horizontal alignment */
  69803. set horizontalAlignment(value: number);
  69804. /** Gets or sets vertical alignment */
  69805. set verticalAlignment(value: number);
  69806. private get _effectiveX2();
  69807. private get _effectiveY2();
  69808. /**
  69809. * Creates a new Line
  69810. * @param name defines the control name
  69811. */
  69812. constructor(name?: string | undefined);
  69813. protected _getTypeName(): string;
  69814. _draw(context: CanvasRenderingContext2D): void;
  69815. _measure(): void;
  69816. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  69817. /**
  69818. * Move one end of the line given 3D cartesian coordinates.
  69819. * @param position Targeted world position
  69820. * @param scene BABYLON.Scene
  69821. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  69822. */
  69823. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  69824. /**
  69825. * Move one end of the line to a position in screen absolute space.
  69826. * @param projectedPosition Position in screen absolute space (X, Y)
  69827. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  69828. */
  69829. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  69830. }
  69831. }
  69832. declare module BABYLON.GUI {
  69833. /**
  69834. * Class used to store a point for a MultiLine object.
  69835. * The point can be pure 2D coordinates, a mesh or a control
  69836. */
  69837. export class MultiLinePoint {
  69838. private _multiLine;
  69839. private _x;
  69840. private _y;
  69841. private _control;
  69842. private _mesh;
  69843. private _controlObserver;
  69844. private _meshObserver;
  69845. /** @hidden */
  69846. _point: BABYLON.Vector2;
  69847. /**
  69848. * Creates a new MultiLinePoint
  69849. * @param multiLine defines the source MultiLine object
  69850. */
  69851. constructor(multiLine: MultiLine);
  69852. /** Gets or sets x coordinate */
  69853. get x(): string | number;
  69854. set x(value: string | number);
  69855. /** Gets or sets y coordinate */
  69856. get y(): string | number;
  69857. set y(value: string | number);
  69858. /** Gets or sets the control associated with this point */
  69859. get control(): BABYLON.Nullable<Control>;
  69860. set control(value: BABYLON.Nullable<Control>);
  69861. /** Gets or sets the mesh associated with this point */
  69862. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  69863. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  69864. /** Resets links */
  69865. resetLinks(): void;
  69866. /**
  69867. * Gets a translation vector
  69868. * @returns the translation vector
  69869. */
  69870. translate(): BABYLON.Vector2;
  69871. private _translatePoint;
  69872. /** Release associated resources */
  69873. dispose(): void;
  69874. }
  69875. }
  69876. declare module BABYLON.GUI {
  69877. /**
  69878. * Class used to create multi line control
  69879. */
  69880. export class MultiLine extends Control {
  69881. name?: string | undefined;
  69882. private _lineWidth;
  69883. private _dash;
  69884. private _points;
  69885. private _minX;
  69886. private _minY;
  69887. private _maxX;
  69888. private _maxY;
  69889. /**
  69890. * Creates a new MultiLine
  69891. * @param name defines the control name
  69892. */
  69893. constructor(name?: string | undefined);
  69894. /** Gets or sets dash pattern */
  69895. get dash(): Array<number>;
  69896. set dash(value: Array<number>);
  69897. /**
  69898. * Gets point stored at specified index
  69899. * @param index defines the index to look for
  69900. * @returns the requested point if found
  69901. */
  69902. getAt(index: number): MultiLinePoint;
  69903. /** Function called when a point is updated */
  69904. onPointUpdate: () => void;
  69905. /**
  69906. * Adds new points to the point collection
  69907. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  69908. * @returns the list of created MultiLinePoint
  69909. */
  69910. add(...items: (AbstractMesh | Control | {
  69911. x: string | number;
  69912. y: string | number;
  69913. })[]): MultiLinePoint[];
  69914. /**
  69915. * Adds a new point to the point collection
  69916. * @param item defines the item (mesh, control or 2d coordiantes) to add
  69917. * @returns the created MultiLinePoint
  69918. */
  69919. push(item?: (AbstractMesh | Control | {
  69920. x: string | number;
  69921. y: string | number;
  69922. })): MultiLinePoint;
  69923. /**
  69924. * Remove a specific value or point from the active point collection
  69925. * @param value defines the value or point to remove
  69926. */
  69927. remove(value: number | MultiLinePoint): void;
  69928. /**
  69929. * Resets this object to initial state (no point)
  69930. */
  69931. reset(): void;
  69932. /**
  69933. * Resets all links
  69934. */
  69935. resetLinks(): void;
  69936. /** Gets or sets line width */
  69937. get lineWidth(): number;
  69938. set lineWidth(value: number);
  69939. set horizontalAlignment(value: number);
  69940. set verticalAlignment(value: number);
  69941. protected _getTypeName(): string;
  69942. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  69943. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  69944. _measure(): void;
  69945. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  69946. dispose(): void;
  69947. }
  69948. }
  69949. declare module BABYLON.GUI {
  69950. /**
  69951. * Class used to create radio button controls
  69952. */
  69953. export class RadioButton extends Control {
  69954. name?: string | undefined;
  69955. private _isChecked;
  69956. private _background;
  69957. private _checkSizeRatio;
  69958. private _thickness;
  69959. /** Gets or sets border thickness */
  69960. get thickness(): number;
  69961. set thickness(value: number);
  69962. /** Gets or sets group name */
  69963. group: string;
  69964. /** BABYLON.Observable raised when isChecked is changed */
  69965. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  69966. /** Gets or sets a value indicating the ratio between overall size and check size */
  69967. get checkSizeRatio(): number;
  69968. set checkSizeRatio(value: number);
  69969. /** Gets or sets background color */
  69970. get background(): string;
  69971. set background(value: string);
  69972. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  69973. get isChecked(): boolean;
  69974. set isChecked(value: boolean);
  69975. /**
  69976. * Creates a new RadioButton
  69977. * @param name defines the control name
  69978. */
  69979. constructor(name?: string | undefined);
  69980. protected _getTypeName(): string;
  69981. _draw(context: CanvasRenderingContext2D): void;
  69982. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  69983. /**
  69984. * Utility function to easily create a radio button with a header
  69985. * @param title defines the label to use for the header
  69986. * @param group defines the group to use for the radio button
  69987. * @param isChecked defines the initial state of the radio button
  69988. * @param onValueChanged defines the callback to call when value changes
  69989. * @returns a StackPanel containing the radio button and a textBlock
  69990. */
  69991. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  69992. }
  69993. }
  69994. declare module BABYLON.GUI {
  69995. /**
  69996. * Class used to create slider controls
  69997. */
  69998. export class BaseSlider extends Control {
  69999. name?: string | undefined;
  70000. protected _thumbWidth: ValueAndUnit;
  70001. private _minimum;
  70002. private _maximum;
  70003. private _value;
  70004. private _isVertical;
  70005. protected _barOffset: ValueAndUnit;
  70006. private _isThumbClamped;
  70007. protected _displayThumb: boolean;
  70008. private _step;
  70009. private _lastPointerDownID;
  70010. protected _effectiveBarOffset: number;
  70011. protected _renderLeft: number;
  70012. protected _renderTop: number;
  70013. protected _renderWidth: number;
  70014. protected _renderHeight: number;
  70015. protected _backgroundBoxLength: number;
  70016. protected _backgroundBoxThickness: number;
  70017. protected _effectiveThumbThickness: number;
  70018. /** BABYLON.Observable raised when the sldier value changes */
  70019. onValueChangedObservable: BABYLON.Observable<number>;
  70020. /** Gets or sets a boolean indicating if the thumb must be rendered */
  70021. get displayThumb(): boolean;
  70022. set displayThumb(value: boolean);
  70023. /** Gets or sets a step to apply to values (0 by default) */
  70024. get step(): number;
  70025. set step(value: number);
  70026. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  70027. get barOffset(): string | number;
  70028. /** Gets main bar offset in pixels*/
  70029. get barOffsetInPixels(): number;
  70030. set barOffset(value: string | number);
  70031. /** Gets or sets thumb width */
  70032. get thumbWidth(): string | number;
  70033. /** Gets thumb width in pixels */
  70034. get thumbWidthInPixels(): number;
  70035. set thumbWidth(value: string | number);
  70036. /** Gets or sets minimum value */
  70037. get minimum(): number;
  70038. set minimum(value: number);
  70039. /** Gets or sets maximum value */
  70040. get maximum(): number;
  70041. set maximum(value: number);
  70042. /** Gets or sets current value */
  70043. get value(): number;
  70044. set value(value: number);
  70045. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  70046. get isVertical(): boolean;
  70047. set isVertical(value: boolean);
  70048. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  70049. get isThumbClamped(): boolean;
  70050. set isThumbClamped(value: boolean);
  70051. /**
  70052. * Creates a new BaseSlider
  70053. * @param name defines the control name
  70054. */
  70055. constructor(name?: string | undefined);
  70056. protected _getTypeName(): string;
  70057. protected _getThumbPosition(): number;
  70058. protected _getThumbThickness(type: string): number;
  70059. protected _prepareRenderingData(type: string): void;
  70060. private _pointerIsDown;
  70061. /** @hidden */
  70062. protected _updateValueFromPointer(x: number, y: number): void;
  70063. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  70064. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  70065. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  70066. }
  70067. }
  70068. declare module BABYLON.GUI {
  70069. /**
  70070. * Class used to create slider controls
  70071. */
  70072. export class Slider extends BaseSlider {
  70073. name?: string | undefined;
  70074. private _background;
  70075. private _borderColor;
  70076. private _isThumbCircle;
  70077. protected _displayValueBar: boolean;
  70078. /** Gets or sets a boolean indicating if the value bar must be rendered */
  70079. get displayValueBar(): boolean;
  70080. set displayValueBar(value: boolean);
  70081. /** Gets or sets border color */
  70082. get borderColor(): string;
  70083. set borderColor(value: string);
  70084. /** Gets or sets background color */
  70085. get background(): string;
  70086. set background(value: string);
  70087. /** Gets or sets a boolean indicating if the thumb should be round or square */
  70088. get isThumbCircle(): boolean;
  70089. set isThumbCircle(value: boolean);
  70090. /**
  70091. * Creates a new Slider
  70092. * @param name defines the control name
  70093. */
  70094. constructor(name?: string | undefined);
  70095. protected _getTypeName(): string;
  70096. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  70097. }
  70098. }
  70099. declare module BABYLON.GUI {
  70100. /** Class used to create a RadioGroup
  70101. * which contains groups of radio buttons
  70102. */
  70103. export class SelectorGroup {
  70104. /** name of SelectorGroup */
  70105. name: string;
  70106. private _groupPanel;
  70107. private _selectors;
  70108. private _groupHeader;
  70109. /**
  70110. * Creates a new SelectorGroup
  70111. * @param name of group, used as a group heading
  70112. */
  70113. constructor(
  70114. /** name of SelectorGroup */
  70115. name: string);
  70116. /** Gets the groupPanel of the SelectorGroup */
  70117. get groupPanel(): StackPanel;
  70118. /** Gets the selectors array */
  70119. get selectors(): StackPanel[];
  70120. /** Gets and sets the group header */
  70121. get header(): string;
  70122. set header(label: string);
  70123. /** @hidden */
  70124. private _addGroupHeader;
  70125. /** @hidden*/
  70126. _getSelector(selectorNb: number): StackPanel | undefined;
  70127. /** Removes the selector at the given position
  70128. * @param selectorNb the position of the selector within the group
  70129. */
  70130. removeSelector(selectorNb: number): void;
  70131. }
  70132. /** Class used to create a CheckboxGroup
  70133. * which contains groups of checkbox buttons
  70134. */
  70135. export class CheckboxGroup extends SelectorGroup {
  70136. /** Adds a checkbox as a control
  70137. * @param text is the label for the selector
  70138. * @param func is the function called when the Selector is checked
  70139. * @param checked is true when Selector is checked
  70140. */
  70141. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  70142. /** @hidden */
  70143. _setSelectorLabel(selectorNb: number, label: string): void;
  70144. /** @hidden */
  70145. _setSelectorLabelColor(selectorNb: number, color: string): void;
  70146. /** @hidden */
  70147. _setSelectorButtonColor(selectorNb: number, color: string): void;
  70148. /** @hidden */
  70149. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  70150. }
  70151. /** Class used to create a RadioGroup
  70152. * which contains groups of radio buttons
  70153. */
  70154. export class RadioGroup extends SelectorGroup {
  70155. private _selectNb;
  70156. /** Adds a radio button as a control
  70157. * @param label is the label for the selector
  70158. * @param func is the function called when the Selector is checked
  70159. * @param checked is true when Selector is checked
  70160. */
  70161. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  70162. /** @hidden */
  70163. _setSelectorLabel(selectorNb: number, label: string): void;
  70164. /** @hidden */
  70165. _setSelectorLabelColor(selectorNb: number, color: string): void;
  70166. /** @hidden */
  70167. _setSelectorButtonColor(selectorNb: number, color: string): void;
  70168. /** @hidden */
  70169. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  70170. }
  70171. /** Class used to create a SliderGroup
  70172. * which contains groups of slider buttons
  70173. */
  70174. export class SliderGroup extends SelectorGroup {
  70175. /**
  70176. * Adds a slider to the SelectorGroup
  70177. * @param label is the label for the SliderBar
  70178. * @param func is the function called when the Slider moves
  70179. * @param unit is a string describing the units used, eg degrees or metres
  70180. * @param min is the minimum value for the Slider
  70181. * @param max is the maximum value for the Slider
  70182. * @param value is the start value for the Slider between min and max
  70183. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  70184. */
  70185. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  70186. /** @hidden */
  70187. _setSelectorLabel(selectorNb: number, label: string): void;
  70188. /** @hidden */
  70189. _setSelectorLabelColor(selectorNb: number, color: string): void;
  70190. /** @hidden */
  70191. _setSelectorButtonColor(selectorNb: number, color: string): void;
  70192. /** @hidden */
  70193. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  70194. }
  70195. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  70196. * @see http://doc.babylonjs.com/how_to/selector
  70197. */
  70198. export class SelectionPanel extends Rectangle {
  70199. /** name of SelectionPanel */
  70200. name: string;
  70201. /** an array of SelectionGroups */
  70202. groups: SelectorGroup[];
  70203. private _panel;
  70204. private _buttonColor;
  70205. private _buttonBackground;
  70206. private _headerColor;
  70207. private _barColor;
  70208. private _barHeight;
  70209. private _spacerHeight;
  70210. private _labelColor;
  70211. private _groups;
  70212. private _bars;
  70213. /**
  70214. * Creates a new SelectionPanel
  70215. * @param name of SelectionPanel
  70216. * @param groups is an array of SelectionGroups
  70217. */
  70218. constructor(
  70219. /** name of SelectionPanel */
  70220. name: string,
  70221. /** an array of SelectionGroups */
  70222. groups?: SelectorGroup[]);
  70223. protected _getTypeName(): string;
  70224. /** Gets or sets the headerColor */
  70225. get headerColor(): string;
  70226. set headerColor(color: string);
  70227. private _setHeaderColor;
  70228. /** Gets or sets the button color */
  70229. get buttonColor(): string;
  70230. set buttonColor(color: string);
  70231. private _setbuttonColor;
  70232. /** Gets or sets the label color */
  70233. get labelColor(): string;
  70234. set labelColor(color: string);
  70235. private _setLabelColor;
  70236. /** Gets or sets the button background */
  70237. get buttonBackground(): string;
  70238. set buttonBackground(color: string);
  70239. private _setButtonBackground;
  70240. /** Gets or sets the color of separator bar */
  70241. get barColor(): string;
  70242. set barColor(color: string);
  70243. private _setBarColor;
  70244. /** Gets or sets the height of separator bar */
  70245. get barHeight(): string;
  70246. set barHeight(value: string);
  70247. private _setBarHeight;
  70248. /** Gets or sets the height of spacers*/
  70249. get spacerHeight(): string;
  70250. set spacerHeight(value: string);
  70251. private _setSpacerHeight;
  70252. /** Adds a bar between groups */
  70253. private _addSpacer;
  70254. /** Add a group to the selection panel
  70255. * @param group is the selector group to add
  70256. */
  70257. addGroup(group: SelectorGroup): void;
  70258. /** Remove the group from the given position
  70259. * @param groupNb is the position of the group in the list
  70260. */
  70261. removeGroup(groupNb: number): void;
  70262. /** Change a group header label
  70263. * @param label is the new group header label
  70264. * @param groupNb is the number of the group to relabel
  70265. * */
  70266. setHeaderName(label: string, groupNb: number): void;
  70267. /** Change selector label to the one given
  70268. * @param label is the new selector label
  70269. * @param groupNb is the number of the groupcontaining the selector
  70270. * @param selectorNb is the number of the selector within a group to relabel
  70271. * */
  70272. relabel(label: string, groupNb: number, selectorNb: number): void;
  70273. /** For a given group position remove the selector at the given position
  70274. * @param groupNb is the number of the group to remove the selector from
  70275. * @param selectorNb is the number of the selector within the group
  70276. */
  70277. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  70278. /** For a given group position of correct type add a checkbox button
  70279. * @param groupNb is the number of the group to remove the selector from
  70280. * @param label is the label for the selector
  70281. * @param func is the function called when the Selector is checked
  70282. * @param checked is true when Selector is checked
  70283. */
  70284. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  70285. /** For a given group position of correct type add a radio button
  70286. * @param groupNb is the number of the group to remove the selector from
  70287. * @param label is the label for the selector
  70288. * @param func is the function called when the Selector is checked
  70289. * @param checked is true when Selector is checked
  70290. */
  70291. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  70292. /**
  70293. * For a given slider group add a slider
  70294. * @param groupNb is the number of the group to add the slider to
  70295. * @param label is the label for the Slider
  70296. * @param func is the function called when the Slider moves
  70297. * @param unit is a string describing the units used, eg degrees or metres
  70298. * @param min is the minimum value for the Slider
  70299. * @param max is the maximum value for the Slider
  70300. * @param value is the start value for the Slider between min and max
  70301. * @param onVal is the function used to format the value displayed, eg radians to degrees
  70302. */
  70303. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  70304. }
  70305. }
  70306. declare module BABYLON.GUI {
  70307. /**
  70308. * Class used to hold a the container for ScrollViewer
  70309. * @hidden
  70310. */
  70311. export class _ScrollViewerWindow extends Container {
  70312. parentClientWidth: number;
  70313. parentClientHeight: number;
  70314. /**
  70315. * Creates a new ScrollViewerWindow
  70316. * @param name of ScrollViewerWindow
  70317. */
  70318. constructor(name?: string);
  70319. protected _getTypeName(): string;
  70320. /** @hidden */
  70321. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  70322. protected _postMeasure(): void;
  70323. }
  70324. }
  70325. declare module BABYLON.GUI {
  70326. /**
  70327. * Class used to create slider controls
  70328. */
  70329. export class ScrollBar extends BaseSlider {
  70330. name?: string | undefined;
  70331. private _background;
  70332. private _borderColor;
  70333. private _tempMeasure;
  70334. /** Gets or sets border color */
  70335. get borderColor(): string;
  70336. set borderColor(value: string);
  70337. /** Gets or sets background color */
  70338. get background(): string;
  70339. set background(value: string);
  70340. /**
  70341. * Creates a new Slider
  70342. * @param name defines the control name
  70343. */
  70344. constructor(name?: string | undefined);
  70345. protected _getTypeName(): string;
  70346. protected _getThumbThickness(): number;
  70347. _draw(context: CanvasRenderingContext2D): void;
  70348. private _first;
  70349. private _originX;
  70350. private _originY;
  70351. /** @hidden */
  70352. protected _updateValueFromPointer(x: number, y: number): void;
  70353. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  70354. }
  70355. }
  70356. declare module BABYLON.GUI {
  70357. /**
  70358. * Class used to create slider controls
  70359. */
  70360. export class ImageScrollBar extends BaseSlider {
  70361. name?: string | undefined;
  70362. private _backgroundBaseImage;
  70363. private _backgroundImage;
  70364. private _thumbImage;
  70365. private _thumbBaseImage;
  70366. private _thumbLength;
  70367. private _thumbHeight;
  70368. private _barImageHeight;
  70369. private _tempMeasure;
  70370. /**
  70371. * Gets or sets the image used to render the background for horizontal bar
  70372. */
  70373. get backgroundImage(): Image;
  70374. set backgroundImage(value: Image);
  70375. /**
  70376. * Gets or sets the image used to render the thumb
  70377. */
  70378. get thumbImage(): Image;
  70379. set thumbImage(value: Image);
  70380. /**
  70381. * Gets or sets the length of the thumb
  70382. */
  70383. get thumbLength(): number;
  70384. set thumbLength(value: number);
  70385. /**
  70386. * Gets or sets the height of the thumb
  70387. */
  70388. get thumbHeight(): number;
  70389. set thumbHeight(value: number);
  70390. /**
  70391. * Gets or sets the height of the bar image
  70392. */
  70393. get barImageHeight(): number;
  70394. set barImageHeight(value: number);
  70395. /**
  70396. * Creates a new ImageScrollBar
  70397. * @param name defines the control name
  70398. */
  70399. constructor(name?: string | undefined);
  70400. protected _getTypeName(): string;
  70401. protected _getThumbThickness(): number;
  70402. _draw(context: CanvasRenderingContext2D): void;
  70403. private _first;
  70404. private _originX;
  70405. private _originY;
  70406. /** @hidden */
  70407. protected _updateValueFromPointer(x: number, y: number): void;
  70408. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  70409. }
  70410. }
  70411. declare module BABYLON.GUI {
  70412. /**
  70413. * Class used to hold a viewer window and sliders in a grid
  70414. */
  70415. export class ScrollViewer extends Rectangle {
  70416. private _grid;
  70417. private _horizontalBarSpace;
  70418. private _verticalBarSpace;
  70419. private _dragSpace;
  70420. private _horizontalBar;
  70421. private _verticalBar;
  70422. private _barColor;
  70423. private _barBackground;
  70424. private _barImage;
  70425. private _barBackgroundImage;
  70426. private _barSize;
  70427. private _endLeft;
  70428. private _endTop;
  70429. private _window;
  70430. private _pointerIsOver;
  70431. private _wheelPrecision;
  70432. private _onPointerObserver;
  70433. private _clientWidth;
  70434. private _clientHeight;
  70435. private _useImageBar;
  70436. private _thumbLength;
  70437. private _thumbHeight;
  70438. private _barImageHeight;
  70439. /**
  70440. * Gets the horizontal scrollbar
  70441. */
  70442. get horizontalBar(): ScrollBar | ImageScrollBar;
  70443. /**
  70444. * Gets the vertical scrollbar
  70445. */
  70446. get verticalBar(): ScrollBar | ImageScrollBar;
  70447. /**
  70448. * Adds a new control to the current container
  70449. * @param control defines the control to add
  70450. * @returns the current container
  70451. */
  70452. addControl(control: BABYLON.Nullable<Control>): Container;
  70453. /**
  70454. * Removes a control from the current container
  70455. * @param control defines the control to remove
  70456. * @returns the current container
  70457. */
  70458. removeControl(control: Control): Container;
  70459. /** Gets the list of children */
  70460. get children(): Control[];
  70461. _flagDescendantsAsMatrixDirty(): void;
  70462. /**
  70463. * Creates a new ScrollViewer
  70464. * @param name of ScrollViewer
  70465. */
  70466. constructor(name?: string, isImageBased?: boolean);
  70467. /** Reset the scroll viewer window to initial size */
  70468. resetWindow(): void;
  70469. protected _getTypeName(): string;
  70470. private _buildClientSizes;
  70471. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  70472. protected _postMeasure(): void;
  70473. /**
  70474. * Gets or sets the mouse wheel precision
  70475. * from 0 to 1 with a default value of 0.05
  70476. * */
  70477. get wheelPrecision(): number;
  70478. set wheelPrecision(value: number);
  70479. /** Gets or sets the scroll bar container background color */
  70480. get scrollBackground(): string;
  70481. set scrollBackground(color: string);
  70482. /** Gets or sets the bar color */
  70483. get barColor(): string;
  70484. set barColor(color: string);
  70485. /** Gets or sets the bar image */
  70486. get thumbImage(): Image;
  70487. set thumbImage(value: Image);
  70488. /** Gets or sets the size of the bar */
  70489. get barSize(): number;
  70490. set barSize(value: number);
  70491. /** Gets or sets the length of the thumb */
  70492. get thumbLength(): number;
  70493. set thumbLength(value: number);
  70494. /** Gets or sets the height of the thumb */
  70495. get thumbHeight(): number;
  70496. set thumbHeight(value: number);
  70497. /** Gets or sets the height of the bar image */
  70498. get barImageHeight(): number;
  70499. set barImageHeight(value: number);
  70500. /** Gets or sets the bar background */
  70501. get barBackground(): string;
  70502. set barBackground(color: string);
  70503. /** Gets or sets the bar background image */
  70504. get barImage(): Image;
  70505. set barImage(value: Image);
  70506. /** @hidden */
  70507. private _updateScroller;
  70508. _link(host: AdvancedDynamicTexture): void;
  70509. /** @hidden */
  70510. private _addBar;
  70511. /** @hidden */
  70512. private _attachWheel;
  70513. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  70514. /** Releases associated resources */
  70515. dispose(): void;
  70516. }
  70517. }
  70518. declare module BABYLON.GUI {
  70519. /** Class used to render a grid */
  70520. export class DisplayGrid extends Control {
  70521. name?: string | undefined;
  70522. private _cellWidth;
  70523. private _cellHeight;
  70524. private _minorLineTickness;
  70525. private _minorLineColor;
  70526. private _majorLineTickness;
  70527. private _majorLineColor;
  70528. private _majorLineFrequency;
  70529. private _background;
  70530. private _displayMajorLines;
  70531. private _displayMinorLines;
  70532. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  70533. get displayMinorLines(): boolean;
  70534. set displayMinorLines(value: boolean);
  70535. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  70536. get displayMajorLines(): boolean;
  70537. set displayMajorLines(value: boolean);
  70538. /** Gets or sets background color (Black by default) */
  70539. get background(): string;
  70540. set background(value: string);
  70541. /** Gets or sets the width of each cell (20 by default) */
  70542. get cellWidth(): number;
  70543. set cellWidth(value: number);
  70544. /** Gets or sets the height of each cell (20 by default) */
  70545. get cellHeight(): number;
  70546. set cellHeight(value: number);
  70547. /** Gets or sets the tickness of minor lines (1 by default) */
  70548. get minorLineTickness(): number;
  70549. set minorLineTickness(value: number);
  70550. /** Gets or sets the color of minor lines (DarkGray by default) */
  70551. get minorLineColor(): string;
  70552. set minorLineColor(value: string);
  70553. /** Gets or sets the tickness of major lines (2 by default) */
  70554. get majorLineTickness(): number;
  70555. set majorLineTickness(value: number);
  70556. /** Gets or sets the color of major lines (White by default) */
  70557. get majorLineColor(): string;
  70558. set majorLineColor(value: string);
  70559. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  70560. get majorLineFrequency(): number;
  70561. set majorLineFrequency(value: number);
  70562. /**
  70563. * Creates a new GridDisplayRectangle
  70564. * @param name defines the control name
  70565. */
  70566. constructor(name?: string | undefined);
  70567. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  70568. protected _getTypeName(): string;
  70569. }
  70570. }
  70571. declare module BABYLON.GUI {
  70572. /**
  70573. * Class used to create slider controls based on images
  70574. */
  70575. export class ImageBasedSlider extends BaseSlider {
  70576. name?: string | undefined;
  70577. private _backgroundImage;
  70578. private _thumbImage;
  70579. private _valueBarImage;
  70580. private _tempMeasure;
  70581. get displayThumb(): boolean;
  70582. set displayThumb(value: boolean);
  70583. /**
  70584. * Gets or sets the image used to render the background
  70585. */
  70586. get backgroundImage(): Image;
  70587. set backgroundImage(value: Image);
  70588. /**
  70589. * Gets or sets the image used to render the value bar
  70590. */
  70591. get valueBarImage(): Image;
  70592. set valueBarImage(value: Image);
  70593. /**
  70594. * Gets or sets the image used to render the thumb
  70595. */
  70596. get thumbImage(): Image;
  70597. set thumbImage(value: Image);
  70598. /**
  70599. * Creates a new ImageBasedSlider
  70600. * @param name defines the control name
  70601. */
  70602. constructor(name?: string | undefined);
  70603. protected _getTypeName(): string;
  70604. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  70605. }
  70606. }
  70607. declare module BABYLON.GUI {
  70608. /**
  70609. * Forcing an export so that this code will execute
  70610. * @hidden
  70611. */
  70612. const name = "Statics";
  70613. }
  70614. declare module BABYLON.GUI {
  70615. /**
  70616. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  70617. */
  70618. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  70619. /**
  70620. * Define the instrumented AdvancedDynamicTexture.
  70621. */
  70622. texture: AdvancedDynamicTexture;
  70623. private _captureRenderTime;
  70624. private _renderTime;
  70625. private _captureLayoutTime;
  70626. private _layoutTime;
  70627. private _onBeginRenderObserver;
  70628. private _onEndRenderObserver;
  70629. private _onBeginLayoutObserver;
  70630. private _onEndLayoutObserver;
  70631. /**
  70632. * Gets the perf counter used to capture render time
  70633. */
  70634. get renderTimeCounter(): BABYLON.PerfCounter;
  70635. /**
  70636. * Gets the perf counter used to capture layout time
  70637. */
  70638. get layoutTimeCounter(): BABYLON.PerfCounter;
  70639. /**
  70640. * Enable or disable the render time capture
  70641. */
  70642. get captureRenderTime(): boolean;
  70643. set captureRenderTime(value: boolean);
  70644. /**
  70645. * Enable or disable the layout time capture
  70646. */
  70647. get captureLayoutTime(): boolean;
  70648. set captureLayoutTime(value: boolean);
  70649. /**
  70650. * Instantiates a new advanced dynamic texture instrumentation.
  70651. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  70652. * @param texture Defines the AdvancedDynamicTexture to instrument
  70653. */
  70654. constructor(
  70655. /**
  70656. * Define the instrumented AdvancedDynamicTexture.
  70657. */
  70658. texture: AdvancedDynamicTexture);
  70659. /**
  70660. * Dispose and release associated resources.
  70661. */
  70662. dispose(): void;
  70663. }
  70664. }
  70665. declare module BABYLON.GUI {
  70666. /**
  70667. * Class used to load GUI via XML.
  70668. */
  70669. export class XmlLoader {
  70670. private _nodes;
  70671. private _nodeTypes;
  70672. private _isLoaded;
  70673. private _objectAttributes;
  70674. private _parentClass;
  70675. /**
  70676. * Create a new xml loader
  70677. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  70678. */
  70679. constructor(parentClass?: null);
  70680. private _getChainElement;
  70681. private _getClassAttribute;
  70682. private _createGuiElement;
  70683. private _parseGrid;
  70684. private _parseElement;
  70685. private _prepareSourceElement;
  70686. private _parseElementsFromSource;
  70687. private _parseXml;
  70688. /**
  70689. * Gets if the loading has finished.
  70690. * @returns whether the loading has finished or not
  70691. */
  70692. isLoaded(): boolean;
  70693. /**
  70694. * Gets a loaded node / control by id.
  70695. * @param id the Controls id set in the xml
  70696. * @returns element of type Control
  70697. */
  70698. getNodeById(id: string): any;
  70699. /**
  70700. * Gets all loaded nodes / controls
  70701. * @returns Array of controls
  70702. */
  70703. getNodes(): any;
  70704. /**
  70705. * Initiates the xml layout loading
  70706. * @param xmlFile defines the xml layout to load
  70707. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  70708. * @param callback defines the callback called on layout load.
  70709. */
  70710. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  70711. }
  70712. }
  70713. declare module BABYLON.GUI {
  70714. /**
  70715. * Class used to create containers for controls
  70716. */
  70717. export class Container3D extends Control3D {
  70718. private _blockLayout;
  70719. /**
  70720. * Gets the list of child controls
  70721. */
  70722. protected _children: Control3D[];
  70723. /**
  70724. * Gets the list of child controls
  70725. */
  70726. get children(): Array<Control3D>;
  70727. /**
  70728. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  70729. * This is helpful to optimize layout operation when adding multiple children in a row
  70730. */
  70731. get blockLayout(): boolean;
  70732. set blockLayout(value: boolean);
  70733. /**
  70734. * Creates a new container
  70735. * @param name defines the container name
  70736. */
  70737. constructor(name?: string);
  70738. /**
  70739. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  70740. * @returns the current container
  70741. */
  70742. updateLayout(): Container3D;
  70743. /**
  70744. * Gets a boolean indicating if the given control is in the children of this control
  70745. * @param control defines the control to check
  70746. * @returns true if the control is in the child list
  70747. */
  70748. containsControl(control: Control3D): boolean;
  70749. /**
  70750. * Adds a control to the children of this control
  70751. * @param control defines the control to add
  70752. * @returns the current container
  70753. */
  70754. addControl(control: Control3D): Container3D;
  70755. /**
  70756. * This function will be called everytime a new control is added
  70757. */
  70758. protected _arrangeChildren(): void;
  70759. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  70760. /**
  70761. * Removes a control from the children of this control
  70762. * @param control defines the control to remove
  70763. * @returns the current container
  70764. */
  70765. removeControl(control: Control3D): Container3D;
  70766. protected _getTypeName(): string;
  70767. /**
  70768. * Releases all associated resources
  70769. */
  70770. dispose(): void;
  70771. /** Control rotation will remain unchanged */
  70772. static readonly UNSET_ORIENTATION: number;
  70773. /** Control will rotate to make it look at sphere central axis */
  70774. static readonly FACEORIGIN_ORIENTATION: number;
  70775. /** Control will rotate to make it look back at sphere central axis */
  70776. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  70777. /** Control will rotate to look at z axis (0, 0, 1) */
  70778. static readonly FACEFORWARD_ORIENTATION: number;
  70779. /** Control will rotate to look at negative z axis (0, 0, -1) */
  70780. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  70781. }
  70782. }
  70783. declare module BABYLON.GUI {
  70784. /**
  70785. * Class used to manage 3D user interface
  70786. * @see http://doc.babylonjs.com/how_to/gui3d
  70787. */
  70788. export class GUI3DManager implements BABYLON.IDisposable {
  70789. private _scene;
  70790. private _sceneDisposeObserver;
  70791. private _utilityLayer;
  70792. private _rootContainer;
  70793. private _pointerObserver;
  70794. private _pointerOutObserver;
  70795. /** @hidden */
  70796. _lastPickedControl: Control3D;
  70797. /** @hidden */
  70798. _lastControlOver: {
  70799. [pointerId: number]: Control3D;
  70800. };
  70801. /** @hidden */
  70802. _lastControlDown: {
  70803. [pointerId: number]: Control3D;
  70804. };
  70805. /**
  70806. * BABYLON.Observable raised when the point picked by the pointer events changed
  70807. */
  70808. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  70809. /** @hidden */
  70810. _sharedMaterials: {
  70811. [key: string]: BABYLON.Material;
  70812. };
  70813. /** Gets the hosting scene */
  70814. get scene(): BABYLON.Scene;
  70815. /** Gets associated utility layer */
  70816. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  70817. /**
  70818. * Creates a new GUI3DManager
  70819. * @param scene
  70820. */
  70821. constructor(scene?: BABYLON.Scene);
  70822. private _handlePointerOut;
  70823. private _doPicking;
  70824. /**
  70825. * Gets the root container
  70826. */
  70827. get rootContainer(): Container3D;
  70828. /**
  70829. * Gets a boolean indicating if the given control is in the root child list
  70830. * @param control defines the control to check
  70831. * @returns true if the control is in the root child list
  70832. */
  70833. containsControl(control: Control3D): boolean;
  70834. /**
  70835. * Adds a control to the root child list
  70836. * @param control defines the control to add
  70837. * @returns the current manager
  70838. */
  70839. addControl(control: Control3D): GUI3DManager;
  70840. /**
  70841. * Removes a control from the root child list
  70842. * @param control defines the control to remove
  70843. * @returns the current container
  70844. */
  70845. removeControl(control: Control3D): GUI3DManager;
  70846. /**
  70847. * Releases all associated resources
  70848. */
  70849. dispose(): void;
  70850. }
  70851. }
  70852. declare module BABYLON.GUI {
  70853. /**
  70854. * Class used to transport BABYLON.Vector3 information for pointer events
  70855. */
  70856. export class Vector3WithInfo extends BABYLON.Vector3 {
  70857. /** defines the current mouse button index */
  70858. buttonIndex: number;
  70859. /**
  70860. * Creates a new Vector3WithInfo
  70861. * @param source defines the vector3 data to transport
  70862. * @param buttonIndex defines the current mouse button index
  70863. */
  70864. constructor(source: BABYLON.Vector3,
  70865. /** defines the current mouse button index */
  70866. buttonIndex?: number);
  70867. }
  70868. }
  70869. declare module BABYLON.GUI {
  70870. /**
  70871. * Class used as base class for controls
  70872. */
  70873. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  70874. /** Defines the control name */
  70875. name?: string | undefined;
  70876. /** @hidden */
  70877. _host: GUI3DManager;
  70878. private _node;
  70879. private _downCount;
  70880. private _enterCount;
  70881. private _downPointerIds;
  70882. private _isVisible;
  70883. /** Gets or sets the control position in world space */
  70884. get position(): BABYLON.Vector3;
  70885. set position(value: BABYLON.Vector3);
  70886. /** Gets or sets the control scaling in world space */
  70887. get scaling(): BABYLON.Vector3;
  70888. set scaling(value: BABYLON.Vector3);
  70889. /** Callback used to start pointer enter animation */
  70890. pointerEnterAnimation: () => void;
  70891. /** Callback used to start pointer out animation */
  70892. pointerOutAnimation: () => void;
  70893. /** Callback used to start pointer down animation */
  70894. pointerDownAnimation: () => void;
  70895. /** Callback used to start pointer up animation */
  70896. pointerUpAnimation: () => void;
  70897. /**
  70898. * An event triggered when the pointer move over the control
  70899. */
  70900. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  70901. /**
  70902. * An event triggered when the pointer move out of the control
  70903. */
  70904. onPointerOutObservable: BABYLON.Observable<Control3D>;
  70905. /**
  70906. * An event triggered when the pointer taps the control
  70907. */
  70908. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  70909. /**
  70910. * An event triggered when pointer is up
  70911. */
  70912. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  70913. /**
  70914. * An event triggered when a control is clicked on (with a mouse)
  70915. */
  70916. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  70917. /**
  70918. * An event triggered when pointer enters the control
  70919. */
  70920. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  70921. /**
  70922. * Gets or sets the parent container
  70923. */
  70924. parent: BABYLON.Nullable<Container3D>;
  70925. private _behaviors;
  70926. /**
  70927. * Gets the list of attached behaviors
  70928. * @see http://doc.babylonjs.com/features/behaviour
  70929. */
  70930. get behaviors(): BABYLON.Behavior<Control3D>[];
  70931. /**
  70932. * Attach a behavior to the control
  70933. * @see http://doc.babylonjs.com/features/behaviour
  70934. * @param behavior defines the behavior to attach
  70935. * @returns the current control
  70936. */
  70937. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  70938. /**
  70939. * Remove an attached behavior
  70940. * @see http://doc.babylonjs.com/features/behaviour
  70941. * @param behavior defines the behavior to attach
  70942. * @returns the current control
  70943. */
  70944. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  70945. /**
  70946. * Gets an attached behavior by name
  70947. * @param name defines the name of the behavior to look for
  70948. * @see http://doc.babylonjs.com/features/behaviour
  70949. * @returns null if behavior was not found else the requested behavior
  70950. */
  70951. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  70952. /** Gets or sets a boolean indicating if the control is visible */
  70953. get isVisible(): boolean;
  70954. set isVisible(value: boolean);
  70955. /**
  70956. * Creates a new control
  70957. * @param name defines the control name
  70958. */
  70959. constructor(
  70960. /** Defines the control name */
  70961. name?: string | undefined);
  70962. /**
  70963. * Gets a string representing the class name
  70964. */
  70965. get typeName(): string;
  70966. /**
  70967. * Get the current class name of the control.
  70968. * @returns current class name
  70969. */
  70970. getClassName(): string;
  70971. protected _getTypeName(): string;
  70972. /**
  70973. * Gets the transform node used by this control
  70974. */
  70975. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  70976. /**
  70977. * Gets the mesh used to render this control
  70978. */
  70979. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  70980. /**
  70981. * Link the control as child of the given node
  70982. * @param node defines the node to link to. Use null to unlink the control
  70983. * @returns the current control
  70984. */
  70985. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  70986. /** @hidden **/
  70987. _prepareNode(scene: BABYLON.Scene): void;
  70988. /**
  70989. * Node creation.
  70990. * Can be overriden by children
  70991. * @param scene defines the scene where the node must be attached
  70992. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  70993. */
  70994. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  70995. /**
  70996. * Affect a material to the given mesh
  70997. * @param mesh defines the mesh which will represent the control
  70998. */
  70999. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  71000. /** @hidden */
  71001. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  71002. /** @hidden */
  71003. _onPointerEnter(target: Control3D): boolean;
  71004. /** @hidden */
  71005. _onPointerOut(target: Control3D): void;
  71006. /** @hidden */
  71007. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  71008. /** @hidden */
  71009. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  71010. /** @hidden */
  71011. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  71012. /** @hidden */
  71013. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  71014. /** @hidden */
  71015. _disposeNode(): void;
  71016. /**
  71017. * Releases all associated resources
  71018. */
  71019. dispose(): void;
  71020. }
  71021. }
  71022. declare module BABYLON.GUI {
  71023. /**
  71024. * Class used as a root to all buttons
  71025. */
  71026. export class AbstractButton3D extends Control3D {
  71027. /**
  71028. * Creates a new button
  71029. * @param name defines the control name
  71030. */
  71031. constructor(name?: string);
  71032. protected _getTypeName(): string;
  71033. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  71034. }
  71035. }
  71036. declare module BABYLON.GUI {
  71037. /**
  71038. * Class used to create a button in 3D
  71039. */
  71040. export class Button3D extends AbstractButton3D {
  71041. /** @hidden */
  71042. protected _currentMaterial: BABYLON.Material;
  71043. private _facadeTexture;
  71044. private _content;
  71045. private _contentResolution;
  71046. private _contentScaleRatio;
  71047. /**
  71048. * Gets or sets the texture resolution used to render content (512 by default)
  71049. */
  71050. get contentResolution(): BABYLON.int;
  71051. set contentResolution(value: BABYLON.int);
  71052. /**
  71053. * Gets or sets the texture scale ratio used to render content (2 by default)
  71054. */
  71055. get contentScaleRatio(): number;
  71056. set contentScaleRatio(value: number);
  71057. protected _disposeFacadeTexture(): void;
  71058. protected _resetContent(): void;
  71059. /**
  71060. * Creates a new button
  71061. * @param name defines the control name
  71062. */
  71063. constructor(name?: string);
  71064. /**
  71065. * Gets or sets the GUI 2D content used to display the button's facade
  71066. */
  71067. get content(): Control;
  71068. set content(value: Control);
  71069. /**
  71070. * Apply the facade texture (created from the content property).
  71071. * This function can be overloaded by child classes
  71072. * @param facadeTexture defines the AdvancedDynamicTexture to use
  71073. */
  71074. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  71075. protected _getTypeName(): string;
  71076. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  71077. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  71078. /**
  71079. * Releases all associated resources
  71080. */
  71081. dispose(): void;
  71082. }
  71083. }
  71084. declare module BABYLON.GUI {
  71085. /**
  71086. * Abstract class used to create a container panel deployed on the surface of a volume
  71087. */
  71088. export abstract class VolumeBasedPanel extends Container3D {
  71089. private _columns;
  71090. private _rows;
  71091. private _rowThenColum;
  71092. private _orientation;
  71093. protected _cellWidth: number;
  71094. protected _cellHeight: number;
  71095. /**
  71096. * Gets or sets the distance between elements
  71097. */
  71098. margin: number;
  71099. /**
  71100. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  71101. * | Value | Type | Description |
  71102. * | ----- | ----------------------------------- | ----------- |
  71103. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  71104. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  71105. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  71106. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  71107. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  71108. */
  71109. get orientation(): number;
  71110. set orientation(value: number);
  71111. /**
  71112. * Gets or sets the number of columns requested (10 by default).
  71113. * The panel will automatically compute the number of rows based on number of child controls.
  71114. */
  71115. get columns(): BABYLON.int;
  71116. set columns(value: BABYLON.int);
  71117. /**
  71118. * Gets or sets a the number of rows requested.
  71119. * The panel will automatically compute the number of columns based on number of child controls.
  71120. */
  71121. get rows(): BABYLON.int;
  71122. set rows(value: BABYLON.int);
  71123. /**
  71124. * Creates new VolumeBasedPanel
  71125. */
  71126. constructor();
  71127. protected _arrangeChildren(): void;
  71128. /** Child classes must implement this function to provide correct control positioning */
  71129. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  71130. /** Child classes can implement this function to provide additional processing */
  71131. protected _finalProcessing(): void;
  71132. }
  71133. }
  71134. declare module BABYLON.GUI {
  71135. /**
  71136. * Class used to create a container panel deployed on the surface of a cylinder
  71137. */
  71138. export class CylinderPanel extends VolumeBasedPanel {
  71139. private _radius;
  71140. /**
  71141. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  71142. */
  71143. get radius(): BABYLON.float;
  71144. set radius(value: BABYLON.float);
  71145. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  71146. private _cylindricalMapping;
  71147. }
  71148. }
  71149. declare module BABYLON.GUI {
  71150. /** @hidden */
  71151. export var fluentVertexShader: {
  71152. name: string;
  71153. shader: string;
  71154. };
  71155. }
  71156. declare module BABYLON.GUI {
  71157. /** @hidden */
  71158. export var fluentPixelShader: {
  71159. name: string;
  71160. shader: string;
  71161. };
  71162. }
  71163. declare module BABYLON.GUI {
  71164. /** @hidden */
  71165. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  71166. INNERGLOW: boolean;
  71167. BORDER: boolean;
  71168. HOVERLIGHT: boolean;
  71169. TEXTURE: boolean;
  71170. constructor();
  71171. }
  71172. /**
  71173. * Class used to render controls with fluent desgin
  71174. */
  71175. export class FluentMaterial extends BABYLON.PushMaterial {
  71176. /**
  71177. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  71178. */
  71179. innerGlowColorIntensity: number;
  71180. /**
  71181. * Gets or sets the inner glow color (white by default)
  71182. */
  71183. innerGlowColor: BABYLON.Color3;
  71184. /**
  71185. * Gets or sets alpha value (default is 1.0)
  71186. */
  71187. alpha: number;
  71188. /**
  71189. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  71190. */
  71191. albedoColor: BABYLON.Color3;
  71192. /**
  71193. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  71194. */
  71195. renderBorders: boolean;
  71196. /**
  71197. * Gets or sets border width (default is 0.5)
  71198. */
  71199. borderWidth: number;
  71200. /**
  71201. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  71202. */
  71203. edgeSmoothingValue: number;
  71204. /**
  71205. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  71206. */
  71207. borderMinValue: number;
  71208. /**
  71209. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  71210. */
  71211. renderHoverLight: boolean;
  71212. /**
  71213. * Gets or sets the radius used to render the hover light (default is 1.0)
  71214. */
  71215. hoverRadius: number;
  71216. /**
  71217. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  71218. */
  71219. hoverColor: BABYLON.Color4;
  71220. /**
  71221. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  71222. */
  71223. hoverPosition: BABYLON.Vector3;
  71224. private _albedoTexture;
  71225. /** Gets or sets the texture to use for albedo color */
  71226. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  71227. /**
  71228. * Creates a new Fluent material
  71229. * @param name defines the name of the material
  71230. * @param scene defines the hosting scene
  71231. */
  71232. constructor(name: string, scene: BABYLON.Scene);
  71233. needAlphaBlending(): boolean;
  71234. needAlphaTesting(): boolean;
  71235. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71236. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71237. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71238. getActiveTextures(): BABYLON.BaseTexture[];
  71239. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71240. dispose(forceDisposeEffect?: boolean): void;
  71241. clone(name: string): FluentMaterial;
  71242. serialize(): any;
  71243. getClassName(): string;
  71244. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  71245. }
  71246. }
  71247. declare module BABYLON.GUI {
  71248. /**
  71249. * Class used to create a holographic button in 3D
  71250. */
  71251. export class HolographicButton extends Button3D {
  71252. private _backPlate;
  71253. private _textPlate;
  71254. private _frontPlate;
  71255. private _text;
  71256. private _imageUrl;
  71257. private _shareMaterials;
  71258. private _frontMaterial;
  71259. private _backMaterial;
  71260. private _plateMaterial;
  71261. private _pickedPointObserver;
  71262. private _tooltipFade;
  71263. private _tooltipTextBlock;
  71264. private _tooltipTexture;
  71265. private _tooltipMesh;
  71266. private _tooltipHoverObserver;
  71267. private _tooltipOutObserver;
  71268. private _disposeTooltip;
  71269. /**
  71270. * Rendering ground id of all the mesh in the button
  71271. */
  71272. set renderingGroupId(id: number);
  71273. get renderingGroupId(): number;
  71274. /**
  71275. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  71276. */
  71277. set tooltipText(text: BABYLON.Nullable<string>);
  71278. get tooltipText(): BABYLON.Nullable<string>;
  71279. /**
  71280. * Gets or sets text for the button
  71281. */
  71282. get text(): string;
  71283. set text(value: string);
  71284. /**
  71285. * Gets or sets the image url for the button
  71286. */
  71287. get imageUrl(): string;
  71288. set imageUrl(value: string);
  71289. /**
  71290. * Gets the back material used by this button
  71291. */
  71292. get backMaterial(): FluentMaterial;
  71293. /**
  71294. * Gets the front material used by this button
  71295. */
  71296. get frontMaterial(): FluentMaterial;
  71297. /**
  71298. * Gets the plate material used by this button
  71299. */
  71300. get plateMaterial(): BABYLON.StandardMaterial;
  71301. /**
  71302. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  71303. */
  71304. get shareMaterials(): boolean;
  71305. /**
  71306. * Creates a new button
  71307. * @param name defines the control name
  71308. */
  71309. constructor(name?: string, shareMaterials?: boolean);
  71310. protected _getTypeName(): string;
  71311. private _rebuildContent;
  71312. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  71313. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  71314. private _createBackMaterial;
  71315. private _createFrontMaterial;
  71316. private _createPlateMaterial;
  71317. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  71318. /**
  71319. * Releases all associated resources
  71320. */
  71321. dispose(): void;
  71322. }
  71323. }
  71324. declare module BABYLON.GUI {
  71325. /**
  71326. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  71327. */
  71328. export class MeshButton3D extends Button3D {
  71329. /** @hidden */
  71330. protected _currentMesh: BABYLON.Mesh;
  71331. /**
  71332. * Creates a new 3D button based on a mesh
  71333. * @param mesh mesh to become a 3D button
  71334. * @param name defines the control name
  71335. */
  71336. constructor(mesh: BABYLON.Mesh, name?: string);
  71337. protected _getTypeName(): string;
  71338. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  71339. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  71340. }
  71341. }
  71342. declare module BABYLON.GUI {
  71343. /**
  71344. * Class used to create a container panel deployed on the surface of a plane
  71345. */
  71346. export class PlanePanel extends VolumeBasedPanel {
  71347. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  71348. }
  71349. }
  71350. declare module BABYLON.GUI {
  71351. /**
  71352. * Class used to create a container panel where items get randomized planar mapping
  71353. */
  71354. export class ScatterPanel extends VolumeBasedPanel {
  71355. private _iteration;
  71356. /**
  71357. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  71358. */
  71359. get iteration(): BABYLON.float;
  71360. set iteration(value: BABYLON.float);
  71361. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  71362. private _scatterMapping;
  71363. protected _finalProcessing(): void;
  71364. }
  71365. }
  71366. declare module BABYLON.GUI {
  71367. /**
  71368. * Class used to create a container panel deployed on the surface of a sphere
  71369. */
  71370. export class SpherePanel extends VolumeBasedPanel {
  71371. private _radius;
  71372. /**
  71373. * Gets or sets the radius of the sphere where to project controls (5 by default)
  71374. */
  71375. get radius(): BABYLON.float;
  71376. set radius(value: BABYLON.float);
  71377. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  71378. private _sphericalMapping;
  71379. }
  71380. }
  71381. declare module BABYLON.GUI {
  71382. /**
  71383. * Class used to create a stack panel in 3D on XY plane
  71384. */
  71385. export class StackPanel3D extends Container3D {
  71386. private _isVertical;
  71387. /**
  71388. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  71389. */
  71390. get isVertical(): boolean;
  71391. set isVertical(value: boolean);
  71392. /**
  71393. * Gets or sets the distance between elements
  71394. */
  71395. margin: number;
  71396. /**
  71397. * Creates new StackPanel
  71398. * @param isVertical
  71399. */
  71400. constructor(isVertical?: boolean);
  71401. protected _arrangeChildren(): void;
  71402. }
  71403. }
  71404. declare module BABYLON {
  71405. /**
  71406. * Mode that determines the coordinate system to use.
  71407. */
  71408. export enum GLTFLoaderCoordinateSystemMode {
  71409. /**
  71410. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  71411. */
  71412. AUTO = 0,
  71413. /**
  71414. * Sets the useRightHandedSystem flag on the scene.
  71415. */
  71416. FORCE_RIGHT_HANDED = 1
  71417. }
  71418. /**
  71419. * Mode that determines what animations will start.
  71420. */
  71421. export enum GLTFLoaderAnimationStartMode {
  71422. /**
  71423. * No animation will start.
  71424. */
  71425. NONE = 0,
  71426. /**
  71427. * The first animation will start.
  71428. */
  71429. FIRST = 1,
  71430. /**
  71431. * All animations will start.
  71432. */
  71433. ALL = 2
  71434. }
  71435. /**
  71436. * Interface that contains the data for the glTF asset.
  71437. */
  71438. export interface IGLTFLoaderData {
  71439. /**
  71440. * The object that represents the glTF JSON.
  71441. */
  71442. json: Object;
  71443. /**
  71444. * The BIN chunk of a binary glTF.
  71445. */
  71446. bin: Nullable<IDataBuffer>;
  71447. }
  71448. /**
  71449. * Interface for extending the loader.
  71450. */
  71451. export interface IGLTFLoaderExtension {
  71452. /**
  71453. * The name of this extension.
  71454. */
  71455. readonly name: string;
  71456. /**
  71457. * Defines whether this extension is enabled.
  71458. */
  71459. enabled: boolean;
  71460. /**
  71461. * Defines the order of this extension.
  71462. * The loader sorts the extensions using these values when loading.
  71463. */
  71464. order?: number;
  71465. }
  71466. /**
  71467. * Loader state.
  71468. */
  71469. export enum GLTFLoaderState {
  71470. /**
  71471. * The asset is loading.
  71472. */
  71473. LOADING = 0,
  71474. /**
  71475. * The asset is ready for rendering.
  71476. */
  71477. READY = 1,
  71478. /**
  71479. * The asset is completely loaded.
  71480. */
  71481. COMPLETE = 2
  71482. }
  71483. /** @hidden */
  71484. export interface IGLTFLoader extends IDisposable {
  71485. readonly state: Nullable<GLTFLoaderState>;
  71486. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<{
  71487. meshes: AbstractMesh[];
  71488. particleSystems: IParticleSystem[];
  71489. skeletons: Skeleton[];
  71490. animationGroups: AnimationGroup[];
  71491. }>;
  71492. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  71493. }
  71494. /**
  71495. * File loader for loading glTF files into a scene.
  71496. */
  71497. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  71498. /** @hidden */
  71499. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  71500. /** @hidden */
  71501. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  71502. /**
  71503. * Raised when the asset has been parsed
  71504. */
  71505. onParsedObservable: Observable<IGLTFLoaderData>;
  71506. private _onParsedObserver;
  71507. /**
  71508. * Raised when the asset has been parsed
  71509. */
  71510. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  71511. /**
  71512. * 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.
  71513. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  71514. * Defaults to true.
  71515. * @hidden
  71516. */
  71517. static IncrementalLoading: boolean;
  71518. /**
  71519. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  71520. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  71521. * @hidden
  71522. */
  71523. static HomogeneousCoordinates: boolean;
  71524. /**
  71525. * The coordinate system mode. Defaults to AUTO.
  71526. */
  71527. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  71528. /**
  71529. * The animation start mode. Defaults to FIRST.
  71530. */
  71531. animationStartMode: GLTFLoaderAnimationStartMode;
  71532. /**
  71533. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  71534. */
  71535. compileMaterials: boolean;
  71536. /**
  71537. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  71538. */
  71539. useClipPlane: boolean;
  71540. /**
  71541. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  71542. */
  71543. compileShadowGenerators: boolean;
  71544. /**
  71545. * Defines if the Alpha blended materials are only applied as coverage.
  71546. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  71547. * If true, no extra effects are applied to transparent pixels.
  71548. */
  71549. transparencyAsCoverage: boolean;
  71550. /**
  71551. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  71552. * Enabling will disable offline support and glTF validator.
  71553. * Defaults to false.
  71554. */
  71555. useRangeRequests: boolean;
  71556. /**
  71557. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  71558. */
  71559. createInstances: boolean;
  71560. /**
  71561. * Function called before loading a url referenced by the asset.
  71562. */
  71563. preprocessUrlAsync: (url: string) => Promise<string>;
  71564. /**
  71565. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  71566. */
  71567. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  71568. private _onMeshLoadedObserver;
  71569. /**
  71570. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  71571. */
  71572. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  71573. /**
  71574. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  71575. */
  71576. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  71577. private _onTextureLoadedObserver;
  71578. /**
  71579. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  71580. */
  71581. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  71582. /**
  71583. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  71584. */
  71585. readonly onMaterialLoadedObservable: Observable<Material>;
  71586. private _onMaterialLoadedObserver;
  71587. /**
  71588. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  71589. */
  71590. set onMaterialLoaded(callback: (material: Material) => void);
  71591. /**
  71592. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  71593. */
  71594. readonly onCameraLoadedObservable: Observable<Camera>;
  71595. private _onCameraLoadedObserver;
  71596. /**
  71597. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  71598. */
  71599. set onCameraLoaded(callback: (camera: Camera) => void);
  71600. /**
  71601. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  71602. * For assets with LODs, raised when all of the LODs are complete.
  71603. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  71604. */
  71605. readonly onCompleteObservable: Observable<void>;
  71606. private _onCompleteObserver;
  71607. /**
  71608. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  71609. * For assets with LODs, raised when all of the LODs are complete.
  71610. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  71611. */
  71612. set onComplete(callback: () => void);
  71613. /**
  71614. * Observable raised when an error occurs.
  71615. */
  71616. readonly onErrorObservable: Observable<any>;
  71617. private _onErrorObserver;
  71618. /**
  71619. * Callback raised when an error occurs.
  71620. */
  71621. set onError(callback: (reason: any) => void);
  71622. /**
  71623. * Observable raised after the loader is disposed.
  71624. */
  71625. readonly onDisposeObservable: Observable<void>;
  71626. private _onDisposeObserver;
  71627. /**
  71628. * Callback raised after the loader is disposed.
  71629. */
  71630. set onDispose(callback: () => void);
  71631. /**
  71632. * Observable raised after a loader extension is created.
  71633. * Set additional options for a loader extension in this event.
  71634. */
  71635. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  71636. private _onExtensionLoadedObserver;
  71637. /**
  71638. * Callback raised after a loader extension is created.
  71639. */
  71640. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  71641. /**
  71642. * Defines if the loader logging is enabled.
  71643. */
  71644. get loggingEnabled(): boolean;
  71645. set loggingEnabled(value: boolean);
  71646. /**
  71647. * Defines if the loader should capture performance counters.
  71648. */
  71649. get capturePerformanceCounters(): boolean;
  71650. set capturePerformanceCounters(value: boolean);
  71651. /**
  71652. * Defines if the loader should validate the asset.
  71653. */
  71654. validate: boolean;
  71655. /**
  71656. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  71657. */
  71658. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  71659. private _onValidatedObserver;
  71660. /**
  71661. * Callback raised after a loader extension is created.
  71662. */
  71663. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  71664. private _loader;
  71665. /**
  71666. * Name of the loader ("gltf")
  71667. */
  71668. name: string;
  71669. /** @hidden */
  71670. extensions: ISceneLoaderPluginExtensions;
  71671. /**
  71672. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  71673. */
  71674. dispose(): void;
  71675. /** @hidden */
  71676. _clear(): void;
  71677. /** @hidden */
  71678. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  71679. /** @hidden */
  71680. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  71681. /** @hidden */
  71682. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  71683. meshes: AbstractMesh[];
  71684. particleSystems: IParticleSystem[];
  71685. skeletons: Skeleton[];
  71686. animationGroups: AnimationGroup[];
  71687. }>;
  71688. /** @hidden */
  71689. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  71690. /** @hidden */
  71691. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  71692. /** @hidden */
  71693. canDirectLoad(data: string): boolean;
  71694. /** @hidden */
  71695. directLoad(scene: Scene, data: string): any;
  71696. /**
  71697. * The callback that allows custom handling of the root url based on the response url.
  71698. * @param rootUrl the original root url
  71699. * @param responseURL the response url if available
  71700. * @returns the new root url
  71701. */
  71702. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  71703. /** @hidden */
  71704. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  71705. /**
  71706. * The loader state or null if the loader is not active.
  71707. */
  71708. get loaderState(): Nullable<GLTFLoaderState>;
  71709. /**
  71710. * Returns a promise that resolves when the asset is completely loaded.
  71711. * @returns a promise that resolves when the asset is completely loaded.
  71712. */
  71713. whenCompleteAsync(): Promise<void>;
  71714. private _validateAsync;
  71715. private _getLoader;
  71716. private _parseJson;
  71717. private _unpackBinaryAsync;
  71718. private _unpackBinaryV1Async;
  71719. private _unpackBinaryV2Async;
  71720. private static _parseVersion;
  71721. private static _compareVersion;
  71722. private static readonly _logSpaces;
  71723. private _logIndentLevel;
  71724. private _loggingEnabled;
  71725. /** @hidden */
  71726. _log: (message: string) => void;
  71727. /** @hidden */
  71728. _logOpen(message: string): void;
  71729. /** @hidden */
  71730. _logClose(): void;
  71731. private _logEnabled;
  71732. private _logDisabled;
  71733. private _capturePerformanceCounters;
  71734. /** @hidden */
  71735. _startPerformanceCounter: (counterName: string) => void;
  71736. /** @hidden */
  71737. _endPerformanceCounter: (counterName: string) => void;
  71738. private _startPerformanceCounterEnabled;
  71739. private _startPerformanceCounterDisabled;
  71740. private _endPerformanceCounterEnabled;
  71741. private _endPerformanceCounterDisabled;
  71742. }
  71743. }
  71744. declare module BABYLON.GLTF1 {
  71745. /**
  71746. * Enums
  71747. * @hidden
  71748. */
  71749. export enum EComponentType {
  71750. BYTE = 5120,
  71751. UNSIGNED_BYTE = 5121,
  71752. SHORT = 5122,
  71753. UNSIGNED_SHORT = 5123,
  71754. FLOAT = 5126
  71755. }
  71756. /** @hidden */
  71757. export enum EShaderType {
  71758. FRAGMENT = 35632,
  71759. VERTEX = 35633
  71760. }
  71761. /** @hidden */
  71762. export enum EParameterType {
  71763. BYTE = 5120,
  71764. UNSIGNED_BYTE = 5121,
  71765. SHORT = 5122,
  71766. UNSIGNED_SHORT = 5123,
  71767. INT = 5124,
  71768. UNSIGNED_INT = 5125,
  71769. FLOAT = 5126,
  71770. FLOAT_VEC2 = 35664,
  71771. FLOAT_VEC3 = 35665,
  71772. FLOAT_VEC4 = 35666,
  71773. INT_VEC2 = 35667,
  71774. INT_VEC3 = 35668,
  71775. INT_VEC4 = 35669,
  71776. BOOL = 35670,
  71777. BOOL_VEC2 = 35671,
  71778. BOOL_VEC3 = 35672,
  71779. BOOL_VEC4 = 35673,
  71780. FLOAT_MAT2 = 35674,
  71781. FLOAT_MAT3 = 35675,
  71782. FLOAT_MAT4 = 35676,
  71783. SAMPLER_2D = 35678
  71784. }
  71785. /** @hidden */
  71786. export enum ETextureWrapMode {
  71787. CLAMP_TO_EDGE = 33071,
  71788. MIRRORED_REPEAT = 33648,
  71789. REPEAT = 10497
  71790. }
  71791. /** @hidden */
  71792. export enum ETextureFilterType {
  71793. NEAREST = 9728,
  71794. LINEAR = 9728,
  71795. NEAREST_MIPMAP_NEAREST = 9984,
  71796. LINEAR_MIPMAP_NEAREST = 9985,
  71797. NEAREST_MIPMAP_LINEAR = 9986,
  71798. LINEAR_MIPMAP_LINEAR = 9987
  71799. }
  71800. /** @hidden */
  71801. export enum ETextureFormat {
  71802. ALPHA = 6406,
  71803. RGB = 6407,
  71804. RGBA = 6408,
  71805. LUMINANCE = 6409,
  71806. LUMINANCE_ALPHA = 6410
  71807. }
  71808. /** @hidden */
  71809. export enum ECullingType {
  71810. FRONT = 1028,
  71811. BACK = 1029,
  71812. FRONT_AND_BACK = 1032
  71813. }
  71814. /** @hidden */
  71815. export enum EBlendingFunction {
  71816. ZERO = 0,
  71817. ONE = 1,
  71818. SRC_COLOR = 768,
  71819. ONE_MINUS_SRC_COLOR = 769,
  71820. DST_COLOR = 774,
  71821. ONE_MINUS_DST_COLOR = 775,
  71822. SRC_ALPHA = 770,
  71823. ONE_MINUS_SRC_ALPHA = 771,
  71824. DST_ALPHA = 772,
  71825. ONE_MINUS_DST_ALPHA = 773,
  71826. CONSTANT_COLOR = 32769,
  71827. ONE_MINUS_CONSTANT_COLOR = 32770,
  71828. CONSTANT_ALPHA = 32771,
  71829. ONE_MINUS_CONSTANT_ALPHA = 32772,
  71830. SRC_ALPHA_SATURATE = 776
  71831. }
  71832. /** @hidden */
  71833. export interface IGLTFProperty {
  71834. extensions?: {
  71835. [key: string]: any;
  71836. };
  71837. extras?: Object;
  71838. }
  71839. /** @hidden */
  71840. export interface IGLTFChildRootProperty extends IGLTFProperty {
  71841. name?: string;
  71842. }
  71843. /** @hidden */
  71844. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  71845. bufferView: string;
  71846. byteOffset: number;
  71847. byteStride: number;
  71848. count: number;
  71849. type: string;
  71850. componentType: EComponentType;
  71851. max?: number[];
  71852. min?: number[];
  71853. name?: string;
  71854. }
  71855. /** @hidden */
  71856. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  71857. buffer: string;
  71858. byteOffset: number;
  71859. byteLength: number;
  71860. byteStride: number;
  71861. target?: number;
  71862. }
  71863. /** @hidden */
  71864. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  71865. uri: string;
  71866. byteLength?: number;
  71867. type?: string;
  71868. }
  71869. /** @hidden */
  71870. export interface IGLTFShader extends IGLTFChildRootProperty {
  71871. uri: string;
  71872. type: EShaderType;
  71873. }
  71874. /** @hidden */
  71875. export interface IGLTFProgram extends IGLTFChildRootProperty {
  71876. attributes: string[];
  71877. fragmentShader: string;
  71878. vertexShader: string;
  71879. }
  71880. /** @hidden */
  71881. export interface IGLTFTechniqueParameter {
  71882. type: number;
  71883. count?: number;
  71884. semantic?: string;
  71885. node?: string;
  71886. value?: number | boolean | string | Array<any>;
  71887. source?: string;
  71888. babylonValue?: any;
  71889. }
  71890. /** @hidden */
  71891. export interface IGLTFTechniqueCommonProfile {
  71892. lightingModel: string;
  71893. texcoordBindings: Object;
  71894. parameters?: Array<any>;
  71895. }
  71896. /** @hidden */
  71897. export interface IGLTFTechniqueStatesFunctions {
  71898. blendColor?: number[];
  71899. blendEquationSeparate?: number[];
  71900. blendFuncSeparate?: number[];
  71901. colorMask: boolean[];
  71902. cullFace: number[];
  71903. }
  71904. /** @hidden */
  71905. export interface IGLTFTechniqueStates {
  71906. enable: number[];
  71907. functions: IGLTFTechniqueStatesFunctions;
  71908. }
  71909. /** @hidden */
  71910. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  71911. parameters: {
  71912. [key: string]: IGLTFTechniqueParameter;
  71913. };
  71914. program: string;
  71915. attributes: {
  71916. [key: string]: string;
  71917. };
  71918. uniforms: {
  71919. [key: string]: string;
  71920. };
  71921. states: IGLTFTechniqueStates;
  71922. }
  71923. /** @hidden */
  71924. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  71925. technique?: string;
  71926. values: string[];
  71927. }
  71928. /** @hidden */
  71929. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  71930. attributes: {
  71931. [key: string]: string;
  71932. };
  71933. indices: string;
  71934. material: string;
  71935. mode?: number;
  71936. }
  71937. /** @hidden */
  71938. export interface IGLTFMesh extends IGLTFChildRootProperty {
  71939. primitives: IGLTFMeshPrimitive[];
  71940. }
  71941. /** @hidden */
  71942. export interface IGLTFImage extends IGLTFChildRootProperty {
  71943. uri: string;
  71944. }
  71945. /** @hidden */
  71946. export interface IGLTFSampler extends IGLTFChildRootProperty {
  71947. magFilter?: number;
  71948. minFilter?: number;
  71949. wrapS?: number;
  71950. wrapT?: number;
  71951. }
  71952. /** @hidden */
  71953. export interface IGLTFTexture extends IGLTFChildRootProperty {
  71954. sampler: string;
  71955. source: string;
  71956. format?: ETextureFormat;
  71957. internalFormat?: ETextureFormat;
  71958. target?: number;
  71959. type?: number;
  71960. babylonTexture?: Texture;
  71961. }
  71962. /** @hidden */
  71963. export interface IGLTFAmbienLight {
  71964. color?: number[];
  71965. }
  71966. /** @hidden */
  71967. export interface IGLTFDirectionalLight {
  71968. color?: number[];
  71969. }
  71970. /** @hidden */
  71971. export interface IGLTFPointLight {
  71972. color?: number[];
  71973. constantAttenuation?: number;
  71974. linearAttenuation?: number;
  71975. quadraticAttenuation?: number;
  71976. }
  71977. /** @hidden */
  71978. export interface IGLTFSpotLight {
  71979. color?: number[];
  71980. constantAttenuation?: number;
  71981. fallOfAngle?: number;
  71982. fallOffExponent?: number;
  71983. linearAttenuation?: number;
  71984. quadraticAttenuation?: number;
  71985. }
  71986. /** @hidden */
  71987. export interface IGLTFLight extends IGLTFChildRootProperty {
  71988. type: string;
  71989. }
  71990. /** @hidden */
  71991. export interface IGLTFCameraOrthographic {
  71992. xmag: number;
  71993. ymag: number;
  71994. zfar: number;
  71995. znear: number;
  71996. }
  71997. /** @hidden */
  71998. export interface IGLTFCameraPerspective {
  71999. aspectRatio: number;
  72000. yfov: number;
  72001. zfar: number;
  72002. znear: number;
  72003. }
  72004. /** @hidden */
  72005. export interface IGLTFCamera extends IGLTFChildRootProperty {
  72006. type: string;
  72007. }
  72008. /** @hidden */
  72009. export interface IGLTFAnimationChannelTarget {
  72010. id: string;
  72011. path: string;
  72012. }
  72013. /** @hidden */
  72014. export interface IGLTFAnimationChannel {
  72015. sampler: string;
  72016. target: IGLTFAnimationChannelTarget;
  72017. }
  72018. /** @hidden */
  72019. export interface IGLTFAnimationSampler {
  72020. input: string;
  72021. output: string;
  72022. interpolation?: string;
  72023. }
  72024. /** @hidden */
  72025. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  72026. channels?: IGLTFAnimationChannel[];
  72027. parameters?: {
  72028. [key: string]: string;
  72029. };
  72030. samplers?: {
  72031. [key: string]: IGLTFAnimationSampler;
  72032. };
  72033. }
  72034. /** @hidden */
  72035. export interface IGLTFNodeInstanceSkin {
  72036. skeletons: string[];
  72037. skin: string;
  72038. meshes: string[];
  72039. }
  72040. /** @hidden */
  72041. export interface IGLTFSkins extends IGLTFChildRootProperty {
  72042. bindShapeMatrix: number[];
  72043. inverseBindMatrices: string;
  72044. jointNames: string[];
  72045. babylonSkeleton?: Skeleton;
  72046. }
  72047. /** @hidden */
  72048. export interface IGLTFNode extends IGLTFChildRootProperty {
  72049. camera?: string;
  72050. children: string[];
  72051. skin?: string;
  72052. jointName?: string;
  72053. light?: string;
  72054. matrix: number[];
  72055. mesh?: string;
  72056. meshes?: string[];
  72057. rotation?: number[];
  72058. scale?: number[];
  72059. translation?: number[];
  72060. babylonNode?: Node;
  72061. }
  72062. /** @hidden */
  72063. export interface IGLTFScene extends IGLTFChildRootProperty {
  72064. nodes: string[];
  72065. }
  72066. /** @hidden */
  72067. export interface IGLTFRuntime {
  72068. extensions: {
  72069. [key: string]: any;
  72070. };
  72071. accessors: {
  72072. [key: string]: IGLTFAccessor;
  72073. };
  72074. buffers: {
  72075. [key: string]: IGLTFBuffer;
  72076. };
  72077. bufferViews: {
  72078. [key: string]: IGLTFBufferView;
  72079. };
  72080. meshes: {
  72081. [key: string]: IGLTFMesh;
  72082. };
  72083. lights: {
  72084. [key: string]: IGLTFLight;
  72085. };
  72086. cameras: {
  72087. [key: string]: IGLTFCamera;
  72088. };
  72089. nodes: {
  72090. [key: string]: IGLTFNode;
  72091. };
  72092. images: {
  72093. [key: string]: IGLTFImage;
  72094. };
  72095. textures: {
  72096. [key: string]: IGLTFTexture;
  72097. };
  72098. shaders: {
  72099. [key: string]: IGLTFShader;
  72100. };
  72101. programs: {
  72102. [key: string]: IGLTFProgram;
  72103. };
  72104. samplers: {
  72105. [key: string]: IGLTFSampler;
  72106. };
  72107. techniques: {
  72108. [key: string]: IGLTFTechnique;
  72109. };
  72110. materials: {
  72111. [key: string]: IGLTFMaterial;
  72112. };
  72113. animations: {
  72114. [key: string]: IGLTFAnimation;
  72115. };
  72116. skins: {
  72117. [key: string]: IGLTFSkins;
  72118. };
  72119. currentScene?: Object;
  72120. scenes: {
  72121. [key: string]: IGLTFScene;
  72122. };
  72123. extensionsUsed: string[];
  72124. extensionsRequired?: string[];
  72125. buffersCount: number;
  72126. shaderscount: number;
  72127. scene: Scene;
  72128. rootUrl: string;
  72129. loadedBufferCount: number;
  72130. loadedBufferViews: {
  72131. [name: string]: ArrayBufferView;
  72132. };
  72133. loadedShaderCount: number;
  72134. importOnlyMeshes: boolean;
  72135. importMeshesNames?: string[];
  72136. dummyNodes: Node[];
  72137. }
  72138. /** @hidden */
  72139. export interface INodeToRoot {
  72140. bone: Bone;
  72141. node: IGLTFNode;
  72142. id: string;
  72143. }
  72144. /** @hidden */
  72145. export interface IJointNode {
  72146. node: IGLTFNode;
  72147. id: string;
  72148. }
  72149. }
  72150. declare module BABYLON.GLTF1 {
  72151. /**
  72152. * Utils functions for GLTF
  72153. * @hidden
  72154. */
  72155. export class GLTFUtils {
  72156. /**
  72157. * Sets the given "parameter" matrix
  72158. * @param scene: the Scene object
  72159. * @param source: the source node where to pick the matrix
  72160. * @param parameter: the GLTF technique parameter
  72161. * @param uniformName: the name of the shader's uniform
  72162. * @param shaderMaterial: the shader material
  72163. */
  72164. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  72165. /**
  72166. * Sets the given "parameter" matrix
  72167. * @param shaderMaterial: the shader material
  72168. * @param uniform: the name of the shader's uniform
  72169. * @param value: the value of the uniform
  72170. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  72171. */
  72172. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  72173. /**
  72174. * Returns the wrap mode of the texture
  72175. * @param mode: the mode value
  72176. */
  72177. static GetWrapMode(mode: number): number;
  72178. /**
  72179. * Returns the byte stride giving an accessor
  72180. * @param accessor: the GLTF accessor objet
  72181. */
  72182. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  72183. /**
  72184. * Returns the texture filter mode giving a mode value
  72185. * @param mode: the filter mode value
  72186. */
  72187. static GetTextureFilterMode(mode: number): ETextureFilterType;
  72188. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  72189. /**
  72190. * Returns a buffer from its accessor
  72191. * @param gltfRuntime: the GLTF runtime
  72192. * @param accessor: the GLTF accessor
  72193. */
  72194. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  72195. /**
  72196. * Decodes a buffer view into a string
  72197. * @param view: the buffer view
  72198. */
  72199. static DecodeBufferToText(view: ArrayBufferView): string;
  72200. /**
  72201. * Returns the default material of gltf. Related to
  72202. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  72203. * @param scene: the Babylon.js scene
  72204. */
  72205. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  72206. private static _DefaultMaterial;
  72207. }
  72208. }
  72209. declare module BABYLON.GLTF1 {
  72210. /**
  72211. * Implementation of the base glTF spec
  72212. * @hidden
  72213. */
  72214. export class GLTFLoaderBase {
  72215. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  72216. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  72217. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  72218. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  72219. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  72220. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  72221. }
  72222. /**
  72223. * glTF V1 Loader
  72224. * @hidden
  72225. */
  72226. export class GLTFLoader implements IGLTFLoader {
  72227. static Extensions: {
  72228. [name: string]: GLTFLoaderExtension;
  72229. };
  72230. static RegisterExtension(extension: GLTFLoaderExtension): void;
  72231. state: Nullable<GLTFLoaderState>;
  72232. dispose(): void;
  72233. private _importMeshAsync;
  72234. /**
  72235. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  72236. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  72237. * @param scene the scene the meshes should be added to
  72238. * @param data gltf data containing information of the meshes in a loaded file
  72239. * @param rootUrl root url to load from
  72240. * @param onProgress event that fires when loading progress has occured
  72241. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  72242. */
  72243. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  72244. meshes: AbstractMesh[];
  72245. particleSystems: IParticleSystem[];
  72246. skeletons: Skeleton[];
  72247. animationGroups: AnimationGroup[];
  72248. }>;
  72249. private _loadAsync;
  72250. /**
  72251. * Imports all objects from a loaded gltf file and adds them to the scene
  72252. * @param scene the scene the objects should be added to
  72253. * @param data gltf data containing information of the meshes in a loaded file
  72254. * @param rootUrl root url to load from
  72255. * @param onProgress event that fires when loading progress has occured
  72256. * @returns a promise which completes when objects have been loaded to the scene
  72257. */
  72258. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  72259. private _loadShadersAsync;
  72260. private _loadBuffersAsync;
  72261. private _createNodes;
  72262. }
  72263. /** @hidden */
  72264. export abstract class GLTFLoaderExtension {
  72265. private _name;
  72266. constructor(name: string);
  72267. get name(): string;
  72268. /**
  72269. * Defines an override for loading the runtime
  72270. * Return true to stop further extensions from loading the runtime
  72271. */
  72272. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  72273. /**
  72274. * Defines an onverride for creating gltf runtime
  72275. * Return true to stop further extensions from creating the runtime
  72276. */
  72277. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  72278. /**
  72279. * Defines an override for loading buffers
  72280. * Return true to stop further extensions from loading this buffer
  72281. */
  72282. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  72283. /**
  72284. * Defines an override for loading texture buffers
  72285. * Return true to stop further extensions from loading this texture data
  72286. */
  72287. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  72288. /**
  72289. * Defines an override for creating textures
  72290. * Return true to stop further extensions from loading this texture
  72291. */
  72292. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  72293. /**
  72294. * Defines an override for loading shader strings
  72295. * Return true to stop further extensions from loading this shader data
  72296. */
  72297. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  72298. /**
  72299. * Defines an override for loading materials
  72300. * Return true to stop further extensions from loading this material
  72301. */
  72302. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  72303. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  72304. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  72305. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  72306. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  72307. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  72308. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  72309. private static LoadTextureBufferAsync;
  72310. private static CreateTextureAsync;
  72311. private static ApplyExtensions;
  72312. }
  72313. }
  72314. declare module BABYLON.GLTF1 {
  72315. /** @hidden */
  72316. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  72317. private _bin;
  72318. constructor();
  72319. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  72320. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  72321. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  72322. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  72323. }
  72324. }
  72325. declare module BABYLON.GLTF1 {
  72326. /** @hidden */
  72327. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  72328. constructor();
  72329. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  72330. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  72331. private _loadTexture;
  72332. }
  72333. }
  72334. declare module BABYLON.GLTF2.Loader {
  72335. /**
  72336. * Loader interface with an index field.
  72337. */
  72338. export interface IArrayItem {
  72339. /**
  72340. * The index of this item in the array.
  72341. */
  72342. index: number;
  72343. }
  72344. /**
  72345. * Loader interface with additional members.
  72346. */
  72347. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  72348. /** @hidden */
  72349. _data?: Promise<ArrayBufferView>;
  72350. /** @hidden */
  72351. _babylonVertexBuffer?: Promise<VertexBuffer>;
  72352. }
  72353. /**
  72354. * Loader interface with additional members.
  72355. */
  72356. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  72357. }
  72358. /** @hidden */
  72359. export interface _IAnimationSamplerData {
  72360. input: Float32Array;
  72361. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  72362. output: Float32Array;
  72363. }
  72364. /**
  72365. * Loader interface with additional members.
  72366. */
  72367. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  72368. /** @hidden */
  72369. _data?: Promise<_IAnimationSamplerData>;
  72370. }
  72371. /**
  72372. * Loader interface with additional members.
  72373. */
  72374. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  72375. channels: IAnimationChannel[];
  72376. samplers: IAnimationSampler[];
  72377. /** @hidden */
  72378. _babylonAnimationGroup?: AnimationGroup;
  72379. }
  72380. /**
  72381. * Loader interface with additional members.
  72382. */
  72383. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  72384. /** @hidden */
  72385. _data?: Promise<ArrayBufferView>;
  72386. }
  72387. /**
  72388. * Loader interface with additional members.
  72389. */
  72390. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  72391. /** @hidden */
  72392. _data?: Promise<ArrayBufferView>;
  72393. /** @hidden */
  72394. _babylonBuffer?: Promise<Buffer>;
  72395. }
  72396. /**
  72397. * Loader interface with additional members.
  72398. */
  72399. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  72400. }
  72401. /**
  72402. * Loader interface with additional members.
  72403. */
  72404. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  72405. /** @hidden */
  72406. _data?: Promise<ArrayBufferView>;
  72407. }
  72408. /**
  72409. * Loader interface with additional members.
  72410. */
  72411. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  72412. }
  72413. /**
  72414. * Loader interface with additional members.
  72415. */
  72416. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  72417. }
  72418. /**
  72419. * Loader interface with additional members.
  72420. */
  72421. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  72422. baseColorTexture?: ITextureInfo;
  72423. metallicRoughnessTexture?: ITextureInfo;
  72424. }
  72425. /**
  72426. * Loader interface with additional members.
  72427. */
  72428. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  72429. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  72430. normalTexture?: IMaterialNormalTextureInfo;
  72431. occlusionTexture?: IMaterialOcclusionTextureInfo;
  72432. emissiveTexture?: ITextureInfo;
  72433. /** @hidden */
  72434. _data?: {
  72435. [babylonDrawMode: number]: {
  72436. babylonMaterial: Material;
  72437. babylonMeshes: AbstractMesh[];
  72438. promise: Promise<void>;
  72439. };
  72440. };
  72441. }
  72442. /**
  72443. * Loader interface with additional members.
  72444. */
  72445. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  72446. primitives: IMeshPrimitive[];
  72447. }
  72448. /**
  72449. * Loader interface with additional members.
  72450. */
  72451. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  72452. /** @hidden */
  72453. _instanceData?: {
  72454. babylonSourceMesh: Mesh;
  72455. promise: Promise<any>;
  72456. };
  72457. }
  72458. /**
  72459. * Loader interface with additional members.
  72460. */
  72461. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  72462. /**
  72463. * The parent glTF node.
  72464. */
  72465. parent?: INode;
  72466. /** @hidden */
  72467. _babylonTransformNode?: TransformNode;
  72468. /** @hidden */
  72469. _primitiveBabylonMeshes?: AbstractMesh[];
  72470. /** @hidden */
  72471. _babylonBones?: Bone[];
  72472. /** @hidden */
  72473. _numMorphTargets?: number;
  72474. }
  72475. /** @hidden */
  72476. export interface _ISamplerData {
  72477. noMipMaps: boolean;
  72478. samplingMode: number;
  72479. wrapU: number;
  72480. wrapV: number;
  72481. }
  72482. /**
  72483. * Loader interface with additional members.
  72484. */
  72485. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  72486. /** @hidden */
  72487. _data?: _ISamplerData;
  72488. }
  72489. /**
  72490. * Loader interface with additional members.
  72491. */
  72492. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  72493. }
  72494. /**
  72495. * Loader interface with additional members.
  72496. */
  72497. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  72498. /** @hidden */
  72499. _data?: {
  72500. babylonSkeleton: Skeleton;
  72501. promise: Promise<void>;
  72502. };
  72503. }
  72504. /**
  72505. * Loader interface with additional members.
  72506. */
  72507. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  72508. }
  72509. /**
  72510. * Loader interface with additional members.
  72511. */
  72512. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  72513. }
  72514. /**
  72515. * Loader interface with additional members.
  72516. */
  72517. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  72518. accessors?: IAccessor[];
  72519. animations?: IAnimation[];
  72520. buffers?: IBuffer[];
  72521. bufferViews?: IBufferView[];
  72522. cameras?: ICamera[];
  72523. images?: IImage[];
  72524. materials?: IMaterial[];
  72525. meshes?: IMesh[];
  72526. nodes?: INode[];
  72527. samplers?: ISampler[];
  72528. scenes?: IScene[];
  72529. skins?: ISkin[];
  72530. textures?: ITexture[];
  72531. }
  72532. }
  72533. declare module BABYLON.GLTF2 {
  72534. /**
  72535. * Interface for a glTF loader extension.
  72536. */
  72537. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  72538. /**
  72539. * Called after the loader state changes to LOADING.
  72540. */
  72541. onLoading?(): void;
  72542. /**
  72543. * Called after the loader state changes to READY.
  72544. */
  72545. onReady?(): void;
  72546. /**
  72547. * Define this method to modify the default behavior when loading scenes.
  72548. * @param context The context when loading the asset
  72549. * @param scene The glTF scene property
  72550. * @returns A promise that resolves when the load is complete or null if not handled
  72551. */
  72552. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  72553. /**
  72554. * Define this method to modify the default behavior when loading nodes.
  72555. * @param context The context when loading the asset
  72556. * @param node The glTF node property
  72557. * @param assign A function called synchronously after parsing the glTF properties
  72558. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  72559. */
  72560. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  72561. /**
  72562. * Define this method to modify the default behavior when loading cameras.
  72563. * @param context The context when loading the asset
  72564. * @param camera The glTF camera property
  72565. * @param assign A function called synchronously after parsing the glTF properties
  72566. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  72567. */
  72568. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  72569. /**
  72570. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  72571. * @param context The context when loading the asset
  72572. * @param primitive The glTF mesh primitive property
  72573. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  72574. */
  72575. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  72576. /**
  72577. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  72578. * @param context The context when loading the asset
  72579. * @param name The mesh name when loading the asset
  72580. * @param node The glTF node when loading the asset
  72581. * @param mesh The glTF mesh when loading the asset
  72582. * @param primitive The glTF mesh primitive property
  72583. * @param assign A function called synchronously after parsing the glTF properties
  72584. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  72585. */
  72586. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  72587. /**
  72588. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  72589. * @param context The context when loading the asset
  72590. * @param material The glTF material property
  72591. * @param assign A function called synchronously after parsing the glTF properties
  72592. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  72593. */
  72594. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  72595. /**
  72596. * Define this method to modify the default behavior when creating materials.
  72597. * @param context The context when loading the asset
  72598. * @param material The glTF material property
  72599. * @param babylonDrawMode The draw mode for the Babylon material
  72600. * @returns The Babylon material or null if not handled
  72601. */
  72602. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  72603. /**
  72604. * Define this method to modify the default behavior when loading material properties.
  72605. * @param context The context when loading the asset
  72606. * @param material The glTF material property
  72607. * @param babylonMaterial The Babylon material
  72608. * @returns A promise that resolves when the load is complete or null if not handled
  72609. */
  72610. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  72611. /**
  72612. * Define this method to modify the default behavior when loading texture infos.
  72613. * @param context The context when loading the asset
  72614. * @param textureInfo The glTF texture info property
  72615. * @param assign A function called synchronously after parsing the glTF properties
  72616. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  72617. */
  72618. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  72619. /**
  72620. * Define this method to modify the default behavior when loading animations.
  72621. * @param context The context when loading the asset
  72622. * @param animation The glTF animation property
  72623. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  72624. */
  72625. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  72626. /**
  72627. * @hidden Define this method to modify the default behavior when loading skins.
  72628. * @param context The context when loading the asset
  72629. * @param node The glTF node property
  72630. * @param skin The glTF skin property
  72631. * @returns A promise that resolves when the load is complete or null if not handled
  72632. */
  72633. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  72634. /**
  72635. * @hidden Define this method to modify the default behavior when loading uris.
  72636. * @param context The context when loading the asset
  72637. * @param property The glTF property associated with the uri
  72638. * @param uri The uri to load
  72639. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  72640. */
  72641. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  72642. /**
  72643. * Define this method to modify the default behavior when loading buffer views.
  72644. * @param context The context when loading the asset
  72645. * @param bufferView The glTF buffer view property
  72646. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  72647. */
  72648. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  72649. /**
  72650. * Define this method to modify the default behavior when loading buffers.
  72651. * @param context The context when loading the asset
  72652. * @param buffer The glTF buffer property
  72653. * @param byteOffset The byte offset to load
  72654. * @param byteLength The byte length to load
  72655. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  72656. */
  72657. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  72658. }
  72659. }
  72660. declare module BABYLON.GLTF2 {
  72661. /**
  72662. * Helper class for working with arrays when loading the glTF asset
  72663. */
  72664. export class ArrayItem {
  72665. /**
  72666. * Gets an item from the given array.
  72667. * @param context The context when loading the asset
  72668. * @param array The array to get the item from
  72669. * @param index The index to the array
  72670. * @returns The array item
  72671. */
  72672. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  72673. /**
  72674. * Assign an `index` field to each item of the given array.
  72675. * @param array The array of items
  72676. */
  72677. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  72678. }
  72679. /**
  72680. * The glTF 2.0 loader
  72681. */
  72682. export class GLTFLoader implements IGLTFLoader {
  72683. /** @hidden */
  72684. _completePromises: Promise<any>[];
  72685. private _disposed;
  72686. private _parent;
  72687. private _state;
  72688. private _extensions;
  72689. private _rootUrl;
  72690. private _fileName;
  72691. private _uniqueRootUrl;
  72692. private _gltf;
  72693. private _bin;
  72694. private _babylonScene;
  72695. private _rootBabylonMesh;
  72696. private _defaultBabylonMaterialData;
  72697. private _progressCallback?;
  72698. private _requests;
  72699. private static readonly _DefaultSampler;
  72700. private static _RegisteredExtensions;
  72701. /**
  72702. * Registers a loader extension.
  72703. * @param name The name of the loader extension.
  72704. * @param factory The factory function that creates the loader extension.
  72705. */
  72706. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  72707. /**
  72708. * Unregisters a loader extension.
  72709. * @param name The name of the loader extension.
  72710. * @returns A boolean indicating whether the extension has been unregistered
  72711. */
  72712. static UnregisterExtension(name: string): boolean;
  72713. /**
  72714. * Gets the loader state.
  72715. */
  72716. get state(): Nullable<GLTFLoaderState>;
  72717. /**
  72718. * The object that represents the glTF JSON.
  72719. */
  72720. get gltf(): IGLTF;
  72721. /**
  72722. * The BIN chunk of a binary glTF.
  72723. */
  72724. get bin(): Nullable<IDataBuffer>;
  72725. /**
  72726. * The parent file loader.
  72727. */
  72728. get parent(): GLTFFileLoader;
  72729. /**
  72730. * The Babylon scene when loading the asset.
  72731. */
  72732. get babylonScene(): Scene;
  72733. /**
  72734. * The root Babylon mesh when loading the asset.
  72735. */
  72736. get rootBabylonMesh(): Mesh;
  72737. /** @hidden */
  72738. constructor(parent: GLTFFileLoader);
  72739. /** @hidden */
  72740. dispose(): void;
  72741. /** @hidden */
  72742. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  72743. meshes: AbstractMesh[];
  72744. particleSystems: IParticleSystem[];
  72745. skeletons: Skeleton[];
  72746. animationGroups: AnimationGroup[];
  72747. }>;
  72748. /** @hidden */
  72749. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  72750. private _loadAsync;
  72751. private _loadData;
  72752. private _setupData;
  72753. private _loadExtensions;
  72754. private _checkExtensions;
  72755. private _setState;
  72756. private _createRootNode;
  72757. /**
  72758. * Loads a glTF scene.
  72759. * @param context The context when loading the asset
  72760. * @param scene The glTF scene property
  72761. * @returns A promise that resolves when the load is complete
  72762. */
  72763. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  72764. private _forEachPrimitive;
  72765. private _getMeshes;
  72766. private _getSkeletons;
  72767. private _getAnimationGroups;
  72768. private _startAnimations;
  72769. /**
  72770. * Loads a glTF node.
  72771. * @param context The context when loading the asset
  72772. * @param node The glTF node property
  72773. * @param assign A function called synchronously after parsing the glTF properties
  72774. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  72775. */
  72776. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  72777. private _loadMeshAsync;
  72778. /**
  72779. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  72780. * @param context The context when loading the asset
  72781. * @param name The mesh name when loading the asset
  72782. * @param node The glTF node when loading the asset
  72783. * @param mesh The glTF mesh when loading the asset
  72784. * @param primitive The glTF mesh primitive property
  72785. * @param assign A function called synchronously after parsing the glTF properties
  72786. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  72787. */
  72788. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  72789. private _loadVertexDataAsync;
  72790. private _createMorphTargets;
  72791. private _loadMorphTargetsAsync;
  72792. private _loadMorphTargetVertexDataAsync;
  72793. private static _LoadTransform;
  72794. private _loadSkinAsync;
  72795. private _loadBones;
  72796. private _loadBone;
  72797. private _loadSkinInverseBindMatricesDataAsync;
  72798. private _updateBoneMatrices;
  72799. private _getNodeMatrix;
  72800. /**
  72801. * Loads a glTF camera.
  72802. * @param context The context when loading the asset
  72803. * @param camera The glTF camera property
  72804. * @param assign A function called synchronously after parsing the glTF properties
  72805. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  72806. */
  72807. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  72808. private _loadAnimationsAsync;
  72809. /**
  72810. * Loads a glTF animation.
  72811. * @param context The context when loading the asset
  72812. * @param animation The glTF animation property
  72813. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  72814. */
  72815. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  72816. /**
  72817. * @hidden Loads a glTF animation channel.
  72818. * @param context The context when loading the asset
  72819. * @param animationContext The context of the animation when loading the asset
  72820. * @param animation The glTF animation property
  72821. * @param channel The glTF animation channel property
  72822. * @param babylonAnimationGroup The babylon animation group property
  72823. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  72824. * @returns A void promise when the channel load is complete
  72825. */
  72826. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  72827. private _loadAnimationSamplerAsync;
  72828. private _loadBufferAsync;
  72829. /**
  72830. * Loads a glTF buffer view.
  72831. * @param context The context when loading the asset
  72832. * @param bufferView The glTF buffer view property
  72833. * @returns A promise that resolves with the loaded data when the load is complete
  72834. */
  72835. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  72836. private _loadAccessorAsync;
  72837. private _loadFloatAccessorAsync;
  72838. private _loadIndicesAccessorAsync;
  72839. private _loadVertexBufferViewAsync;
  72840. private _loadVertexAccessorAsync;
  72841. private _loadMaterialMetallicRoughnessPropertiesAsync;
  72842. /** @hidden */
  72843. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  72844. private _createDefaultMaterial;
  72845. /**
  72846. * Creates a Babylon material from a glTF material.
  72847. * @param context The context when loading the asset
  72848. * @param material The glTF material property
  72849. * @param babylonDrawMode The draw mode for the Babylon material
  72850. * @returns The Babylon material
  72851. */
  72852. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  72853. /**
  72854. * Loads properties from a glTF material into a Babylon material.
  72855. * @param context The context when loading the asset
  72856. * @param material The glTF material property
  72857. * @param babylonMaterial The Babylon material
  72858. * @returns A promise that resolves when the load is complete
  72859. */
  72860. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  72861. /**
  72862. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  72863. * @param context The context when loading the asset
  72864. * @param material The glTF material property
  72865. * @param babylonMaterial The Babylon material
  72866. * @returns A promise that resolves when the load is complete
  72867. */
  72868. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  72869. /**
  72870. * Loads the alpha properties from a glTF material into a Babylon material.
  72871. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  72872. * @param context The context when loading the asset
  72873. * @param material The glTF material property
  72874. * @param babylonMaterial The Babylon material
  72875. */
  72876. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  72877. /**
  72878. * Loads a glTF texture info.
  72879. * @param context The context when loading the asset
  72880. * @param textureInfo The glTF texture info property
  72881. * @param assign A function called synchronously after parsing the glTF properties
  72882. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  72883. */
  72884. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  72885. private _loadTextureAsync;
  72886. private _loadSampler;
  72887. /**
  72888. * Loads a glTF image.
  72889. * @param context The context when loading the asset
  72890. * @param image The glTF image property
  72891. * @returns A promise that resolves with the loaded data when the load is complete
  72892. */
  72893. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  72894. /**
  72895. * Loads a glTF uri.
  72896. * @param context The context when loading the asset
  72897. * @param property The glTF property associated with the uri
  72898. * @param uri The base64 or relative uri
  72899. * @returns A promise that resolves with the loaded data when the load is complete
  72900. */
  72901. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  72902. private _onProgress;
  72903. /**
  72904. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  72905. * @param babylonObject the Babylon object with metadata
  72906. * @param pointer the JSON pointer
  72907. */
  72908. static AddPointerMetadata(babylonObject: {
  72909. metadata: any;
  72910. }, pointer: string): void;
  72911. private static _GetTextureWrapMode;
  72912. private static _GetTextureSamplingMode;
  72913. private static _GetTypedArrayConstructor;
  72914. private static _GetTypedArray;
  72915. private static _GetNumComponents;
  72916. private static _ValidateUri;
  72917. private static _GetDrawMode;
  72918. private _compileMaterialsAsync;
  72919. private _compileShadowGeneratorsAsync;
  72920. private _forEachExtensions;
  72921. private _applyExtensions;
  72922. private _extensionsOnLoading;
  72923. private _extensionsOnReady;
  72924. private _extensionsLoadSceneAsync;
  72925. private _extensionsLoadNodeAsync;
  72926. private _extensionsLoadCameraAsync;
  72927. private _extensionsLoadVertexDataAsync;
  72928. private _extensionsLoadMeshPrimitiveAsync;
  72929. private _extensionsLoadMaterialAsync;
  72930. private _extensionsCreateMaterial;
  72931. private _extensionsLoadMaterialPropertiesAsync;
  72932. private _extensionsLoadTextureInfoAsync;
  72933. private _extensionsLoadAnimationAsync;
  72934. private _extensionsLoadSkinAsync;
  72935. private _extensionsLoadUriAsync;
  72936. private _extensionsLoadBufferViewAsync;
  72937. private _extensionsLoadBufferAsync;
  72938. /**
  72939. * Helper method called by a loader extension to load an glTF extension.
  72940. * @param context The context when loading the asset
  72941. * @param property The glTF property to load the extension from
  72942. * @param extensionName The name of the extension to load
  72943. * @param actionAsync The action to run
  72944. * @returns The promise returned by actionAsync or null if the extension does not exist
  72945. */
  72946. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  72947. /**
  72948. * Helper method called by a loader extension to load a glTF extra.
  72949. * @param context The context when loading the asset
  72950. * @param property The glTF property to load the extra from
  72951. * @param extensionName The name of the extension to load
  72952. * @param actionAsync The action to run
  72953. * @returns The promise returned by actionAsync or null if the extra does not exist
  72954. */
  72955. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  72956. /**
  72957. * Checks for presence of an extension.
  72958. * @param name The name of the extension to check
  72959. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  72960. */
  72961. isExtensionUsed(name: string): boolean;
  72962. /**
  72963. * Increments the indentation level and logs a message.
  72964. * @param message The message to log
  72965. */
  72966. logOpen(message: string): void;
  72967. /**
  72968. * Decrements the indentation level.
  72969. */
  72970. logClose(): void;
  72971. /**
  72972. * Logs a message
  72973. * @param message The message to log
  72974. */
  72975. log(message: string): void;
  72976. /**
  72977. * Starts a performance counter.
  72978. * @param counterName The name of the performance counter
  72979. */
  72980. startPerformanceCounter(counterName: string): void;
  72981. /**
  72982. * Ends a performance counter.
  72983. * @param counterName The name of the performance counter
  72984. */
  72985. endPerformanceCounter(counterName: string): void;
  72986. }
  72987. }
  72988. declare module BABYLON.GLTF2.Loader.Extensions {
  72989. /**
  72990. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  72991. */
  72992. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  72993. /**
  72994. * The name of this extension.
  72995. */
  72996. readonly name: string;
  72997. /**
  72998. * Defines whether this extension is enabled.
  72999. */
  73000. enabled: boolean;
  73001. private _loader;
  73002. private _lights?;
  73003. /** @hidden */
  73004. constructor(loader: GLTFLoader);
  73005. /** @hidden */
  73006. dispose(): void;
  73007. /** @hidden */
  73008. onLoading(): void;
  73009. /** @hidden */
  73010. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  73011. private _loadLightAsync;
  73012. }
  73013. }
  73014. declare module BABYLON.GLTF2.Loader.Extensions {
  73015. /**
  73016. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  73017. */
  73018. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  73019. /**
  73020. * The name of this extension.
  73021. */
  73022. readonly name: string;
  73023. /**
  73024. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  73025. */
  73026. dracoCompression?: DracoCompression;
  73027. /**
  73028. * Defines whether this extension is enabled.
  73029. */
  73030. enabled: boolean;
  73031. private _loader;
  73032. /** @hidden */
  73033. constructor(loader: GLTFLoader);
  73034. /** @hidden */
  73035. dispose(): void;
  73036. /** @hidden */
  73037. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  73038. }
  73039. }
  73040. declare module BABYLON.GLTF2.Loader.Extensions {
  73041. /**
  73042. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  73043. */
  73044. export class KHR_lights implements IGLTFLoaderExtension {
  73045. /**
  73046. * The name of this extension.
  73047. */
  73048. readonly name: string;
  73049. /**
  73050. * Defines whether this extension is enabled.
  73051. */
  73052. enabled: boolean;
  73053. private _loader;
  73054. private _lights?;
  73055. /** @hidden */
  73056. constructor(loader: GLTFLoader);
  73057. /** @hidden */
  73058. dispose(): void;
  73059. /** @hidden */
  73060. onLoading(): void;
  73061. /** @hidden */
  73062. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  73063. }
  73064. }
  73065. declare module BABYLON.GLTF2.Loader.Extensions {
  73066. /**
  73067. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  73068. */
  73069. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  73070. /**
  73071. * The name of this extension.
  73072. */
  73073. readonly name: string;
  73074. /**
  73075. * Defines whether this extension is enabled.
  73076. */
  73077. enabled: boolean;
  73078. /**
  73079. * Defines a number that determines the order the extensions are applied.
  73080. */
  73081. order: number;
  73082. private _loader;
  73083. /** @hidden */
  73084. constructor(loader: GLTFLoader);
  73085. /** @hidden */
  73086. dispose(): void;
  73087. /** @hidden */
  73088. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  73089. private _loadSpecularGlossinessPropertiesAsync;
  73090. }
  73091. }
  73092. declare module BABYLON.GLTF2.Loader.Extensions {
  73093. /**
  73094. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  73095. */
  73096. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  73097. /**
  73098. * The name of this extension.
  73099. */
  73100. readonly name: string;
  73101. /**
  73102. * Defines whether this extension is enabled.
  73103. */
  73104. enabled: boolean;
  73105. /**
  73106. * Defines a number that determines the order the extensions are applied.
  73107. */
  73108. order: number;
  73109. private _loader;
  73110. /** @hidden */
  73111. constructor(loader: GLTFLoader);
  73112. /** @hidden */
  73113. dispose(): void;
  73114. /** @hidden */
  73115. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  73116. private _loadUnlitPropertiesAsync;
  73117. }
  73118. }
  73119. declare module BABYLON.GLTF2.Loader.Extensions {
  73120. /**
  73121. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  73122. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  73123. * !!! Experimental Extension Subject to Changes !!!
  73124. */
  73125. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  73126. /**
  73127. * The name of this extension.
  73128. */
  73129. readonly name: string;
  73130. /**
  73131. * Defines whether this extension is enabled.
  73132. */
  73133. enabled: boolean;
  73134. /**
  73135. * Defines a number that determines the order the extensions are applied.
  73136. */
  73137. order: number;
  73138. private _loader;
  73139. /** @hidden */
  73140. constructor(loader: GLTFLoader);
  73141. /** @hidden */
  73142. dispose(): void;
  73143. /** @hidden */
  73144. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  73145. private _loadClearCoatPropertiesAsync;
  73146. }
  73147. }
  73148. declare module BABYLON.GLTF2.Loader.Extensions {
  73149. /**
  73150. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  73151. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  73152. * !!! Experimental Extension Subject to Changes !!!
  73153. */
  73154. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  73155. /**
  73156. * The name of this extension.
  73157. */
  73158. readonly name: string;
  73159. /**
  73160. * Defines whether this extension is enabled.
  73161. */
  73162. enabled: boolean;
  73163. /**
  73164. * Defines a number that determines the order the extensions are applied.
  73165. */
  73166. order: number;
  73167. private _loader;
  73168. /** @hidden */
  73169. constructor(loader: GLTFLoader);
  73170. /** @hidden */
  73171. dispose(): void;
  73172. /** @hidden */
  73173. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  73174. private _loadSheenPropertiesAsync;
  73175. }
  73176. }
  73177. declare module BABYLON.GLTF2.Loader.Extensions {
  73178. /**
  73179. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  73180. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  73181. * !!! Experimental Extension Subject to Changes !!!
  73182. */
  73183. export class KHR_materials_specular implements IGLTFLoaderExtension {
  73184. /**
  73185. * The name of this extension.
  73186. */
  73187. readonly name: string;
  73188. /**
  73189. * Defines whether this extension is enabled.
  73190. */
  73191. enabled: boolean;
  73192. /**
  73193. * Defines a number that determines the order the extensions are applied.
  73194. */
  73195. order: number;
  73196. private _loader;
  73197. /** @hidden */
  73198. constructor(loader: GLTFLoader);
  73199. /** @hidden */
  73200. dispose(): void;
  73201. /** @hidden */
  73202. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  73203. private _loadSpecularPropertiesAsync;
  73204. }
  73205. }
  73206. declare module BABYLON.GLTF2.Loader.Extensions {
  73207. /**
  73208. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  73209. */
  73210. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  73211. /**
  73212. * The name of this extension.
  73213. */
  73214. readonly name: string;
  73215. /**
  73216. * Defines whether this extension is enabled.
  73217. */
  73218. enabled: boolean;
  73219. /** @hidden */
  73220. constructor(loader: GLTFLoader);
  73221. /** @hidden */
  73222. dispose(): void;
  73223. }
  73224. }
  73225. declare module BABYLON.GLTF2.Loader.Extensions {
  73226. /**
  73227. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  73228. */
  73229. export class KHR_texture_transform implements IGLTFLoaderExtension {
  73230. /**
  73231. * The name of this extension.
  73232. */
  73233. readonly name: string;
  73234. /**
  73235. * Defines whether this extension is enabled.
  73236. */
  73237. enabled: boolean;
  73238. private _loader;
  73239. /** @hidden */
  73240. constructor(loader: GLTFLoader);
  73241. /** @hidden */
  73242. dispose(): void;
  73243. /** @hidden */
  73244. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  73245. }
  73246. }
  73247. declare module BABYLON.GLTF2.Loader.Extensions {
  73248. /**
  73249. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  73250. */
  73251. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  73252. /**
  73253. * The name of this extension.
  73254. */
  73255. readonly name: string;
  73256. /**
  73257. * Defines whether this extension is enabled.
  73258. */
  73259. enabled: boolean;
  73260. private _loader;
  73261. private _clips;
  73262. private _emitters;
  73263. /** @hidden */
  73264. constructor(loader: GLTFLoader);
  73265. /** @hidden */
  73266. dispose(): void;
  73267. /** @hidden */
  73268. onLoading(): void;
  73269. /** @hidden */
  73270. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  73271. /** @hidden */
  73272. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  73273. /** @hidden */
  73274. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  73275. private _loadClipAsync;
  73276. private _loadEmitterAsync;
  73277. private _getEventAction;
  73278. private _loadAnimationEventAsync;
  73279. }
  73280. }
  73281. declare module BABYLON.GLTF2.Loader.Extensions {
  73282. /**
  73283. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  73284. */
  73285. export class MSFT_lod implements IGLTFLoaderExtension {
  73286. /**
  73287. * The name of this extension.
  73288. */
  73289. readonly name: string;
  73290. /**
  73291. * Defines whether this extension is enabled.
  73292. */
  73293. enabled: boolean;
  73294. /**
  73295. * Defines a number that determines the order the extensions are applied.
  73296. */
  73297. order: number;
  73298. /**
  73299. * Maximum number of LODs to load, starting from the lowest LOD.
  73300. */
  73301. maxLODsToLoad: number;
  73302. /**
  73303. * Observable raised when all node LODs of one level are loaded.
  73304. * The event data is the index of the loaded LOD starting from zero.
  73305. * Dispose the loader to cancel the loading of the next level of LODs.
  73306. */
  73307. onNodeLODsLoadedObservable: Observable<number>;
  73308. /**
  73309. * Observable raised when all material LODs of one level are loaded.
  73310. * The event data is the index of the loaded LOD starting from zero.
  73311. * Dispose the loader to cancel the loading of the next level of LODs.
  73312. */
  73313. onMaterialLODsLoadedObservable: Observable<number>;
  73314. private _loader;
  73315. private _nodeIndexLOD;
  73316. private _nodeSignalLODs;
  73317. private _nodePromiseLODs;
  73318. private _materialIndexLOD;
  73319. private _materialSignalLODs;
  73320. private _materialPromiseLODs;
  73321. private _indexLOD;
  73322. private _bufferLODs;
  73323. /** @hidden */
  73324. constructor(loader: GLTFLoader);
  73325. /** @hidden */
  73326. dispose(): void;
  73327. /** @hidden */
  73328. onReady(): void;
  73329. /** @hidden */
  73330. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  73331. /** @hidden */
  73332. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  73333. /** @hidden */
  73334. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  73335. /** @hidden */
  73336. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  73337. private _loadBufferLOD;
  73338. /**
  73339. * Gets an array of LOD properties from lowest to highest.
  73340. */
  73341. private _getLODs;
  73342. private _disposeUnusedMaterials;
  73343. }
  73344. }
  73345. declare module BABYLON.GLTF2.Loader.Extensions {
  73346. /** @hidden */
  73347. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  73348. readonly name: string;
  73349. enabled: boolean;
  73350. private _loader;
  73351. constructor(loader: GLTFLoader);
  73352. dispose(): void;
  73353. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  73354. }
  73355. }
  73356. declare module BABYLON.GLTF2.Loader.Extensions {
  73357. /** @hidden */
  73358. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  73359. readonly name: string;
  73360. enabled: boolean;
  73361. private _loader;
  73362. constructor(loader: GLTFLoader);
  73363. dispose(): void;
  73364. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  73365. }
  73366. }
  73367. declare module BABYLON.GLTF2.Loader.Extensions {
  73368. /**
  73369. * Store glTF extras (if present) in BJS objects' metadata
  73370. */
  73371. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  73372. /**
  73373. * The name of this extension.
  73374. */
  73375. readonly name: string;
  73376. /**
  73377. * Defines whether this extension is enabled.
  73378. */
  73379. enabled: boolean;
  73380. private _loader;
  73381. private _assignExtras;
  73382. /** @hidden */
  73383. constructor(loader: GLTFLoader);
  73384. /** @hidden */
  73385. dispose(): void;
  73386. /** @hidden */
  73387. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  73388. /** @hidden */
  73389. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  73390. /** @hidden */
  73391. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  73392. }
  73393. }
  73394. declare module BABYLON {
  73395. /**
  73396. * Class reading and parsing the MTL file bundled with the obj file.
  73397. */
  73398. export class MTLFileLoader {
  73399. /**
  73400. * All material loaded from the mtl will be set here
  73401. */
  73402. materials: StandardMaterial[];
  73403. /**
  73404. * This function will read the mtl file and create each material described inside
  73405. * This function could be improve by adding :
  73406. * -some component missing (Ni, Tf...)
  73407. * -including the specific options available
  73408. *
  73409. * @param scene defines the scene the material will be created in
  73410. * @param data defines the mtl data to parse
  73411. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  73412. */
  73413. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string): void;
  73414. /**
  73415. * Gets the texture for the material.
  73416. *
  73417. * If the material is imported from input file,
  73418. * We sanitize the url to ensure it takes the textre from aside the material.
  73419. *
  73420. * @param rootUrl The root url to load from
  73421. * @param value The value stored in the mtl
  73422. * @return The Texture
  73423. */
  73424. private static _getTexture;
  73425. }
  73426. /**
  73427. * Options for loading OBJ/MTL files
  73428. */
  73429. type MeshLoadOptions = {
  73430. /**
  73431. * Defines if UVs are optimized by default during load.
  73432. */
  73433. OptimizeWithUV: boolean;
  73434. /**
  73435. * Defines custom scaling of UV coordinates of loaded meshes.
  73436. */
  73437. UVScaling: Vector2;
  73438. /**
  73439. * Invert model on y-axis (does a model scaling inversion)
  73440. */
  73441. InvertY: boolean;
  73442. /**
  73443. * Invert Y-Axis of referenced textures on load
  73444. */
  73445. InvertTextureY: boolean;
  73446. /**
  73447. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  73448. */
  73449. ImportVertexColors: boolean;
  73450. /**
  73451. * Compute the normals for the model, even if normals are present in the file.
  73452. */
  73453. ComputeNormals: boolean;
  73454. /**
  73455. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  73456. */
  73457. SkipMaterials: boolean;
  73458. /**
  73459. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  73460. */
  73461. MaterialLoadingFailsSilently: boolean;
  73462. };
  73463. /**
  73464. * OBJ file type loader.
  73465. * This is a babylon scene loader plugin.
  73466. */
  73467. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  73468. /**
  73469. * Defines if UVs are optimized by default during load.
  73470. */
  73471. static OPTIMIZE_WITH_UV: boolean;
  73472. /**
  73473. * Invert model on y-axis (does a model scaling inversion)
  73474. */
  73475. static INVERT_Y: boolean;
  73476. /**
  73477. * Invert Y-Axis of referenced textures on load
  73478. */
  73479. static INVERT_TEXTURE_Y: boolean;
  73480. /**
  73481. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  73482. */
  73483. static IMPORT_VERTEX_COLORS: boolean;
  73484. /**
  73485. * Compute the normals for the model, even if normals are present in the file.
  73486. */
  73487. static COMPUTE_NORMALS: boolean;
  73488. /**
  73489. * Defines custom scaling of UV coordinates of loaded meshes.
  73490. */
  73491. static UV_SCALING: Vector2;
  73492. /**
  73493. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  73494. */
  73495. static SKIP_MATERIALS: boolean;
  73496. /**
  73497. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  73498. *
  73499. * Defaults to true for backwards compatibility.
  73500. */
  73501. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  73502. /**
  73503. * Defines the name of the plugin.
  73504. */
  73505. name: string;
  73506. /**
  73507. * Defines the extension the plugin is able to load.
  73508. */
  73509. extensions: string;
  73510. /** @hidden */
  73511. obj: RegExp;
  73512. /** @hidden */
  73513. group: RegExp;
  73514. /** @hidden */
  73515. mtllib: RegExp;
  73516. /** @hidden */
  73517. usemtl: RegExp;
  73518. /** @hidden */
  73519. smooth: RegExp;
  73520. /** @hidden */
  73521. vertexPattern: RegExp;
  73522. /** @hidden */
  73523. normalPattern: RegExp;
  73524. /** @hidden */
  73525. uvPattern: RegExp;
  73526. /** @hidden */
  73527. facePattern1: RegExp;
  73528. /** @hidden */
  73529. facePattern2: RegExp;
  73530. /** @hidden */
  73531. facePattern3: RegExp;
  73532. /** @hidden */
  73533. facePattern4: RegExp;
  73534. /** @hidden */
  73535. facePattern5: RegExp;
  73536. private _meshLoadOptions;
  73537. /**
  73538. * Creates loader for .OBJ files
  73539. *
  73540. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  73541. */
  73542. constructor(meshLoadOptions?: MeshLoadOptions);
  73543. private static get currentMeshLoadOptions();
  73544. /**
  73545. * Calls synchronously the MTL file attached to this obj.
  73546. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  73547. * Without this function materials are not displayed in the first frame (but displayed after).
  73548. * In consequence it is impossible to get material information in your HTML file
  73549. *
  73550. * @param url The URL of the MTL file
  73551. * @param rootUrl
  73552. * @param onSuccess Callback function to be called when the MTL file is loaded
  73553. * @private
  73554. */
  73555. private _loadMTL;
  73556. /**
  73557. * Instantiates a OBJ file loader plugin.
  73558. * @returns the created plugin
  73559. */
  73560. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  73561. /**
  73562. * If the data string can be loaded directly.
  73563. *
  73564. * @param data string containing the file data
  73565. * @returns if the data can be loaded directly
  73566. */
  73567. canDirectLoad(data: string): boolean;
  73568. /**
  73569. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  73570. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  73571. * @param scene the scene the meshes should be added to
  73572. * @param data the OBJ data to load
  73573. * @param rootUrl root url to load from
  73574. * @param onProgress event that fires when loading progress has occured
  73575. * @param fileName Defines the name of the file to load
  73576. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  73577. */
  73578. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  73579. meshes: AbstractMesh[];
  73580. particleSystems: IParticleSystem[];
  73581. skeletons: Skeleton[];
  73582. animationGroups: AnimationGroup[];
  73583. }>;
  73584. /**
  73585. * Imports all objects from the loaded OBJ data and adds them to the scene
  73586. * @param scene the scene the objects should be added to
  73587. * @param data the OBJ data to load
  73588. * @param rootUrl root url to load from
  73589. * @param onProgress event that fires when loading progress has occured
  73590. * @param fileName Defines the name of the file to load
  73591. * @returns a promise which completes when objects have been loaded to the scene
  73592. */
  73593. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  73594. /**
  73595. * Load into an asset container.
  73596. * @param scene The scene to load into
  73597. * @param data The data to import
  73598. * @param rootUrl The root url for scene and resources
  73599. * @param onProgress The callback when the load progresses
  73600. * @param fileName Defines the name of the file to load
  73601. * @returns The loaded asset container
  73602. */
  73603. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  73604. /**
  73605. * Read the OBJ file and create an Array of meshes.
  73606. * Each mesh contains all information given by the OBJ and the MTL file.
  73607. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  73608. *
  73609. * @param meshesNames
  73610. * @param scene Scene The scene where are displayed the data
  73611. * @param data String The content of the obj file
  73612. * @param rootUrl String The path to the folder
  73613. * @returns Array<AbstractMesh>
  73614. * @private
  73615. */
  73616. private _parseSolid;
  73617. }
  73618. }
  73619. declare module BABYLON {
  73620. /**
  73621. * STL file type loader.
  73622. * This is a babylon scene loader plugin.
  73623. */
  73624. export class STLFileLoader implements ISceneLoaderPlugin {
  73625. /** @hidden */
  73626. solidPattern: RegExp;
  73627. /** @hidden */
  73628. facetsPattern: RegExp;
  73629. /** @hidden */
  73630. normalPattern: RegExp;
  73631. /** @hidden */
  73632. vertexPattern: RegExp;
  73633. /**
  73634. * Defines the name of the plugin.
  73635. */
  73636. name: string;
  73637. /**
  73638. * Defines the extensions the stl loader is able to load.
  73639. * force data to come in as an ArrayBuffer
  73640. * we'll convert to string if it looks like it's an ASCII .stl
  73641. */
  73642. extensions: ISceneLoaderPluginExtensions;
  73643. /**
  73644. * Import meshes into a scene.
  73645. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  73646. * @param scene The scene to import into
  73647. * @param data The data to import
  73648. * @param rootUrl The root url for scene and resources
  73649. * @param meshes The meshes array to import into
  73650. * @param particleSystems The particle systems array to import into
  73651. * @param skeletons The skeletons array to import into
  73652. * @param onError The callback when import fails
  73653. * @returns True if successful or false otherwise
  73654. */
  73655. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  73656. /**
  73657. * Load into a scene.
  73658. * @param scene The scene to load into
  73659. * @param data The data to import
  73660. * @param rootUrl The root url for scene and resources
  73661. * @param onError The callback when import fails
  73662. * @returns true if successful or false otherwise
  73663. */
  73664. load(scene: Scene, data: any, rootUrl: string): boolean;
  73665. /**
  73666. * Load into an asset container.
  73667. * @param scene The scene to load into
  73668. * @param data The data to import
  73669. * @param rootUrl The root url for scene and resources
  73670. * @param onError The callback when import fails
  73671. * @returns The loaded asset container
  73672. */
  73673. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  73674. private _isBinary;
  73675. private _parseBinary;
  73676. private _parseASCII;
  73677. }
  73678. }
  73679. declare module BABYLON {
  73680. /**
  73681. * Class for generating OBJ data from a Babylon scene.
  73682. */
  73683. export class OBJExport {
  73684. /**
  73685. * Exports the geometry of a Mesh array in .OBJ file format (text)
  73686. * @param mesh defines the list of meshes to serialize
  73687. * @param materials defines if materials should be exported
  73688. * @param matlibname defines the name of the associated mtl file
  73689. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  73690. * @returns the OBJ content
  73691. */
  73692. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  73693. /**
  73694. * Exports the material(s) of a mesh in .MTL file format (text)
  73695. * @param mesh defines the mesh to extract the material from
  73696. * @returns the mtl content
  73697. */
  73698. static MTL(mesh: Mesh): string;
  73699. }
  73700. }
  73701. declare module BABYLON {
  73702. /** @hidden */
  73703. export var __IGLTFExporterExtension: number;
  73704. /**
  73705. * Interface for extending the exporter
  73706. * @hidden
  73707. */
  73708. export interface IGLTFExporterExtension {
  73709. /**
  73710. * The name of this extension
  73711. */
  73712. readonly name: string;
  73713. /**
  73714. * Defines whether this extension is enabled
  73715. */
  73716. enabled: boolean;
  73717. /**
  73718. * Defines whether this extension is required
  73719. */
  73720. required: boolean;
  73721. }
  73722. }
  73723. declare module BABYLON.GLTF2.Exporter {
  73724. /** @hidden */
  73725. export var __IGLTFExporterExtensionV2: number;
  73726. /**
  73727. * Interface for a glTF exporter extension
  73728. * @hidden
  73729. */
  73730. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  73731. /**
  73732. * Define this method to modify the default behavior before exporting a texture
  73733. * @param context The context when loading the asset
  73734. * @param babylonTexture The Babylon.js texture
  73735. * @param mimeType The mime-type of the generated image
  73736. * @returns A promise that resolves with the exported texture
  73737. */
  73738. preExportTextureAsync?(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  73739. /**
  73740. * Define this method to get notified when a texture info is created
  73741. * @param context The context when loading the asset
  73742. * @param textureInfo The glTF texture info
  73743. * @param babylonTexture The Babylon.js texture
  73744. */
  73745. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  73746. /**
  73747. * Define this method to modify the default behavior when exporting texture info
  73748. * @param context The context when loading the asset
  73749. * @param meshPrimitive glTF mesh primitive
  73750. * @param babylonSubMesh Babylon submesh
  73751. * @param binaryWriter glTF serializer binary writer instance
  73752. * @returns nullable IMeshPrimitive promise
  73753. */
  73754. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  73755. /**
  73756. * Define this method to modify the default behavior when exporting a node
  73757. * @param context The context when exporting the node
  73758. * @param node glTF node
  73759. * @param babylonNode BabylonJS node
  73760. * @returns nullable INode promise
  73761. */
  73762. postExportNodeAsync?(context: string, node: INode, babylonNode: Node): Promise<INode>;
  73763. /**
  73764. * Define this method to modify the default behavior when exporting a material
  73765. * @param material glTF material
  73766. * @param babylonMaterial BabylonJS material
  73767. * @returns nullable IMaterial promise
  73768. */
  73769. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  73770. /**
  73771. * Define this method to return additional textures to export from a material
  73772. * @param material glTF material
  73773. * @param babylonMaterial BabylonJS material
  73774. * @returns List of textures
  73775. */
  73776. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  73777. /** Gets a boolean indicating that this extension was used */
  73778. wasUsed: boolean;
  73779. /** Gets a boolean indicating that this extension is required for the file to work */
  73780. required: boolean;
  73781. /**
  73782. * Called after the exporter state changes to EXPORTING
  73783. */
  73784. onExporting?(): void;
  73785. }
  73786. }
  73787. declare module BABYLON.GLTF2.Exporter {
  73788. /**
  73789. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  73790. * @hidden
  73791. */
  73792. export class _GLTFMaterialExporter {
  73793. /**
  73794. * Represents the dielectric specular values for R, G and B
  73795. */
  73796. private static readonly _DielectricSpecular;
  73797. /**
  73798. * Allows the maximum specular power to be defined for material calculations
  73799. */
  73800. private static readonly _MaxSpecularPower;
  73801. /**
  73802. * Mapping to store textures
  73803. */
  73804. private _textureMap;
  73805. /**
  73806. * Numeric tolerance value
  73807. */
  73808. private static readonly _Epsilon;
  73809. /**
  73810. * Reference to the glTF Exporter
  73811. */
  73812. private _exporter;
  73813. constructor(exporter: _Exporter);
  73814. /**
  73815. * Specifies if two colors are approximately equal in value
  73816. * @param color1 first color to compare to
  73817. * @param color2 second color to compare to
  73818. * @param epsilon threshold value
  73819. */
  73820. private static FuzzyEquals;
  73821. /**
  73822. * Gets the materials from a Babylon scene and converts them to glTF materials
  73823. * @param scene babylonjs scene
  73824. * @param mimeType texture mime type
  73825. * @param images array of images
  73826. * @param textures array of textures
  73827. * @param materials array of materials
  73828. * @param imageData mapping of texture names to base64 textures
  73829. * @param hasTextureCoords specifies if texture coordinates are present on the material
  73830. */
  73831. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  73832. /**
  73833. * Makes a copy of the glTF material without the texture parameters
  73834. * @param originalMaterial original glTF material
  73835. * @returns glTF material without texture parameters
  73836. */
  73837. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  73838. /**
  73839. * Specifies if the material has any texture parameters present
  73840. * @param material glTF Material
  73841. * @returns boolean specifying if texture parameters are present
  73842. */
  73843. _hasTexturesPresent(material: IMaterial): boolean;
  73844. /**
  73845. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  73846. * @param babylonStandardMaterial
  73847. * @returns glTF Metallic Roughness Material representation
  73848. */
  73849. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  73850. /**
  73851. * Computes the metallic factor
  73852. * @param diffuse diffused value
  73853. * @param specular specular value
  73854. * @param oneMinusSpecularStrength one minus the specular strength
  73855. * @returns metallic value
  73856. */
  73857. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  73858. /**
  73859. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  73860. * @param glTFMaterial glTF material
  73861. * @param babylonMaterial Babylon material
  73862. */
  73863. private static _SetAlphaMode;
  73864. /**
  73865. * Converts a Babylon Standard Material to a glTF Material
  73866. * @param babylonStandardMaterial BJS Standard Material
  73867. * @param mimeType mime type to use for the textures
  73868. * @param images array of glTF image interfaces
  73869. * @param textures array of glTF texture interfaces
  73870. * @param materials array of glTF material interfaces
  73871. * @param imageData map of image file name to data
  73872. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  73873. */
  73874. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  73875. private _finishMaterial;
  73876. /**
  73877. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  73878. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  73879. * @param mimeType mime type to use for the textures
  73880. * @param images array of glTF image interfaces
  73881. * @param textures array of glTF texture interfaces
  73882. * @param materials array of glTF material interfaces
  73883. * @param imageData map of image file name to data
  73884. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  73885. */
  73886. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  73887. /**
  73888. * Converts an image typed array buffer to a base64 image
  73889. * @param buffer typed array buffer
  73890. * @param width width of the image
  73891. * @param height height of the image
  73892. * @param mimeType mimetype of the image
  73893. * @returns base64 image string
  73894. */
  73895. private _createBase64FromCanvasAsync;
  73896. /**
  73897. * Generates a white texture based on the specified width and height
  73898. * @param width width of the texture in pixels
  73899. * @param height height of the texture in pixels
  73900. * @param scene babylonjs scene
  73901. * @returns white texture
  73902. */
  73903. private _createWhiteTexture;
  73904. /**
  73905. * 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
  73906. * @param texture1 first texture to resize
  73907. * @param texture2 second texture to resize
  73908. * @param scene babylonjs scene
  73909. * @returns resized textures or null
  73910. */
  73911. private _resizeTexturesToSameDimensions;
  73912. /**
  73913. * Converts an array of pixels to a Float32Array
  73914. * Throws an error if the pixel format is not supported
  73915. * @param pixels - array buffer containing pixel values
  73916. * @returns Float32 of pixels
  73917. */
  73918. private _convertPixelArrayToFloat32;
  73919. /**
  73920. * Convert Specular Glossiness Textures to Metallic Roughness
  73921. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  73922. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  73923. * @param diffuseTexture texture used to store diffuse information
  73924. * @param specularGlossinessTexture texture used to store specular and glossiness information
  73925. * @param factors specular glossiness material factors
  73926. * @param mimeType the mime type to use for the texture
  73927. * @returns pbr metallic roughness interface or null
  73928. */
  73929. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  73930. /**
  73931. * Converts specular glossiness material properties to metallic roughness
  73932. * @param specularGlossiness interface with specular glossiness material properties
  73933. * @returns interface with metallic roughness material properties
  73934. */
  73935. private _convertSpecularGlossinessToMetallicRoughness;
  73936. /**
  73937. * Calculates the surface reflectance, independent of lighting conditions
  73938. * @param color Color source to calculate brightness from
  73939. * @returns number representing the perceived brightness, or zero if color is undefined
  73940. */
  73941. private _getPerceivedBrightness;
  73942. /**
  73943. * Returns the maximum color component value
  73944. * @param color
  73945. * @returns maximum color component value, or zero if color is null or undefined
  73946. */
  73947. private _getMaxComponent;
  73948. /**
  73949. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  73950. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  73951. * @param mimeType mime type to use for the textures
  73952. * @param images array of glTF image interfaces
  73953. * @param textures array of glTF texture interfaces
  73954. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  73955. * @param imageData map of image file name to data
  73956. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  73957. * @returns glTF PBR Metallic Roughness factors
  73958. */
  73959. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  73960. private _getGLTFTextureSampler;
  73961. private _getGLTFTextureWrapMode;
  73962. private _getGLTFTextureWrapModesSampler;
  73963. /**
  73964. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  73965. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  73966. * @param mimeType mime type to use for the textures
  73967. * @param images array of glTF image interfaces
  73968. * @param textures array of glTF texture interfaces
  73969. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  73970. * @param imageData map of image file name to data
  73971. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  73972. * @returns glTF PBR Metallic Roughness factors
  73973. */
  73974. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  73975. /**
  73976. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  73977. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  73978. * @param mimeType mime type to use for the textures
  73979. * @param images array of glTF image interfaces
  73980. * @param textures array of glTF texture interfaces
  73981. * @param materials array of glTF material interfaces
  73982. * @param imageData map of image file name to data
  73983. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  73984. */
  73985. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  73986. private setMetallicRoughnessPbrMaterial;
  73987. private getPixelsFromTexture;
  73988. /**
  73989. * Extracts a texture from a Babylon texture into file data and glTF data
  73990. * @param babylonTexture Babylon texture to extract
  73991. * @param mimeType Mime Type of the babylonTexture
  73992. * @return glTF texture info, or null if the texture format is not supported
  73993. */
  73994. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  73995. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  73996. /**
  73997. * Builds a texture from base64 string
  73998. * @param base64Texture base64 texture string
  73999. * @param baseTextureName Name to use for the texture
  74000. * @param mimeType image mime type for the texture
  74001. * @param images array of images
  74002. * @param textures array of textures
  74003. * @param imageData map of image data
  74004. * @returns glTF texture info, or null if the texture format is not supported
  74005. */
  74006. private _getTextureInfoFromBase64;
  74007. }
  74008. }
  74009. declare module BABYLON {
  74010. /**
  74011. * Class for holding and downloading glTF file data
  74012. */
  74013. export class GLTFData {
  74014. /**
  74015. * Object which contains the file name as the key and its data as the value
  74016. */
  74017. glTFFiles: {
  74018. [fileName: string]: string | Blob;
  74019. };
  74020. /**
  74021. * Initializes the glTF file object
  74022. */
  74023. constructor();
  74024. /**
  74025. * Downloads the glTF data as files based on their names and data
  74026. */
  74027. downloadFiles(): void;
  74028. }
  74029. }
  74030. declare module BABYLON {
  74031. /**
  74032. * Holds a collection of exporter options and parameters
  74033. */
  74034. export interface IExportOptions {
  74035. /**
  74036. * Function which indicates whether a babylon node should be exported or not
  74037. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  74038. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  74039. */
  74040. shouldExportNode?(node: Node): boolean;
  74041. /**
  74042. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  74043. * @param metadata source metadata to read from
  74044. * @returns the data to store to glTF node extras
  74045. */
  74046. metadataSelector?(metadata: any): any;
  74047. /**
  74048. * The sample rate to bake animation curves
  74049. */
  74050. animationSampleRate?: number;
  74051. /**
  74052. * Begin serialization without waiting for the scene to be ready
  74053. */
  74054. exportWithoutWaitingForScene?: boolean;
  74055. }
  74056. /**
  74057. * Class for generating glTF data from a Babylon scene.
  74058. */
  74059. export class GLTF2Export {
  74060. /**
  74061. * Exports the geometry of the scene to .gltf file format asynchronously
  74062. * @param scene Babylon scene with scene hierarchy information
  74063. * @param filePrefix File prefix to use when generating the glTF file
  74064. * @param options Exporter options
  74065. * @returns Returns an object with a .gltf file and associates texture names
  74066. * as keys and their data and paths as values
  74067. */
  74068. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  74069. private static _PreExportAsync;
  74070. private static _PostExportAsync;
  74071. /**
  74072. * Exports the geometry of the scene to .glb file format asychronously
  74073. * @param scene Babylon scene with scene hierarchy information
  74074. * @param filePrefix File prefix to use when generating glb file
  74075. * @param options Exporter options
  74076. * @returns Returns an object with a .glb filename as key and data as value
  74077. */
  74078. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  74079. }
  74080. }
  74081. declare module BABYLON.GLTF2.Exporter {
  74082. /**
  74083. * @hidden
  74084. */
  74085. export class _GLTFUtilities {
  74086. /**
  74087. * Creates a buffer view based on the supplied arguments
  74088. * @param bufferIndex index value of the specified buffer
  74089. * @param byteOffset byte offset value
  74090. * @param byteLength byte length of the bufferView
  74091. * @param byteStride byte distance between conequential elements
  74092. * @param name name of the buffer view
  74093. * @returns bufferView for glTF
  74094. */
  74095. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  74096. /**
  74097. * Creates an accessor based on the supplied arguments
  74098. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  74099. * @param name The name of the accessor
  74100. * @param type The type of the accessor
  74101. * @param componentType The datatype of components in the attribute
  74102. * @param count The number of attributes referenced by this accessor
  74103. * @param byteOffset The offset relative to the start of the bufferView in bytes
  74104. * @param min Minimum value of each component in this attribute
  74105. * @param max Maximum value of each component in this attribute
  74106. * @returns accessor for glTF
  74107. */
  74108. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  74109. /**
  74110. * Calculates the minimum and maximum values of an array of position floats
  74111. * @param positions Positions array of a mesh
  74112. * @param vertexStart Starting vertex offset to calculate min and max values
  74113. * @param vertexCount Number of vertices to check for min and max values
  74114. * @returns min number array and max number array
  74115. */
  74116. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  74117. min: number[];
  74118. max: number[];
  74119. };
  74120. /**
  74121. * Converts a new right-handed Vector3
  74122. * @param vector vector3 array
  74123. * @returns right-handed Vector3
  74124. */
  74125. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  74126. /**
  74127. * Converts a Vector3 to right-handed
  74128. * @param vector Vector3 to convert to right-handed
  74129. */
  74130. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  74131. /**
  74132. * Converts a three element number array to right-handed
  74133. * @param vector number array to convert to right-handed
  74134. */
  74135. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  74136. /**
  74137. * Converts a new right-handed Vector3
  74138. * @param vector vector3 array
  74139. * @returns right-handed Vector3
  74140. */
  74141. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  74142. /**
  74143. * Converts a Vector3 to right-handed
  74144. * @param vector Vector3 to convert to right-handed
  74145. */
  74146. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  74147. /**
  74148. * Converts a three element number array to right-handed
  74149. * @param vector number array to convert to right-handed
  74150. */
  74151. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  74152. /**
  74153. * Converts a Vector4 to right-handed
  74154. * @param vector Vector4 to convert to right-handed
  74155. */
  74156. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  74157. /**
  74158. * Converts a Vector4 to right-handed
  74159. * @param vector Vector4 to convert to right-handed
  74160. */
  74161. static _GetRightHandedArray4FromRef(vector: number[]): void;
  74162. /**
  74163. * Converts a Quaternion to right-handed
  74164. * @param quaternion Source quaternion to convert to right-handed
  74165. */
  74166. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  74167. /**
  74168. * Converts a Quaternion to right-handed
  74169. * @param quaternion Source quaternion to convert to right-handed
  74170. */
  74171. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  74172. static _NormalizeTangentFromRef(tangent: Vector4): void;
  74173. }
  74174. }
  74175. declare module BABYLON.GLTF2.Exporter {
  74176. /**
  74177. * Converts Babylon Scene into glTF 2.0.
  74178. * @hidden
  74179. */
  74180. export class _Exporter {
  74181. /**
  74182. * Stores the glTF to export
  74183. */
  74184. _glTF: IGLTF;
  74185. /**
  74186. * Stores all generated buffer views, which represents views into the main glTF buffer data
  74187. */
  74188. _bufferViews: IBufferView[];
  74189. /**
  74190. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  74191. */
  74192. _accessors: IAccessor[];
  74193. /**
  74194. * Stores all the generated nodes, which contains transform and/or mesh information per node
  74195. */
  74196. private _nodes;
  74197. /**
  74198. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  74199. */
  74200. private _scenes;
  74201. /**
  74202. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  74203. */
  74204. private _meshes;
  74205. /**
  74206. * Stores all the generated material information, which represents the appearance of each primitive
  74207. */
  74208. _materials: IMaterial[];
  74209. _materialMap: {
  74210. [materialID: number]: number;
  74211. };
  74212. /**
  74213. * Stores all the generated texture information, which is referenced by glTF materials
  74214. */
  74215. _textures: ITexture[];
  74216. /**
  74217. * Stores all the generated image information, which is referenced by glTF textures
  74218. */
  74219. _images: IImage[];
  74220. /**
  74221. * Stores all the texture samplers
  74222. */
  74223. _samplers: ISampler[];
  74224. /**
  74225. * Stores all the generated animation samplers, which is referenced by glTF animations
  74226. */
  74227. /**
  74228. * Stores the animations for glTF models
  74229. */
  74230. private _animations;
  74231. /**
  74232. * Stores the total amount of bytes stored in the glTF buffer
  74233. */
  74234. private _totalByteLength;
  74235. /**
  74236. * Stores a reference to the Babylon scene containing the source geometry and material information
  74237. */
  74238. _babylonScene: Scene;
  74239. /**
  74240. * Stores a map of the image data, where the key is the file name and the value
  74241. * is the image data
  74242. */
  74243. _imageData: {
  74244. [fileName: string]: {
  74245. data: Uint8Array;
  74246. mimeType: ImageMimeType;
  74247. };
  74248. };
  74249. /**
  74250. * Stores a map of the unique id of a node to its index in the node array
  74251. */
  74252. private _nodeMap;
  74253. /**
  74254. * Specifies if the Babylon scene should be converted to right-handed on export
  74255. */
  74256. _convertToRightHandedSystem: boolean;
  74257. /**
  74258. * Baked animation sample rate
  74259. */
  74260. private _animationSampleRate;
  74261. private _options;
  74262. private _localEngine;
  74263. _glTFMaterialExporter: _GLTFMaterialExporter;
  74264. private _extensions;
  74265. private static _ExtensionNames;
  74266. private static _ExtensionFactories;
  74267. private _applyExtension;
  74268. private _applyExtensions;
  74269. _extensionsPreExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  74270. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  74271. _extensionsPostExportNodeAsync(context: string, node: INode, babylonNode: Node): Promise<Nullable<INode>>;
  74272. _extensionsPostExportMaterialAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  74273. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  74274. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  74275. private _forEachExtensions;
  74276. private _extensionsOnExporting;
  74277. /**
  74278. * Load glTF serializer extensions
  74279. */
  74280. private _loadExtensions;
  74281. /**
  74282. * Creates a glTF Exporter instance, which can accept optional exporter options
  74283. * @param babylonScene Babylon scene object
  74284. * @param options Options to modify the behavior of the exporter
  74285. */
  74286. constructor(babylonScene: Scene, options?: IExportOptions);
  74287. dispose(): void;
  74288. /**
  74289. * Registers a glTF exporter extension
  74290. * @param name Name of the extension to export
  74291. * @param factory The factory function that creates the exporter extension
  74292. */
  74293. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  74294. /**
  74295. * Un-registers an exporter extension
  74296. * @param name The name fo the exporter extension
  74297. * @returns A boolean indicating whether the extension has been un-registered
  74298. */
  74299. static UnregisterExtension(name: string): boolean;
  74300. /**
  74301. * Lazy load a local engine with premultiplied alpha set to false
  74302. */
  74303. _getLocalEngine(): Engine;
  74304. private reorderIndicesBasedOnPrimitiveMode;
  74305. /**
  74306. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  74307. * clock-wise during export to glTF
  74308. * @param submesh BabylonJS submesh
  74309. * @param primitiveMode Primitive mode of the mesh
  74310. * @param sideOrientation the winding order of the submesh
  74311. * @param vertexBufferKind The type of vertex attribute
  74312. * @param meshAttributeArray The vertex attribute data
  74313. * @param byteOffset The offset to the binary data
  74314. * @param binaryWriter The binary data for the glTF file
  74315. */
  74316. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  74317. /**
  74318. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  74319. * clock-wise during export to glTF
  74320. * @param submesh BabylonJS submesh
  74321. * @param primitiveMode Primitive mode of the mesh
  74322. * @param sideOrientation the winding order of the submesh
  74323. * @param vertexBufferKind The type of vertex attribute
  74324. * @param meshAttributeArray The vertex attribute data
  74325. * @param byteOffset The offset to the binary data
  74326. * @param binaryWriter The binary data for the glTF file
  74327. */
  74328. private reorderTriangleFillMode;
  74329. /**
  74330. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  74331. * clock-wise during export to glTF
  74332. * @param submesh BabylonJS submesh
  74333. * @param primitiveMode Primitive mode of the mesh
  74334. * @param sideOrientation the winding order of the submesh
  74335. * @param vertexBufferKind The type of vertex attribute
  74336. * @param meshAttributeArray The vertex attribute data
  74337. * @param byteOffset The offset to the binary data
  74338. * @param binaryWriter The binary data for the glTF file
  74339. */
  74340. private reorderTriangleStripDrawMode;
  74341. /**
  74342. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  74343. * clock-wise during export to glTF
  74344. * @param submesh BabylonJS submesh
  74345. * @param primitiveMode Primitive mode of the mesh
  74346. * @param sideOrientation the winding order of the submesh
  74347. * @param vertexBufferKind The type of vertex attribute
  74348. * @param meshAttributeArray The vertex attribute data
  74349. * @param byteOffset The offset to the binary data
  74350. * @param binaryWriter The binary data for the glTF file
  74351. */
  74352. private reorderTriangleFanMode;
  74353. /**
  74354. * Writes the vertex attribute data to binary
  74355. * @param vertices The vertices to write to the binary writer
  74356. * @param byteOffset The offset into the binary writer to overwrite binary data
  74357. * @param vertexAttributeKind The vertex attribute type
  74358. * @param meshAttributeArray The vertex attribute data
  74359. * @param binaryWriter The writer containing the binary data
  74360. */
  74361. private writeVertexAttributeData;
  74362. /**
  74363. * Writes mesh attribute data to a data buffer
  74364. * Returns the bytelength of the data
  74365. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  74366. * @param meshAttributeArray Array containing the attribute data
  74367. * @param binaryWriter The buffer to write the binary data to
  74368. * @param indices Used to specify the order of the vertex data
  74369. */
  74370. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter): void;
  74371. /**
  74372. * Generates glTF json data
  74373. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  74374. * @param glTFPrefix Text to use when prefixing a glTF file
  74375. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  74376. * @returns json data as string
  74377. */
  74378. private generateJSON;
  74379. /**
  74380. * Generates data for .gltf and .bin files based on the glTF prefix string
  74381. * @param glTFPrefix Text to use when prefixing a glTF file
  74382. * @param dispose Dispose the exporter
  74383. * @returns GLTFData with glTF file data
  74384. */
  74385. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  74386. /**
  74387. * Creates a binary buffer for glTF
  74388. * @returns array buffer for binary data
  74389. */
  74390. private _generateBinaryAsync;
  74391. /**
  74392. * Pads the number to a multiple of 4
  74393. * @param num number to pad
  74394. * @returns padded number
  74395. */
  74396. private _getPadding;
  74397. /**
  74398. * @hidden
  74399. */
  74400. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  74401. /**
  74402. * Sets the TRS for each node
  74403. * @param node glTF Node for storing the transformation data
  74404. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  74405. */
  74406. private setNodeTransformation;
  74407. private getVertexBufferFromMesh;
  74408. /**
  74409. * Creates a bufferview based on the vertices type for the Babylon mesh
  74410. * @param kind Indicates the type of vertices data
  74411. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  74412. * @param binaryWriter The buffer to write the bufferview data to
  74413. */
  74414. private createBufferViewKind;
  74415. /**
  74416. * The primitive mode of the Babylon mesh
  74417. * @param babylonMesh The BabylonJS mesh
  74418. */
  74419. private getMeshPrimitiveMode;
  74420. /**
  74421. * Sets the primitive mode of the glTF mesh primitive
  74422. * @param meshPrimitive glTF mesh primitive
  74423. * @param primitiveMode The primitive mode
  74424. */
  74425. private setPrimitiveMode;
  74426. /**
  74427. * Sets the vertex attribute accessor based of the glTF mesh primitive
  74428. * @param meshPrimitive glTF mesh primitive
  74429. * @param attributeKind vertex attribute
  74430. * @returns boolean specifying if uv coordinates are present
  74431. */
  74432. private setAttributeKind;
  74433. /**
  74434. * Sets data for the primitive attributes of each submesh
  74435. * @param mesh glTF Mesh object to store the primitive attribute information
  74436. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  74437. * @param binaryWriter Buffer to write the attribute data to
  74438. */
  74439. private setPrimitiveAttributesAsync;
  74440. /**
  74441. * Creates a glTF scene based on the array of meshes
  74442. * Returns the the total byte offset
  74443. * @param babylonScene Babylon scene to get the mesh data from
  74444. * @param binaryWriter Buffer to write binary data to
  74445. */
  74446. private createSceneAsync;
  74447. /**
  74448. * Creates a mapping of Node unique id to node index and handles animations
  74449. * @param babylonScene Babylon Scene
  74450. * @param nodes Babylon transform nodes
  74451. * @param binaryWriter Buffer to write binary data to
  74452. * @returns Node mapping of unique id to index
  74453. */
  74454. private createNodeMapAndAnimationsAsync;
  74455. /**
  74456. * Creates a glTF node from a Babylon mesh
  74457. * @param babylonMesh Source Babylon mesh
  74458. * @param binaryWriter Buffer for storing geometry data
  74459. * @returns glTF node
  74460. */
  74461. private createNodeAsync;
  74462. }
  74463. /**
  74464. * @hidden
  74465. *
  74466. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  74467. */
  74468. export class _BinaryWriter {
  74469. /**
  74470. * Array buffer which stores all binary data
  74471. */
  74472. private _arrayBuffer;
  74473. /**
  74474. * View of the array buffer
  74475. */
  74476. private _dataView;
  74477. /**
  74478. * byte offset of data in array buffer
  74479. */
  74480. private _byteOffset;
  74481. /**
  74482. * Initialize binary writer with an initial byte length
  74483. * @param byteLength Initial byte length of the array buffer
  74484. */
  74485. constructor(byteLength: number);
  74486. /**
  74487. * Resize the array buffer to the specified byte length
  74488. * @param byteLength
  74489. */
  74490. private resizeBuffer;
  74491. /**
  74492. * Get an array buffer with the length of the byte offset
  74493. * @returns ArrayBuffer resized to the byte offset
  74494. */
  74495. getArrayBuffer(): ArrayBuffer;
  74496. /**
  74497. * Get the byte offset of the array buffer
  74498. * @returns byte offset
  74499. */
  74500. getByteOffset(): number;
  74501. /**
  74502. * Stores an UInt8 in the array buffer
  74503. * @param entry
  74504. * @param byteOffset If defined, specifies where to set the value as an offset.
  74505. */
  74506. setUInt8(entry: number, byteOffset?: number): void;
  74507. /**
  74508. * Gets an UInt32 in the array buffer
  74509. * @param entry
  74510. * @param byteOffset If defined, specifies where to set the value as an offset.
  74511. */
  74512. getUInt32(byteOffset: number): number;
  74513. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  74514. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  74515. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  74516. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  74517. /**
  74518. * Stores a Float32 in the array buffer
  74519. * @param entry
  74520. */
  74521. setFloat32(entry: number, byteOffset?: number): void;
  74522. /**
  74523. * Stores an UInt32 in the array buffer
  74524. * @param entry
  74525. * @param byteOffset If defined, specifies where to set the value as an offset.
  74526. */
  74527. setUInt32(entry: number, byteOffset?: number): void;
  74528. }
  74529. }
  74530. declare module BABYLON.GLTF2.Exporter {
  74531. /**
  74532. * @hidden
  74533. * Interface to store animation data.
  74534. */
  74535. export interface _IAnimationData {
  74536. /**
  74537. * Keyframe data.
  74538. */
  74539. inputs: number[];
  74540. /**
  74541. * Value data.
  74542. */
  74543. outputs: number[][];
  74544. /**
  74545. * Animation interpolation data.
  74546. */
  74547. samplerInterpolation: AnimationSamplerInterpolation;
  74548. /**
  74549. * Minimum keyframe value.
  74550. */
  74551. inputsMin: number;
  74552. /**
  74553. * Maximum keyframe value.
  74554. */
  74555. inputsMax: number;
  74556. }
  74557. /**
  74558. * @hidden
  74559. */
  74560. export interface _IAnimationInfo {
  74561. /**
  74562. * The target channel for the animation
  74563. */
  74564. animationChannelTargetPath: AnimationChannelTargetPath;
  74565. /**
  74566. * The glTF accessor type for the data.
  74567. */
  74568. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  74569. /**
  74570. * Specifies if quaternions should be used.
  74571. */
  74572. useQuaternion: boolean;
  74573. }
  74574. /**
  74575. * @hidden
  74576. * Utility class for generating glTF animation data from BabylonJS.
  74577. */
  74578. export class _GLTFAnimation {
  74579. /**
  74580. * @ignore
  74581. *
  74582. * Creates glTF channel animation from BabylonJS animation.
  74583. * @param babylonTransformNode - BabylonJS mesh.
  74584. * @param animation - animation.
  74585. * @param animationChannelTargetPath - The target animation channel.
  74586. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  74587. * @param useQuaternion - Specifies if quaternions are used.
  74588. * @returns nullable IAnimationData
  74589. */
  74590. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  74591. private static _DeduceAnimationInfo;
  74592. /**
  74593. * @ignore
  74594. * Create node animations from the transform node animations
  74595. * @param babylonNode
  74596. * @param runtimeGLTFAnimation
  74597. * @param idleGLTFAnimations
  74598. * @param nodeMap
  74599. * @param nodes
  74600. * @param binaryWriter
  74601. * @param bufferViews
  74602. * @param accessors
  74603. * @param convertToRightHandedSystem
  74604. */
  74605. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  74606. [key: number]: number;
  74607. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  74608. /**
  74609. * @ignore
  74610. * Create node animations from the animation groups
  74611. * @param babylonScene
  74612. * @param glTFAnimations
  74613. * @param nodeMap
  74614. * @param nodes
  74615. * @param binaryWriter
  74616. * @param bufferViews
  74617. * @param accessors
  74618. * @param convertToRightHandedSystem
  74619. */
  74620. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  74621. [key: number]: number;
  74622. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  74623. private static AddAnimation;
  74624. /**
  74625. * Create a baked animation
  74626. * @param babylonTransformNode BabylonJS mesh
  74627. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  74628. * @param animationChannelTargetPath animation target channel
  74629. * @param minFrame minimum animation frame
  74630. * @param maxFrame maximum animation frame
  74631. * @param fps frames per second of the animation
  74632. * @param inputs input key frames of the animation
  74633. * @param outputs output key frame data of the animation
  74634. * @param convertToRightHandedSystem converts the values to right-handed
  74635. * @param useQuaternion specifies if quaternions should be used
  74636. */
  74637. private static _CreateBakedAnimation;
  74638. private static _ConvertFactorToVector3OrQuaternion;
  74639. private static _SetInterpolatedValue;
  74640. /**
  74641. * Creates linear animation from the animation key frames
  74642. * @param babylonTransformNode BabylonJS mesh
  74643. * @param animation BabylonJS animation
  74644. * @param animationChannelTargetPath The target animation channel
  74645. * @param frameDelta The difference between the last and first frame of the animation
  74646. * @param inputs Array to store the key frame times
  74647. * @param outputs Array to store the key frame data
  74648. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  74649. * @param useQuaternion Specifies if quaternions are used in the animation
  74650. */
  74651. private static _CreateLinearOrStepAnimation;
  74652. /**
  74653. * Creates cubic spline animation from the animation key frames
  74654. * @param babylonTransformNode BabylonJS mesh
  74655. * @param animation BabylonJS animation
  74656. * @param animationChannelTargetPath The target animation channel
  74657. * @param frameDelta The difference between the last and first frame of the animation
  74658. * @param inputs Array to store the key frame times
  74659. * @param outputs Array to store the key frame data
  74660. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  74661. * @param useQuaternion Specifies if quaternions are used in the animation
  74662. */
  74663. private static _CreateCubicSplineAnimation;
  74664. private static _GetBasePositionRotationOrScale;
  74665. /**
  74666. * Adds a key frame value
  74667. * @param keyFrame
  74668. * @param animation
  74669. * @param outputs
  74670. * @param animationChannelTargetPath
  74671. * @param basePositionRotationOrScale
  74672. * @param convertToRightHandedSystem
  74673. * @param useQuaternion
  74674. */
  74675. private static _AddKeyframeValue;
  74676. /**
  74677. * Determine the interpolation based on the key frames
  74678. * @param keyFrames
  74679. * @param animationChannelTargetPath
  74680. * @param useQuaternion
  74681. */
  74682. private static _DeduceInterpolation;
  74683. /**
  74684. * Adds an input tangent or output tangent to the output data
  74685. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  74686. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  74687. * @param outputs The animation data by keyframe
  74688. * @param animationChannelTargetPath The target animation channel
  74689. * @param interpolation The interpolation type
  74690. * @param keyFrame The key frame with the animation data
  74691. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  74692. * @param useQuaternion Specifies if quaternions are used
  74693. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  74694. */
  74695. private static AddSplineTangent;
  74696. /**
  74697. * Get the minimum and maximum key frames' frame values
  74698. * @param keyFrames animation key frames
  74699. * @returns the minimum and maximum key frame value
  74700. */
  74701. private static calculateMinMaxKeyFrames;
  74702. }
  74703. }
  74704. declare module BABYLON.GLTF2.Exporter {
  74705. /** @hidden */
  74706. export var textureTransformPixelShader: {
  74707. name: string;
  74708. shader: string;
  74709. };
  74710. }
  74711. declare module BABYLON.GLTF2.Exporter.Extensions {
  74712. /**
  74713. * @hidden
  74714. */
  74715. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  74716. private _recordedTextures;
  74717. /** Name of this extension */
  74718. readonly name: string;
  74719. /** Defines whether this extension is enabled */
  74720. enabled: boolean;
  74721. /** Defines whether this extension is required */
  74722. required: boolean;
  74723. /** Reference to the glTF exporter */
  74724. private _wasUsed;
  74725. constructor(exporter: _Exporter);
  74726. dispose(): void;
  74727. /** @hidden */
  74728. get wasUsed(): boolean;
  74729. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  74730. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  74731. /**
  74732. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  74733. * @param babylonTexture
  74734. * @param offset
  74735. * @param rotation
  74736. * @param scale
  74737. * @param scene
  74738. */
  74739. private _textureTransformTextureAsync;
  74740. }
  74741. }
  74742. declare module BABYLON.GLTF2.Exporter.Extensions {
  74743. /**
  74744. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  74745. */
  74746. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  74747. /** The name of this extension. */
  74748. readonly name: string;
  74749. /** Defines whether this extension is enabled. */
  74750. enabled: boolean;
  74751. /** Defines whether this extension is required */
  74752. required: boolean;
  74753. /** Reference to the glTF exporter */
  74754. private _exporter;
  74755. private _lights;
  74756. /** @hidden */
  74757. constructor(exporter: _Exporter);
  74758. /** @hidden */
  74759. dispose(): void;
  74760. /** @hidden */
  74761. get wasUsed(): boolean;
  74762. /** @hidden */
  74763. onExporting(): void;
  74764. /**
  74765. * Define this method to modify the default behavior when exporting a node
  74766. * @param context The context when exporting the node
  74767. * @param node glTF node
  74768. * @param babylonNode BabylonJS node
  74769. * @returns nullable INode promise
  74770. */
  74771. postExportNodeAsync(context: string, node: INode, babylonNode: Node): Promise<INode>;
  74772. }
  74773. }
  74774. declare module BABYLON.GLTF2.Exporter.Extensions {
  74775. /**
  74776. * @hidden
  74777. */
  74778. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  74779. /** Name of this extension */
  74780. readonly name: string;
  74781. /** Defines whether this extension is enabled */
  74782. enabled: boolean;
  74783. /** Defines whether this extension is required */
  74784. required: boolean;
  74785. /** Reference to the glTF exporter */
  74786. private _textureInfos;
  74787. private _exportedTextures;
  74788. private _wasUsed;
  74789. constructor(exporter: _Exporter);
  74790. dispose(): void;
  74791. /** @hidden */
  74792. get wasUsed(): boolean;
  74793. private _getTextureIndex;
  74794. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  74795. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  74796. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  74797. }
  74798. }
  74799. declare module BABYLON {
  74800. /**
  74801. * Class for generating STL data from a Babylon scene.
  74802. */
  74803. export class STLExport {
  74804. /**
  74805. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  74806. * @param meshes list defines the mesh to serialize
  74807. * @param download triggers the automatic download of the file.
  74808. * @param fileName changes the downloads fileName.
  74809. * @param binary changes the STL to a binary type.
  74810. * @param isLittleEndian toggle for binary type exporter.
  74811. * @returns the STL as UTF8 string
  74812. */
  74813. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  74814. }
  74815. }
  74816. declare module "babylonjs-gltf2interface" {
  74817. export = BABYLON.GLTF2;
  74818. }
  74819. /**
  74820. * Module for glTF 2.0 Interface
  74821. */
  74822. declare module BABYLON.GLTF2 {
  74823. /**
  74824. * The datatype of the components in the attribute
  74825. */
  74826. const enum AccessorComponentType {
  74827. /**
  74828. * Byte
  74829. */
  74830. BYTE = 5120,
  74831. /**
  74832. * Unsigned Byte
  74833. */
  74834. UNSIGNED_BYTE = 5121,
  74835. /**
  74836. * Short
  74837. */
  74838. SHORT = 5122,
  74839. /**
  74840. * Unsigned Short
  74841. */
  74842. UNSIGNED_SHORT = 5123,
  74843. /**
  74844. * Unsigned Int
  74845. */
  74846. UNSIGNED_INT = 5125,
  74847. /**
  74848. * Float
  74849. */
  74850. FLOAT = 5126,
  74851. }
  74852. /**
  74853. * Specifies if the attirbute is a scalar, vector, or matrix
  74854. */
  74855. const enum AccessorType {
  74856. /**
  74857. * Scalar
  74858. */
  74859. SCALAR = "SCALAR",
  74860. /**
  74861. * Vector2
  74862. */
  74863. VEC2 = "VEC2",
  74864. /**
  74865. * Vector3
  74866. */
  74867. VEC3 = "VEC3",
  74868. /**
  74869. * Vector4
  74870. */
  74871. VEC4 = "VEC4",
  74872. /**
  74873. * Matrix2x2
  74874. */
  74875. MAT2 = "MAT2",
  74876. /**
  74877. * Matrix3x3
  74878. */
  74879. MAT3 = "MAT3",
  74880. /**
  74881. * Matrix4x4
  74882. */
  74883. MAT4 = "MAT4",
  74884. }
  74885. /**
  74886. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  74887. */
  74888. const enum AnimationChannelTargetPath {
  74889. /**
  74890. * Translation
  74891. */
  74892. TRANSLATION = "translation",
  74893. /**
  74894. * Rotation
  74895. */
  74896. ROTATION = "rotation",
  74897. /**
  74898. * Scale
  74899. */
  74900. SCALE = "scale",
  74901. /**
  74902. * Weights
  74903. */
  74904. WEIGHTS = "weights",
  74905. }
  74906. /**
  74907. * Interpolation algorithm
  74908. */
  74909. const enum AnimationSamplerInterpolation {
  74910. /**
  74911. * The animated values are linearly interpolated between keyframes
  74912. */
  74913. LINEAR = "LINEAR",
  74914. /**
  74915. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  74916. */
  74917. STEP = "STEP",
  74918. /**
  74919. * The animation's interpolation is computed using a cubic spline with specified tangents
  74920. */
  74921. CUBICSPLINE = "CUBICSPLINE",
  74922. }
  74923. /**
  74924. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  74925. */
  74926. const enum CameraType {
  74927. /**
  74928. * A perspective camera containing properties to create a perspective projection matrix
  74929. */
  74930. PERSPECTIVE = "perspective",
  74931. /**
  74932. * An orthographic camera containing properties to create an orthographic projection matrix
  74933. */
  74934. ORTHOGRAPHIC = "orthographic",
  74935. }
  74936. /**
  74937. * The mime-type of the image
  74938. */
  74939. const enum ImageMimeType {
  74940. /**
  74941. * JPEG Mime-type
  74942. */
  74943. JPEG = "image/jpeg",
  74944. /**
  74945. * PNG Mime-type
  74946. */
  74947. PNG = "image/png",
  74948. }
  74949. /**
  74950. * The alpha rendering mode of the material
  74951. */
  74952. const enum MaterialAlphaMode {
  74953. /**
  74954. * The alpha value is ignored and the rendered output is fully opaque
  74955. */
  74956. OPAQUE = "OPAQUE",
  74957. /**
  74958. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  74959. */
  74960. MASK = "MASK",
  74961. /**
  74962. * 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)
  74963. */
  74964. BLEND = "BLEND",
  74965. }
  74966. /**
  74967. * The type of the primitives to render
  74968. */
  74969. const enum MeshPrimitiveMode {
  74970. /**
  74971. * Points
  74972. */
  74973. POINTS = 0,
  74974. /**
  74975. * Lines
  74976. */
  74977. LINES = 1,
  74978. /**
  74979. * Line Loop
  74980. */
  74981. LINE_LOOP = 2,
  74982. /**
  74983. * Line Strip
  74984. */
  74985. LINE_STRIP = 3,
  74986. /**
  74987. * Triangles
  74988. */
  74989. TRIANGLES = 4,
  74990. /**
  74991. * Triangle Strip
  74992. */
  74993. TRIANGLE_STRIP = 5,
  74994. /**
  74995. * Triangle Fan
  74996. */
  74997. TRIANGLE_FAN = 6,
  74998. }
  74999. /**
  75000. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  75001. */
  75002. const enum TextureMagFilter {
  75003. /**
  75004. * Nearest
  75005. */
  75006. NEAREST = 9728,
  75007. /**
  75008. * Linear
  75009. */
  75010. LINEAR = 9729,
  75011. }
  75012. /**
  75013. * Minification filter. All valid values correspond to WebGL enums
  75014. */
  75015. const enum TextureMinFilter {
  75016. /**
  75017. * Nearest
  75018. */
  75019. NEAREST = 9728,
  75020. /**
  75021. * Linear
  75022. */
  75023. LINEAR = 9729,
  75024. /**
  75025. * Nearest Mip-Map Nearest
  75026. */
  75027. NEAREST_MIPMAP_NEAREST = 9984,
  75028. /**
  75029. * Linear Mipmap Nearest
  75030. */
  75031. LINEAR_MIPMAP_NEAREST = 9985,
  75032. /**
  75033. * Nearest Mipmap Linear
  75034. */
  75035. NEAREST_MIPMAP_LINEAR = 9986,
  75036. /**
  75037. * Linear Mipmap Linear
  75038. */
  75039. LINEAR_MIPMAP_LINEAR = 9987,
  75040. }
  75041. /**
  75042. * S (U) wrapping mode. All valid values correspond to WebGL enums
  75043. */
  75044. const enum TextureWrapMode {
  75045. /**
  75046. * Clamp to Edge
  75047. */
  75048. CLAMP_TO_EDGE = 33071,
  75049. /**
  75050. * Mirrored Repeat
  75051. */
  75052. MIRRORED_REPEAT = 33648,
  75053. /**
  75054. * Repeat
  75055. */
  75056. REPEAT = 10497,
  75057. }
  75058. /**
  75059. * glTF Property
  75060. */
  75061. interface IProperty {
  75062. /**
  75063. * Dictionary object with extension-specific objects
  75064. */
  75065. extensions?: {
  75066. [key: string]: any;
  75067. };
  75068. /**
  75069. * Application-Specific data
  75070. */
  75071. extras?: any;
  75072. }
  75073. /**
  75074. * glTF Child of Root Property
  75075. */
  75076. interface IChildRootProperty extends IProperty {
  75077. /**
  75078. * The user-defined name of this object
  75079. */
  75080. name?: string;
  75081. }
  75082. /**
  75083. * Indices of those attributes that deviate from their initialization value
  75084. */
  75085. interface IAccessorSparseIndices extends IProperty {
  75086. /**
  75087. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  75088. */
  75089. bufferView: number;
  75090. /**
  75091. * The offset relative to the start of the bufferView in bytes. Must be aligned
  75092. */
  75093. byteOffset?: number;
  75094. /**
  75095. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  75096. */
  75097. componentType: AccessorComponentType;
  75098. }
  75099. /**
  75100. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  75101. */
  75102. interface IAccessorSparseValues extends IProperty {
  75103. /**
  75104. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  75105. */
  75106. bufferView: number;
  75107. /**
  75108. * The offset relative to the start of the bufferView in bytes. Must be aligned
  75109. */
  75110. byteOffset?: number;
  75111. }
  75112. /**
  75113. * Sparse storage of attributes that deviate from their initialization value
  75114. */
  75115. interface IAccessorSparse extends IProperty {
  75116. /**
  75117. * The number of attributes encoded in this sparse accessor
  75118. */
  75119. count: number;
  75120. /**
  75121. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  75122. */
  75123. indices: IAccessorSparseIndices;
  75124. /**
  75125. * 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
  75126. */
  75127. values: IAccessorSparseValues;
  75128. }
  75129. /**
  75130. * 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
  75131. */
  75132. interface IAccessor extends IChildRootProperty {
  75133. /**
  75134. * The index of the bufferview
  75135. */
  75136. bufferView?: number;
  75137. /**
  75138. * The offset relative to the start of the bufferView in bytes
  75139. */
  75140. byteOffset?: number;
  75141. /**
  75142. * The datatype of components in the attribute
  75143. */
  75144. componentType: AccessorComponentType;
  75145. /**
  75146. * Specifies whether integer data values should be normalized
  75147. */
  75148. normalized?: boolean;
  75149. /**
  75150. * The number of attributes referenced by this accessor
  75151. */
  75152. count: number;
  75153. /**
  75154. * Specifies if the attribute is a scalar, vector, or matrix
  75155. */
  75156. type: AccessorType;
  75157. /**
  75158. * Maximum value of each component in this attribute
  75159. */
  75160. max?: number[];
  75161. /**
  75162. * Minimum value of each component in this attribute
  75163. */
  75164. min?: number[];
  75165. /**
  75166. * Sparse storage of attributes that deviate from their initialization value
  75167. */
  75168. sparse?: IAccessorSparse;
  75169. }
  75170. /**
  75171. * Targets an animation's sampler at a node's property
  75172. */
  75173. interface IAnimationChannel extends IProperty {
  75174. /**
  75175. * The index of a sampler in this animation used to compute the value for the target
  75176. */
  75177. sampler: number;
  75178. /**
  75179. * The index of the node and TRS property to target
  75180. */
  75181. target: IAnimationChannelTarget;
  75182. }
  75183. /**
  75184. * The index of the node and TRS property that an animation channel targets
  75185. */
  75186. interface IAnimationChannelTarget extends IProperty {
  75187. /**
  75188. * The index of the node to target
  75189. */
  75190. node: number;
  75191. /**
  75192. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  75193. */
  75194. path: AnimationChannelTargetPath;
  75195. }
  75196. /**
  75197. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  75198. */
  75199. interface IAnimationSampler extends IProperty {
  75200. /**
  75201. * The index of an accessor containing keyframe input values, e.g., time
  75202. */
  75203. input: number;
  75204. /**
  75205. * Interpolation algorithm
  75206. */
  75207. interpolation?: AnimationSamplerInterpolation;
  75208. /**
  75209. * The index of an accessor, containing keyframe output values
  75210. */
  75211. output: number;
  75212. }
  75213. /**
  75214. * A keyframe animation
  75215. */
  75216. interface IAnimation extends IChildRootProperty {
  75217. /**
  75218. * An array of channels, each of which targets an animation's sampler at a node's property
  75219. */
  75220. channels: IAnimationChannel[];
  75221. /**
  75222. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  75223. */
  75224. samplers: IAnimationSampler[];
  75225. }
  75226. /**
  75227. * Metadata about the glTF asset
  75228. */
  75229. interface IAsset extends IChildRootProperty {
  75230. /**
  75231. * A copyright message suitable for display to credit the content creator
  75232. */
  75233. copyright?: string;
  75234. /**
  75235. * Tool that generated this glTF model. Useful for debugging
  75236. */
  75237. generator?: string;
  75238. /**
  75239. * The glTF version that this asset targets
  75240. */
  75241. version: string;
  75242. /**
  75243. * The minimum glTF version that this asset targets
  75244. */
  75245. minVersion?: string;
  75246. }
  75247. /**
  75248. * A buffer points to binary geometry, animation, or skins
  75249. */
  75250. interface IBuffer extends IChildRootProperty {
  75251. /**
  75252. * 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
  75253. */
  75254. uri?: string;
  75255. /**
  75256. * The length of the buffer in bytes
  75257. */
  75258. byteLength: number;
  75259. }
  75260. /**
  75261. * A view into a buffer generally representing a subset of the buffer
  75262. */
  75263. interface IBufferView extends IChildRootProperty {
  75264. /**
  75265. * The index of the buffer
  75266. */
  75267. buffer: number;
  75268. /**
  75269. * The offset into the buffer in bytes
  75270. */
  75271. byteOffset?: number;
  75272. /**
  75273. * The lenth of the bufferView in bytes
  75274. */
  75275. byteLength: number;
  75276. /**
  75277. * The stride, in bytes
  75278. */
  75279. byteStride?: number;
  75280. }
  75281. /**
  75282. * An orthographic camera containing properties to create an orthographic projection matrix
  75283. */
  75284. interface ICameraOrthographic extends IProperty {
  75285. /**
  75286. * The floating-point horizontal magnification of the view. Must not be zero
  75287. */
  75288. xmag: number;
  75289. /**
  75290. * The floating-point vertical magnification of the view. Must not be zero
  75291. */
  75292. ymag: number;
  75293. /**
  75294. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  75295. */
  75296. zfar: number;
  75297. /**
  75298. * The floating-point distance to the near clipping plane
  75299. */
  75300. znear: number;
  75301. }
  75302. /**
  75303. * A perspective camera containing properties to create a perspective projection matrix
  75304. */
  75305. interface ICameraPerspective extends IProperty {
  75306. /**
  75307. * The floating-point aspect ratio of the field of view
  75308. */
  75309. aspectRatio?: number;
  75310. /**
  75311. * The floating-point vertical field of view in radians
  75312. */
  75313. yfov: number;
  75314. /**
  75315. * The floating-point distance to the far clipping plane
  75316. */
  75317. zfar?: number;
  75318. /**
  75319. * The floating-point distance to the near clipping plane
  75320. */
  75321. znear: number;
  75322. }
  75323. /**
  75324. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  75325. */
  75326. interface ICamera extends IChildRootProperty {
  75327. /**
  75328. * An orthographic camera containing properties to create an orthographic projection matrix
  75329. */
  75330. orthographic?: ICameraOrthographic;
  75331. /**
  75332. * A perspective camera containing properties to create a perspective projection matrix
  75333. */
  75334. perspective?: ICameraPerspective;
  75335. /**
  75336. * Specifies if the camera uses a perspective or orthographic projection
  75337. */
  75338. type: CameraType;
  75339. }
  75340. /**
  75341. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  75342. */
  75343. interface IImage extends IChildRootProperty {
  75344. /**
  75345. * 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
  75346. */
  75347. uri?: string;
  75348. /**
  75349. * The image's MIME type
  75350. */
  75351. mimeType?: ImageMimeType;
  75352. /**
  75353. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  75354. */
  75355. bufferView?: number;
  75356. }
  75357. /**
  75358. * Material Normal Texture Info
  75359. */
  75360. interface IMaterialNormalTextureInfo extends ITextureInfo {
  75361. /**
  75362. * The scalar multiplier applied to each normal vector of the normal texture
  75363. */
  75364. scale?: number;
  75365. }
  75366. /**
  75367. * Material Occlusion Texture Info
  75368. */
  75369. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  75370. /**
  75371. * A scalar multiplier controlling the amount of occlusion applied
  75372. */
  75373. strength?: number;
  75374. }
  75375. /**
  75376. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  75377. */
  75378. interface IMaterialPbrMetallicRoughness {
  75379. /**
  75380. * The material's base color factor
  75381. */
  75382. baseColorFactor?: number[];
  75383. /**
  75384. * The base color texture
  75385. */
  75386. baseColorTexture?: ITextureInfo;
  75387. /**
  75388. * The metalness of the material
  75389. */
  75390. metallicFactor?: number;
  75391. /**
  75392. * The roughness of the material
  75393. */
  75394. roughnessFactor?: number;
  75395. /**
  75396. * The metallic-roughness texture
  75397. */
  75398. metallicRoughnessTexture?: ITextureInfo;
  75399. }
  75400. /**
  75401. * The material appearance of a primitive
  75402. */
  75403. interface IMaterial extends IChildRootProperty {
  75404. /**
  75405. * 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
  75406. */
  75407. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  75408. /**
  75409. * The normal map texture
  75410. */
  75411. normalTexture?: IMaterialNormalTextureInfo;
  75412. /**
  75413. * The occlusion map texture
  75414. */
  75415. occlusionTexture?: IMaterialOcclusionTextureInfo;
  75416. /**
  75417. * The emissive map texture
  75418. */
  75419. emissiveTexture?: ITextureInfo;
  75420. /**
  75421. * 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
  75422. */
  75423. emissiveFactor?: number[];
  75424. /**
  75425. * The alpha rendering mode of the material
  75426. */
  75427. alphaMode?: MaterialAlphaMode;
  75428. /**
  75429. * The alpha cutoff value of the material
  75430. */
  75431. alphaCutoff?: number;
  75432. /**
  75433. * Specifies whether the material is double sided
  75434. */
  75435. doubleSided?: boolean;
  75436. }
  75437. /**
  75438. * Geometry to be rendered with the given material
  75439. */
  75440. interface IMeshPrimitive extends IProperty {
  75441. /**
  75442. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  75443. */
  75444. attributes: {
  75445. [name: string]: number;
  75446. };
  75447. /**
  75448. * The index of the accessor that contains the indices
  75449. */
  75450. indices?: number;
  75451. /**
  75452. * The index of the material to apply to this primitive when rendering
  75453. */
  75454. material?: number;
  75455. /**
  75456. * The type of primitives to render. All valid values correspond to WebGL enums
  75457. */
  75458. mode?: MeshPrimitiveMode;
  75459. /**
  75460. * 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
  75461. */
  75462. targets?: {
  75463. [name: string]: number;
  75464. }[];
  75465. }
  75466. /**
  75467. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  75468. */
  75469. interface IMesh extends IChildRootProperty {
  75470. /**
  75471. * An array of primitives, each defining geometry to be rendered with a material
  75472. */
  75473. primitives: IMeshPrimitive[];
  75474. /**
  75475. * Array of weights to be applied to the Morph Targets
  75476. */
  75477. weights?: number[];
  75478. }
  75479. /**
  75480. * A node in the node hierarchy
  75481. */
  75482. interface INode extends IChildRootProperty {
  75483. /**
  75484. * The index of the camera referenced by this node
  75485. */
  75486. camera?: number;
  75487. /**
  75488. * The indices of this node's children
  75489. */
  75490. children?: number[];
  75491. /**
  75492. * The index of the skin referenced by this node
  75493. */
  75494. skin?: number;
  75495. /**
  75496. * A floating-point 4x4 transformation matrix stored in column-major order
  75497. */
  75498. matrix?: number[];
  75499. /**
  75500. * The index of the mesh in this node
  75501. */
  75502. mesh?: number;
  75503. /**
  75504. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  75505. */
  75506. rotation?: number[];
  75507. /**
  75508. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  75509. */
  75510. scale?: number[];
  75511. /**
  75512. * The node's translation along the x, y, and z axes
  75513. */
  75514. translation?: number[];
  75515. /**
  75516. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  75517. */
  75518. weights?: number[];
  75519. }
  75520. /**
  75521. * Texture sampler properties for filtering and wrapping modes
  75522. */
  75523. interface ISampler extends IChildRootProperty {
  75524. /**
  75525. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  75526. */
  75527. magFilter?: TextureMagFilter;
  75528. /**
  75529. * Minification filter. All valid values correspond to WebGL enums
  75530. */
  75531. minFilter?: TextureMinFilter;
  75532. /**
  75533. * S (U) wrapping mode. All valid values correspond to WebGL enums
  75534. */
  75535. wrapS?: TextureWrapMode;
  75536. /**
  75537. * T (V) wrapping mode. All valid values correspond to WebGL enums
  75538. */
  75539. wrapT?: TextureWrapMode;
  75540. }
  75541. /**
  75542. * The root nodes of a scene
  75543. */
  75544. interface IScene extends IChildRootProperty {
  75545. /**
  75546. * The indices of each root node
  75547. */
  75548. nodes: number[];
  75549. }
  75550. /**
  75551. * Joints and matrices defining a skin
  75552. */
  75553. interface ISkin extends IChildRootProperty {
  75554. /**
  75555. * 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
  75556. */
  75557. inverseBindMatrices?: number;
  75558. /**
  75559. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  75560. */
  75561. skeleton?: number;
  75562. /**
  75563. * 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)
  75564. */
  75565. joints: number[];
  75566. }
  75567. /**
  75568. * A texture and its sampler
  75569. */
  75570. interface ITexture extends IChildRootProperty {
  75571. /**
  75572. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  75573. */
  75574. sampler?: number;
  75575. /**
  75576. * The index of the image used by this texture
  75577. */
  75578. source: number;
  75579. }
  75580. /**
  75581. * Reference to a texture
  75582. */
  75583. interface ITextureInfo extends IProperty {
  75584. /**
  75585. * The index of the texture
  75586. */
  75587. index: number;
  75588. /**
  75589. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  75590. */
  75591. texCoord?: number;
  75592. }
  75593. /**
  75594. * The root object for a glTF asset
  75595. */
  75596. interface IGLTF extends IProperty {
  75597. /**
  75598. * An array of accessors. An accessor is a typed view into a bufferView
  75599. */
  75600. accessors?: IAccessor[];
  75601. /**
  75602. * An array of keyframe animations
  75603. */
  75604. animations?: IAnimation[];
  75605. /**
  75606. * Metadata about the glTF asset
  75607. */
  75608. asset: IAsset;
  75609. /**
  75610. * An array of buffers. A buffer points to binary geometry, animation, or skins
  75611. */
  75612. buffers?: IBuffer[];
  75613. /**
  75614. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  75615. */
  75616. bufferViews?: IBufferView[];
  75617. /**
  75618. * An array of cameras
  75619. */
  75620. cameras?: ICamera[];
  75621. /**
  75622. * Names of glTF extensions used somewhere in this asset
  75623. */
  75624. extensionsUsed?: string[];
  75625. /**
  75626. * Names of glTF extensions required to properly load this asset
  75627. */
  75628. extensionsRequired?: string[];
  75629. /**
  75630. * An array of images. An image defines data used to create a texture
  75631. */
  75632. images?: IImage[];
  75633. /**
  75634. * An array of materials. A material defines the appearance of a primitive
  75635. */
  75636. materials?: IMaterial[];
  75637. /**
  75638. * An array of meshes. A mesh is a set of primitives to be rendered
  75639. */
  75640. meshes?: IMesh[];
  75641. /**
  75642. * An array of nodes
  75643. */
  75644. nodes?: INode[];
  75645. /**
  75646. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  75647. */
  75648. samplers?: ISampler[];
  75649. /**
  75650. * The index of the default scene
  75651. */
  75652. scene?: number;
  75653. /**
  75654. * An array of scenes
  75655. */
  75656. scenes?: IScene[];
  75657. /**
  75658. * An array of skins. A skin is defined by joints and matrices
  75659. */
  75660. skins?: ISkin[];
  75661. /**
  75662. * An array of textures
  75663. */
  75664. textures?: ITexture[];
  75665. }
  75666. /**
  75667. * The glTF validation results
  75668. * @ignore
  75669. */
  75670. interface IGLTFValidationResults {
  75671. info: {
  75672. generator: string;
  75673. hasAnimations: boolean;
  75674. hasDefaultScene: boolean;
  75675. hasMaterials: boolean;
  75676. hasMorphTargets: boolean;
  75677. hasSkins: boolean;
  75678. hasTextures: boolean;
  75679. maxAttributesUsed: number;
  75680. primitivesCount: number
  75681. };
  75682. issues: {
  75683. messages: Array<string>;
  75684. numErrors: number;
  75685. numHints: number;
  75686. numInfos: number;
  75687. numWarnings: number;
  75688. truncated: boolean
  75689. };
  75690. mimeType: string;
  75691. uri: string;
  75692. validatedAt: string;
  75693. validatorVersion: string;
  75694. }
  75695. /**
  75696. * The glTF validation options
  75697. */
  75698. interface IGLTFValidationOptions {
  75699. /** Uri to use */
  75700. uri?: string;
  75701. /** Function used to load external resources */
  75702. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  75703. /** Boolean indicating that we need to validate accessor data */
  75704. validateAccessorData?: boolean;
  75705. /** max number of issues allowed */
  75706. maxIssues?: number;
  75707. /** Ignored issues */
  75708. ignoredIssues?: Array<string>;
  75709. /** Value to override severy settings */
  75710. severityOverrides?: Object;
  75711. }
  75712. /**
  75713. * The glTF validator object
  75714. * @ignore
  75715. */
  75716. interface IGLTFValidator {
  75717. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  75718. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  75719. }
  75720. }
  75721. declare module BABYLON {
  75722. /** @hidden */
  75723. export var cellPixelShader: {
  75724. name: string;
  75725. shader: string;
  75726. };
  75727. }
  75728. declare module BABYLON {
  75729. /** @hidden */
  75730. export var cellVertexShader: {
  75731. name: string;
  75732. shader: string;
  75733. };
  75734. }
  75735. declare module BABYLON {
  75736. export class CellMaterial extends BABYLON.PushMaterial {
  75737. private _diffuseTexture;
  75738. diffuseTexture: BABYLON.BaseTexture;
  75739. diffuseColor: BABYLON.Color3;
  75740. _computeHighLevel: boolean;
  75741. computeHighLevel: boolean;
  75742. private _disableLighting;
  75743. disableLighting: boolean;
  75744. private _maxSimultaneousLights;
  75745. maxSimultaneousLights: number;
  75746. private _renderId;
  75747. constructor(name: string, scene: BABYLON.Scene);
  75748. needAlphaBlending(): boolean;
  75749. needAlphaTesting(): boolean;
  75750. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  75751. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  75752. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  75753. getAnimatables(): BABYLON.IAnimatable[];
  75754. getActiveTextures(): BABYLON.BaseTexture[];
  75755. hasTexture(texture: BABYLON.BaseTexture): boolean;
  75756. dispose(forceDisposeEffect?: boolean): void;
  75757. getClassName(): string;
  75758. clone(name: string): CellMaterial;
  75759. serialize(): any;
  75760. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  75761. }
  75762. }
  75763. declare module BABYLON {
  75764. export class CustomShaderStructure {
  75765. FragmentStore: string;
  75766. VertexStore: string;
  75767. constructor();
  75768. }
  75769. export class ShaderSpecialParts {
  75770. constructor();
  75771. Fragment_Begin: string;
  75772. Fragment_Definitions: string;
  75773. Fragment_MainBegin: string;
  75774. Fragment_Custom_Diffuse: string;
  75775. Fragment_Before_Lights: string;
  75776. Fragment_Before_Fog: string;
  75777. Fragment_Custom_Alpha: string;
  75778. Fragment_Before_FragColor: string;
  75779. Vertex_Begin: string;
  75780. Vertex_Definitions: string;
  75781. Vertex_MainBegin: string;
  75782. Vertex_Before_PositionUpdated: string;
  75783. Vertex_Before_NormalUpdated: string;
  75784. Vertex_MainEnd: string;
  75785. }
  75786. export class CustomMaterial extends BABYLON.StandardMaterial {
  75787. static ShaderIndexer: number;
  75788. CustomParts: ShaderSpecialParts;
  75789. _isCreatedShader: boolean;
  75790. _createdShaderName: string;
  75791. _customUniform: string[];
  75792. _newUniforms: string[];
  75793. _newUniformInstances: any[];
  75794. _newSamplerInstances: BABYLON.Texture[];
  75795. FragmentShader: string;
  75796. VertexShader: string;
  75797. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  75798. ReviewUniform(name: string, arr: string[]): string[];
  75799. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines): string;
  75800. constructor(name: string, scene: BABYLON.Scene);
  75801. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  75802. Fragment_Begin(shaderPart: string): CustomMaterial;
  75803. Fragment_Definitions(shaderPart: string): CustomMaterial;
  75804. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  75805. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  75806. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  75807. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  75808. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  75809. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  75810. Vertex_Begin(shaderPart: string): CustomMaterial;
  75811. Vertex_Definitions(shaderPart: string): CustomMaterial;
  75812. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  75813. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  75814. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  75815. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  75816. }
  75817. }
  75818. declare module BABYLON {
  75819. export class ShaderAlebdoParts {
  75820. constructor();
  75821. Fragment_Begin: string;
  75822. Fragment_Definitions: string;
  75823. Fragment_MainBegin: string;
  75824. Fragment_Custom_Albedo: string;
  75825. Fragment_Before_Lights: string;
  75826. Fragment_Custom_MetallicRoughness: string;
  75827. Fragment_Custom_MicroSurface: string;
  75828. Fragment_Before_Fog: string;
  75829. Fragment_Custom_Alpha: string;
  75830. Fragment_Before_FragColor: string;
  75831. Vertex_Begin: string;
  75832. Vertex_Definitions: string;
  75833. Vertex_MainBegin: string;
  75834. Vertex_Before_PositionUpdated: string;
  75835. Vertex_Before_NormalUpdated: string;
  75836. Vertex_MainEnd: string;
  75837. }
  75838. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  75839. static ShaderIndexer: number;
  75840. CustomParts: ShaderAlebdoParts;
  75841. _isCreatedShader: boolean;
  75842. _createdShaderName: string;
  75843. _customUniform: string[];
  75844. _newUniforms: string[];
  75845. _newUniformInstances: any[];
  75846. _newSamplerInstances: BABYLON.Texture[];
  75847. FragmentShader: string;
  75848. VertexShader: string;
  75849. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  75850. ReviewUniform(name: string, arr: string[]): string[];
  75851. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines): string;
  75852. constructor(name: string, scene: BABYLON.Scene);
  75853. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  75854. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  75855. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  75856. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  75857. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  75858. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  75859. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  75860. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  75861. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  75862. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  75863. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  75864. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  75865. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  75866. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  75867. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  75868. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  75869. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  75870. }
  75871. }
  75872. declare module BABYLON {
  75873. /** @hidden */
  75874. export var firePixelShader: {
  75875. name: string;
  75876. shader: string;
  75877. };
  75878. }
  75879. declare module BABYLON {
  75880. /** @hidden */
  75881. export var fireVertexShader: {
  75882. name: string;
  75883. shader: string;
  75884. };
  75885. }
  75886. declare module BABYLON {
  75887. export class FireMaterial extends BABYLON.PushMaterial {
  75888. private _diffuseTexture;
  75889. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  75890. private _distortionTexture;
  75891. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  75892. private _opacityTexture;
  75893. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  75894. diffuseColor: BABYLON.Color3;
  75895. speed: number;
  75896. private _scaledDiffuse;
  75897. private _renderId;
  75898. private _lastTime;
  75899. constructor(name: string, scene: BABYLON.Scene);
  75900. needAlphaBlending(): boolean;
  75901. needAlphaTesting(): boolean;
  75902. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  75903. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  75904. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  75905. getAnimatables(): BABYLON.IAnimatable[];
  75906. getActiveTextures(): BABYLON.BaseTexture[];
  75907. hasTexture(texture: BABYLON.BaseTexture): boolean;
  75908. getClassName(): string;
  75909. dispose(forceDisposeEffect?: boolean): void;
  75910. clone(name: string): FireMaterial;
  75911. serialize(): any;
  75912. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  75913. }
  75914. }
  75915. declare module BABYLON {
  75916. /** @hidden */
  75917. export var furPixelShader: {
  75918. name: string;
  75919. shader: string;
  75920. };
  75921. }
  75922. declare module BABYLON {
  75923. /** @hidden */
  75924. export var furVertexShader: {
  75925. name: string;
  75926. shader: string;
  75927. };
  75928. }
  75929. declare module BABYLON {
  75930. export class FurMaterial extends BABYLON.PushMaterial {
  75931. private _diffuseTexture;
  75932. diffuseTexture: BABYLON.BaseTexture;
  75933. private _heightTexture;
  75934. heightTexture: BABYLON.BaseTexture;
  75935. diffuseColor: BABYLON.Color3;
  75936. furLength: number;
  75937. furAngle: number;
  75938. furColor: BABYLON.Color3;
  75939. furOffset: number;
  75940. furSpacing: number;
  75941. furGravity: BABYLON.Vector3;
  75942. furSpeed: number;
  75943. furDensity: number;
  75944. furOcclusion: number;
  75945. furTexture: BABYLON.DynamicTexture;
  75946. private _disableLighting;
  75947. disableLighting: boolean;
  75948. private _maxSimultaneousLights;
  75949. maxSimultaneousLights: number;
  75950. highLevelFur: boolean;
  75951. _meshes: BABYLON.AbstractMesh[];
  75952. private _renderId;
  75953. private _furTime;
  75954. constructor(name: string, scene: BABYLON.Scene);
  75955. get furTime(): number;
  75956. set furTime(furTime: number);
  75957. needAlphaBlending(): boolean;
  75958. needAlphaTesting(): boolean;
  75959. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  75960. updateFur(): void;
  75961. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  75962. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  75963. getAnimatables(): BABYLON.IAnimatable[];
  75964. getActiveTextures(): BABYLON.BaseTexture[];
  75965. hasTexture(texture: BABYLON.BaseTexture): boolean;
  75966. dispose(forceDisposeEffect?: boolean): void;
  75967. clone(name: string): FurMaterial;
  75968. serialize(): any;
  75969. getClassName(): string;
  75970. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  75971. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  75972. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  75973. }
  75974. }
  75975. declare module BABYLON {
  75976. /** @hidden */
  75977. export var gradientPixelShader: {
  75978. name: string;
  75979. shader: string;
  75980. };
  75981. }
  75982. declare module BABYLON {
  75983. /** @hidden */
  75984. export var gradientVertexShader: {
  75985. name: string;
  75986. shader: string;
  75987. };
  75988. }
  75989. declare module BABYLON {
  75990. export class GradientMaterial extends BABYLON.PushMaterial {
  75991. private _maxSimultaneousLights;
  75992. maxSimultaneousLights: number;
  75993. topColor: BABYLON.Color3;
  75994. topColorAlpha: number;
  75995. bottomColor: BABYLON.Color3;
  75996. bottomColorAlpha: number;
  75997. offset: number;
  75998. scale: number;
  75999. smoothness: number;
  76000. private _disableLighting;
  76001. disableLighting: boolean;
  76002. private _renderId;
  76003. constructor(name: string, scene: BABYLON.Scene);
  76004. needAlphaBlending(): boolean;
  76005. needAlphaTesting(): boolean;
  76006. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  76007. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  76008. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  76009. getAnimatables(): BABYLON.IAnimatable[];
  76010. dispose(forceDisposeEffect?: boolean): void;
  76011. clone(name: string): GradientMaterial;
  76012. serialize(): any;
  76013. getClassName(): string;
  76014. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  76015. }
  76016. }
  76017. declare module BABYLON {
  76018. /** @hidden */
  76019. export var gridPixelShader: {
  76020. name: string;
  76021. shader: string;
  76022. };
  76023. }
  76024. declare module BABYLON {
  76025. /** @hidden */
  76026. export var gridVertexShader: {
  76027. name: string;
  76028. shader: string;
  76029. };
  76030. }
  76031. declare module BABYLON {
  76032. /**
  76033. * The grid materials allows you to wrap any shape with a grid.
  76034. * Colors are customizable.
  76035. */
  76036. export class GridMaterial extends BABYLON.PushMaterial {
  76037. /**
  76038. * Main color of the grid (e.g. between lines)
  76039. */
  76040. mainColor: BABYLON.Color3;
  76041. /**
  76042. * Color of the grid lines.
  76043. */
  76044. lineColor: BABYLON.Color3;
  76045. /**
  76046. * The scale of the grid compared to unit.
  76047. */
  76048. gridRatio: number;
  76049. /**
  76050. * Allows setting an offset for the grid lines.
  76051. */
  76052. gridOffset: BABYLON.Vector3;
  76053. /**
  76054. * The frequency of thicker lines.
  76055. */
  76056. majorUnitFrequency: number;
  76057. /**
  76058. * The visibility of minor units in the grid.
  76059. */
  76060. minorUnitVisibility: number;
  76061. /**
  76062. * The grid opacity outside of the lines.
  76063. */
  76064. opacity: number;
  76065. /**
  76066. * Determine RBG output is premultiplied by alpha value.
  76067. */
  76068. preMultiplyAlpha: boolean;
  76069. private _opacityTexture;
  76070. opacityTexture: BABYLON.BaseTexture;
  76071. private _gridControl;
  76072. private _renderId;
  76073. /**
  76074. * constructor
  76075. * @param name The name given to the material in order to identify it afterwards.
  76076. * @param scene The scene the material is used in.
  76077. */
  76078. constructor(name: string, scene: BABYLON.Scene);
  76079. /**
  76080. * Returns wehter or not the grid requires alpha blending.
  76081. */
  76082. needAlphaBlending(): boolean;
  76083. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  76084. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  76085. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  76086. /**
  76087. * Dispose the material and its associated resources.
  76088. * @param forceDisposeEffect will also dispose the used effect when true
  76089. */
  76090. dispose(forceDisposeEffect?: boolean): void;
  76091. clone(name: string): GridMaterial;
  76092. serialize(): any;
  76093. getClassName(): string;
  76094. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  76095. }
  76096. }
  76097. declare module BABYLON {
  76098. /** @hidden */
  76099. export var lavaPixelShader: {
  76100. name: string;
  76101. shader: string;
  76102. };
  76103. }
  76104. declare module BABYLON {
  76105. /** @hidden */
  76106. export var lavaVertexShader: {
  76107. name: string;
  76108. shader: string;
  76109. };
  76110. }
  76111. declare module BABYLON {
  76112. export class LavaMaterial extends BABYLON.PushMaterial {
  76113. private _diffuseTexture;
  76114. diffuseTexture: BABYLON.BaseTexture;
  76115. noiseTexture: BABYLON.BaseTexture;
  76116. fogColor: BABYLON.Color3;
  76117. speed: number;
  76118. movingSpeed: number;
  76119. lowFrequencySpeed: number;
  76120. fogDensity: number;
  76121. private _lastTime;
  76122. diffuseColor: BABYLON.Color3;
  76123. private _disableLighting;
  76124. disableLighting: boolean;
  76125. private _unlit;
  76126. unlit: boolean;
  76127. private _maxSimultaneousLights;
  76128. maxSimultaneousLights: number;
  76129. private _scaledDiffuse;
  76130. private _renderId;
  76131. constructor(name: string, scene: BABYLON.Scene);
  76132. needAlphaBlending(): boolean;
  76133. needAlphaTesting(): boolean;
  76134. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  76135. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  76136. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  76137. getAnimatables(): BABYLON.IAnimatable[];
  76138. getActiveTextures(): BABYLON.BaseTexture[];
  76139. hasTexture(texture: BABYLON.BaseTexture): boolean;
  76140. dispose(forceDisposeEffect?: boolean): void;
  76141. clone(name: string): LavaMaterial;
  76142. serialize(): any;
  76143. getClassName(): string;
  76144. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  76145. }
  76146. }
  76147. declare module BABYLON {
  76148. /** @hidden */
  76149. export var mixPixelShader: {
  76150. name: string;
  76151. shader: string;
  76152. };
  76153. }
  76154. declare module BABYLON {
  76155. /** @hidden */
  76156. export var mixVertexShader: {
  76157. name: string;
  76158. shader: string;
  76159. };
  76160. }
  76161. declare module BABYLON {
  76162. export class MixMaterial extends BABYLON.PushMaterial {
  76163. /**
  76164. * Mix textures
  76165. */
  76166. private _mixTexture1;
  76167. mixTexture1: BABYLON.BaseTexture;
  76168. private _mixTexture2;
  76169. mixTexture2: BABYLON.BaseTexture;
  76170. /**
  76171. * Diffuse textures
  76172. */
  76173. private _diffuseTexture1;
  76174. diffuseTexture1: BABYLON.Texture;
  76175. private _diffuseTexture2;
  76176. diffuseTexture2: BABYLON.Texture;
  76177. private _diffuseTexture3;
  76178. diffuseTexture3: BABYLON.Texture;
  76179. private _diffuseTexture4;
  76180. diffuseTexture4: BABYLON.Texture;
  76181. private _diffuseTexture5;
  76182. diffuseTexture5: BABYLON.Texture;
  76183. private _diffuseTexture6;
  76184. diffuseTexture6: BABYLON.Texture;
  76185. private _diffuseTexture7;
  76186. diffuseTexture7: BABYLON.Texture;
  76187. private _diffuseTexture8;
  76188. diffuseTexture8: BABYLON.Texture;
  76189. /**
  76190. * Uniforms
  76191. */
  76192. diffuseColor: BABYLON.Color3;
  76193. specularColor: BABYLON.Color3;
  76194. specularPower: number;
  76195. private _disableLighting;
  76196. disableLighting: boolean;
  76197. private _maxSimultaneousLights;
  76198. maxSimultaneousLights: number;
  76199. private _renderId;
  76200. constructor(name: string, scene: BABYLON.Scene);
  76201. needAlphaBlending(): boolean;
  76202. needAlphaTesting(): boolean;
  76203. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  76204. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  76205. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  76206. getAnimatables(): BABYLON.IAnimatable[];
  76207. getActiveTextures(): BABYLON.BaseTexture[];
  76208. hasTexture(texture: BABYLON.BaseTexture): boolean;
  76209. dispose(forceDisposeEffect?: boolean): void;
  76210. clone(name: string): MixMaterial;
  76211. serialize(): any;
  76212. getClassName(): string;
  76213. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  76214. }
  76215. }
  76216. declare module BABYLON {
  76217. /** @hidden */
  76218. export var normalPixelShader: {
  76219. name: string;
  76220. shader: string;
  76221. };
  76222. }
  76223. declare module BABYLON {
  76224. /** @hidden */
  76225. export var normalVertexShader: {
  76226. name: string;
  76227. shader: string;
  76228. };
  76229. }
  76230. declare module BABYLON {
  76231. export class NormalMaterial extends BABYLON.PushMaterial {
  76232. private _diffuseTexture;
  76233. diffuseTexture: BABYLON.BaseTexture;
  76234. diffuseColor: BABYLON.Color3;
  76235. private _disableLighting;
  76236. disableLighting: boolean;
  76237. private _maxSimultaneousLights;
  76238. maxSimultaneousLights: number;
  76239. private _renderId;
  76240. constructor(name: string, scene: BABYLON.Scene);
  76241. needAlphaBlending(): boolean;
  76242. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  76243. needAlphaTesting(): boolean;
  76244. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  76245. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  76246. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  76247. getAnimatables(): BABYLON.IAnimatable[];
  76248. getActiveTextures(): BABYLON.BaseTexture[];
  76249. hasTexture(texture: BABYLON.BaseTexture): boolean;
  76250. dispose(forceDisposeEffect?: boolean): void;
  76251. clone(name: string): NormalMaterial;
  76252. serialize(): any;
  76253. getClassName(): string;
  76254. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  76255. }
  76256. }
  76257. declare module BABYLON {
  76258. /** @hidden */
  76259. export var shadowOnlyPixelShader: {
  76260. name: string;
  76261. shader: string;
  76262. };
  76263. }
  76264. declare module BABYLON {
  76265. /** @hidden */
  76266. export var shadowOnlyVertexShader: {
  76267. name: string;
  76268. shader: string;
  76269. };
  76270. }
  76271. declare module BABYLON {
  76272. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  76273. private _renderId;
  76274. private _activeLight;
  76275. constructor(name: string, scene: BABYLON.Scene);
  76276. shadowColor: BABYLON.Color3;
  76277. needAlphaBlending(): boolean;
  76278. needAlphaTesting(): boolean;
  76279. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  76280. get activeLight(): BABYLON.IShadowLight;
  76281. set activeLight(light: BABYLON.IShadowLight);
  76282. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  76283. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  76284. clone(name: string): ShadowOnlyMaterial;
  76285. serialize(): any;
  76286. getClassName(): string;
  76287. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  76288. }
  76289. }
  76290. declare module BABYLON {
  76291. /** @hidden */
  76292. export var simplePixelShader: {
  76293. name: string;
  76294. shader: string;
  76295. };
  76296. }
  76297. declare module BABYLON {
  76298. /** @hidden */
  76299. export var simpleVertexShader: {
  76300. name: string;
  76301. shader: string;
  76302. };
  76303. }
  76304. declare module BABYLON {
  76305. export class SimpleMaterial extends BABYLON.PushMaterial {
  76306. private _diffuseTexture;
  76307. diffuseTexture: BABYLON.BaseTexture;
  76308. diffuseColor: BABYLON.Color3;
  76309. private _disableLighting;
  76310. disableLighting: boolean;
  76311. private _maxSimultaneousLights;
  76312. maxSimultaneousLights: number;
  76313. private _renderId;
  76314. constructor(name: string, scene: BABYLON.Scene);
  76315. needAlphaBlending(): boolean;
  76316. needAlphaTesting(): boolean;
  76317. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  76318. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  76319. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  76320. getAnimatables(): BABYLON.IAnimatable[];
  76321. getActiveTextures(): BABYLON.BaseTexture[];
  76322. hasTexture(texture: BABYLON.BaseTexture): boolean;
  76323. dispose(forceDisposeEffect?: boolean): void;
  76324. clone(name: string): SimpleMaterial;
  76325. serialize(): any;
  76326. getClassName(): string;
  76327. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  76328. }
  76329. }
  76330. declare module BABYLON {
  76331. /** @hidden */
  76332. export var skyPixelShader: {
  76333. name: string;
  76334. shader: string;
  76335. };
  76336. }
  76337. declare module BABYLON {
  76338. /** @hidden */
  76339. export var skyVertexShader: {
  76340. name: string;
  76341. shader: string;
  76342. };
  76343. }
  76344. declare module BABYLON {
  76345. /**
  76346. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  76347. * @see https://doc.babylonjs.com/extensions/sky
  76348. */
  76349. export class SkyMaterial extends BABYLON.PushMaterial {
  76350. /**
  76351. * Defines the overall luminance of sky in interval ]0, 1[.
  76352. */
  76353. luminance: number;
  76354. /**
  76355. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  76356. */
  76357. turbidity: number;
  76358. /**
  76359. * Defines the sky appearance (light intensity).
  76360. */
  76361. rayleigh: number;
  76362. /**
  76363. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  76364. */
  76365. mieCoefficient: number;
  76366. /**
  76367. * Defines the amount of haze particles following the Mie scattering theory.
  76368. */
  76369. mieDirectionalG: number;
  76370. /**
  76371. * Defines the distance of the sun according to the active scene camera.
  76372. */
  76373. distance: number;
  76374. /**
  76375. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  76376. * "inclined".
  76377. */
  76378. inclination: number;
  76379. /**
  76380. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  76381. * an object direction and a reference direction.
  76382. */
  76383. azimuth: number;
  76384. /**
  76385. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  76386. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  76387. */
  76388. sunPosition: BABYLON.Vector3;
  76389. /**
  76390. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  76391. * .sunPosition property.
  76392. */
  76393. useSunPosition: boolean;
  76394. /**
  76395. * Defines an offset vector used to get a horizon offset.
  76396. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  76397. */
  76398. cameraOffset: BABYLON.Vector3;
  76399. private _cameraPosition;
  76400. private _renderId;
  76401. /**
  76402. * Instantiates a new sky material.
  76403. * This material allows to create dynamic and texture free
  76404. * effects for skyboxes by taking care of the atmosphere state.
  76405. * @see https://doc.babylonjs.com/extensions/sky
  76406. * @param name Define the name of the material in the scene
  76407. * @param scene Define the scene the material belong to
  76408. */
  76409. constructor(name: string, scene: BABYLON.Scene);
  76410. /**
  76411. * Specifies if the material will require alpha blending
  76412. * @returns a boolean specifying if alpha blending is needed
  76413. */
  76414. needAlphaBlending(): boolean;
  76415. /**
  76416. * Specifies if this material should be rendered in alpha test mode
  76417. * @returns false as the sky material doesn't need alpha testing.
  76418. */
  76419. needAlphaTesting(): boolean;
  76420. /**
  76421. * Get the texture used for alpha test purpose.
  76422. * @returns null as the sky material has no texture.
  76423. */
  76424. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  76425. /**
  76426. * Get if the submesh is ready to be used and all its information available.
  76427. * Child classes can use it to update shaders
  76428. * @param mesh defines the mesh to check
  76429. * @param subMesh defines which submesh to check
  76430. * @param useInstances specifies that instances should be used
  76431. * @returns a boolean indicating that the submesh is ready or not
  76432. */
  76433. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  76434. /**
  76435. * Binds the submesh to this material by preparing the effect and shader to draw
  76436. * @param world defines the world transformation matrix
  76437. * @param mesh defines the mesh containing the submesh
  76438. * @param subMesh defines the submesh to bind the material to
  76439. */
  76440. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  76441. /**
  76442. * Get the list of animatables in the material.
  76443. * @returns the list of animatables object used in the material
  76444. */
  76445. getAnimatables(): BABYLON.IAnimatable[];
  76446. /**
  76447. * Disposes the material
  76448. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  76449. */
  76450. dispose(forceDisposeEffect?: boolean): void;
  76451. /**
  76452. * Makes a duplicate of the material, and gives it a new name
  76453. * @param name defines the new name for the duplicated material
  76454. * @returns the cloned material
  76455. */
  76456. clone(name: string): SkyMaterial;
  76457. /**
  76458. * Serializes this material in a JSON representation
  76459. * @returns the serialized material object
  76460. */
  76461. serialize(): any;
  76462. /**
  76463. * Gets the current class name of the material e.g. "SkyMaterial"
  76464. * Mainly use in serialization.
  76465. * @returns the class name
  76466. */
  76467. getClassName(): string;
  76468. /**
  76469. * Creates a sky material from parsed material data
  76470. * @param source defines the JSON representation of the material
  76471. * @param scene defines the hosting scene
  76472. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  76473. * @returns a new sky material
  76474. */
  76475. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  76476. }
  76477. }
  76478. declare module BABYLON {
  76479. /** @hidden */
  76480. export var terrainPixelShader: {
  76481. name: string;
  76482. shader: string;
  76483. };
  76484. }
  76485. declare module BABYLON {
  76486. /** @hidden */
  76487. export var terrainVertexShader: {
  76488. name: string;
  76489. shader: string;
  76490. };
  76491. }
  76492. declare module BABYLON {
  76493. export class TerrainMaterial extends BABYLON.PushMaterial {
  76494. private _mixTexture;
  76495. mixTexture: BABYLON.BaseTexture;
  76496. private _diffuseTexture1;
  76497. diffuseTexture1: BABYLON.Texture;
  76498. private _diffuseTexture2;
  76499. diffuseTexture2: BABYLON.Texture;
  76500. private _diffuseTexture3;
  76501. diffuseTexture3: BABYLON.Texture;
  76502. private _bumpTexture1;
  76503. bumpTexture1: BABYLON.Texture;
  76504. private _bumpTexture2;
  76505. bumpTexture2: BABYLON.Texture;
  76506. private _bumpTexture3;
  76507. bumpTexture3: BABYLON.Texture;
  76508. diffuseColor: BABYLON.Color3;
  76509. specularColor: BABYLON.Color3;
  76510. specularPower: number;
  76511. private _disableLighting;
  76512. disableLighting: boolean;
  76513. private _maxSimultaneousLights;
  76514. maxSimultaneousLights: number;
  76515. private _renderId;
  76516. constructor(name: string, scene: BABYLON.Scene);
  76517. needAlphaBlending(): boolean;
  76518. needAlphaTesting(): boolean;
  76519. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  76520. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  76521. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  76522. getAnimatables(): BABYLON.IAnimatable[];
  76523. getActiveTextures(): BABYLON.BaseTexture[];
  76524. hasTexture(texture: BABYLON.BaseTexture): boolean;
  76525. dispose(forceDisposeEffect?: boolean): void;
  76526. clone(name: string): TerrainMaterial;
  76527. serialize(): any;
  76528. getClassName(): string;
  76529. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  76530. }
  76531. }
  76532. declare module BABYLON {
  76533. /** @hidden */
  76534. export var triplanarPixelShader: {
  76535. name: string;
  76536. shader: string;
  76537. };
  76538. }
  76539. declare module BABYLON {
  76540. /** @hidden */
  76541. export var triplanarVertexShader: {
  76542. name: string;
  76543. shader: string;
  76544. };
  76545. }
  76546. declare module BABYLON {
  76547. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  76548. mixTexture: BABYLON.BaseTexture;
  76549. private _diffuseTextureX;
  76550. diffuseTextureX: BABYLON.BaseTexture;
  76551. private _diffuseTextureY;
  76552. diffuseTextureY: BABYLON.BaseTexture;
  76553. private _diffuseTextureZ;
  76554. diffuseTextureZ: BABYLON.BaseTexture;
  76555. private _normalTextureX;
  76556. normalTextureX: BABYLON.BaseTexture;
  76557. private _normalTextureY;
  76558. normalTextureY: BABYLON.BaseTexture;
  76559. private _normalTextureZ;
  76560. normalTextureZ: BABYLON.BaseTexture;
  76561. tileSize: number;
  76562. diffuseColor: BABYLON.Color3;
  76563. specularColor: BABYLON.Color3;
  76564. specularPower: number;
  76565. private _disableLighting;
  76566. disableLighting: boolean;
  76567. private _maxSimultaneousLights;
  76568. maxSimultaneousLights: number;
  76569. private _renderId;
  76570. constructor(name: string, scene: BABYLON.Scene);
  76571. needAlphaBlending(): boolean;
  76572. needAlphaTesting(): boolean;
  76573. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  76574. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  76575. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  76576. getAnimatables(): BABYLON.IAnimatable[];
  76577. getActiveTextures(): BABYLON.BaseTexture[];
  76578. hasTexture(texture: BABYLON.BaseTexture): boolean;
  76579. dispose(forceDisposeEffect?: boolean): void;
  76580. clone(name: string): TriPlanarMaterial;
  76581. serialize(): any;
  76582. getClassName(): string;
  76583. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  76584. }
  76585. }
  76586. declare module BABYLON {
  76587. /** @hidden */
  76588. export var waterPixelShader: {
  76589. name: string;
  76590. shader: string;
  76591. };
  76592. }
  76593. declare module BABYLON {
  76594. /** @hidden */
  76595. export var waterVertexShader: {
  76596. name: string;
  76597. shader: string;
  76598. };
  76599. }
  76600. declare module BABYLON {
  76601. export class WaterMaterial extends BABYLON.PushMaterial {
  76602. renderTargetSize: BABYLON.Vector2;
  76603. private _bumpTexture;
  76604. bumpTexture: BABYLON.BaseTexture;
  76605. diffuseColor: BABYLON.Color3;
  76606. specularColor: BABYLON.Color3;
  76607. specularPower: number;
  76608. private _disableLighting;
  76609. disableLighting: boolean;
  76610. private _maxSimultaneousLights;
  76611. maxSimultaneousLights: number;
  76612. /**
  76613. * @param {number}: Represents the wind force
  76614. */
  76615. windForce: number;
  76616. /**
  76617. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  76618. */
  76619. windDirection: BABYLON.Vector2;
  76620. /**
  76621. * @param {number}: Wave height, represents the height of the waves
  76622. */
  76623. waveHeight: number;
  76624. /**
  76625. * @param {number}: Bump height, represents the bump height related to the bump map
  76626. */
  76627. bumpHeight: number;
  76628. /**
  76629. * @param {boolean}: Add a smaller moving bump to less steady waves.
  76630. */
  76631. private _bumpSuperimpose;
  76632. bumpSuperimpose: boolean;
  76633. /**
  76634. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  76635. */
  76636. private _fresnelSeparate;
  76637. fresnelSeparate: boolean;
  76638. /**
  76639. * @param {boolean}: bump Waves modify the reflection.
  76640. */
  76641. private _bumpAffectsReflection;
  76642. bumpAffectsReflection: boolean;
  76643. /**
  76644. * @param {number}: The water color blended with the refraction (near)
  76645. */
  76646. waterColor: BABYLON.Color3;
  76647. /**
  76648. * @param {number}: The blend factor related to the water color
  76649. */
  76650. colorBlendFactor: number;
  76651. /**
  76652. * @param {number}: The water color blended with the reflection (far)
  76653. */
  76654. waterColor2: BABYLON.Color3;
  76655. /**
  76656. * @param {number}: The blend factor related to the water color (reflection, far)
  76657. */
  76658. colorBlendFactor2: number;
  76659. /**
  76660. * @param {number}: Represents the maximum length of a wave
  76661. */
  76662. waveLength: number;
  76663. /**
  76664. * @param {number}: Defines the waves speed
  76665. */
  76666. waveSpeed: number;
  76667. /**
  76668. * Sets or gets wether or not automatic clipping should be enabled or not. Setting to true will save performances and
  76669. * will avoid calculating useless pixels in the pixel shader of the water material.
  76670. */
  76671. disableClipPlane: boolean;
  76672. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  76673. private _mesh;
  76674. private _refractionRTT;
  76675. private _reflectionRTT;
  76676. private _reflectionTransform;
  76677. private _lastTime;
  76678. private _lastDeltaTime;
  76679. private _renderId;
  76680. private _useLogarithmicDepth;
  76681. private _waitingRenderList;
  76682. private _imageProcessingConfiguration;
  76683. private _imageProcessingObserver;
  76684. /**
  76685. * Gets a boolean indicating that current material needs to register RTT
  76686. */
  76687. get hasRenderTargetTextures(): boolean;
  76688. /**
  76689. * Constructor
  76690. */
  76691. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  76692. get useLogarithmicDepth(): boolean;
  76693. set useLogarithmicDepth(value: boolean);
  76694. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  76695. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  76696. addToRenderList(node: any): void;
  76697. enableRenderTargets(enable: boolean): void;
  76698. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  76699. get renderTargetsEnabled(): boolean;
  76700. needAlphaBlending(): boolean;
  76701. needAlphaTesting(): boolean;
  76702. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  76703. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  76704. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  76705. private _createRenderTargets;
  76706. getAnimatables(): BABYLON.IAnimatable[];
  76707. getActiveTextures(): BABYLON.BaseTexture[];
  76708. hasTexture(texture: BABYLON.BaseTexture): boolean;
  76709. dispose(forceDisposeEffect?: boolean): void;
  76710. clone(name: string): WaterMaterial;
  76711. serialize(): any;
  76712. getClassName(): string;
  76713. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  76714. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  76715. }
  76716. }
  76717. declare module BABYLON {
  76718. /** @hidden */
  76719. export var asciiartPixelShader: {
  76720. name: string;
  76721. shader: string;
  76722. };
  76723. }
  76724. declare module BABYLON {
  76725. /**
  76726. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  76727. *
  76728. * It basically takes care rendering the font front the given font size to a texture.
  76729. * This is used later on in the postprocess.
  76730. */
  76731. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  76732. private _font;
  76733. private _text;
  76734. private _charSize;
  76735. /**
  76736. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  76737. */
  76738. get charSize(): number;
  76739. /**
  76740. * Create a new instance of the Ascii Art FontTexture class
  76741. * @param name the name of the texture
  76742. * @param font the font to use, use the W3C CSS notation
  76743. * @param text the caracter set to use in the rendering.
  76744. * @param scene the scene that owns the texture
  76745. */
  76746. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  76747. /**
  76748. * Gets the max char width of a font.
  76749. * @param font the font to use, use the W3C CSS notation
  76750. * @return the max char width
  76751. */
  76752. private getFontWidth;
  76753. /**
  76754. * Gets the max char height of a font.
  76755. * @param font the font to use, use the W3C CSS notation
  76756. * @return the max char height
  76757. */
  76758. private getFontHeight;
  76759. /**
  76760. * Clones the current AsciiArtTexture.
  76761. * @return the clone of the texture.
  76762. */
  76763. clone(): AsciiArtFontTexture;
  76764. /**
  76765. * Parses a json object representing the texture and returns an instance of it.
  76766. * @param source the source JSON representation
  76767. * @param scene the scene to create the texture for
  76768. * @return the parsed texture
  76769. */
  76770. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  76771. }
  76772. /**
  76773. * Option available in the Ascii Art Post Process.
  76774. */
  76775. export interface IAsciiArtPostProcessOptions {
  76776. /**
  76777. * The font to use following the w3c font definition.
  76778. */
  76779. font?: string;
  76780. /**
  76781. * The character set to use in the postprocess.
  76782. */
  76783. characterSet?: string;
  76784. /**
  76785. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  76786. * This number is defined between 0 and 1;
  76787. */
  76788. mixToTile?: number;
  76789. /**
  76790. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  76791. * This number is defined between 0 and 1;
  76792. */
  76793. mixToNormal?: number;
  76794. }
  76795. /**
  76796. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  76797. *
  76798. * Simmply add it to your scene and let the nerd that lives in you have fun.
  76799. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  76800. */
  76801. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  76802. /**
  76803. * The font texture used to render the char in the post process.
  76804. */
  76805. private _asciiArtFontTexture;
  76806. /**
  76807. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  76808. * This number is defined between 0 and 1;
  76809. */
  76810. mixToTile: number;
  76811. /**
  76812. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  76813. * This number is defined between 0 and 1;
  76814. */
  76815. mixToNormal: number;
  76816. /**
  76817. * Instantiates a new Ascii Art Post Process.
  76818. * @param name the name to give to the postprocess
  76819. * @camera the camera to apply the post process to.
  76820. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  76821. */
  76822. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  76823. }
  76824. }
  76825. declare module BABYLON {
  76826. /** @hidden */
  76827. export var digitalrainPixelShader: {
  76828. name: string;
  76829. shader: string;
  76830. };
  76831. }
  76832. declare module BABYLON {
  76833. /**
  76834. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  76835. *
  76836. * It basically takes care rendering the font front the given font size to a texture.
  76837. * This is used later on in the postprocess.
  76838. */
  76839. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  76840. private _font;
  76841. private _text;
  76842. private _charSize;
  76843. /**
  76844. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  76845. */
  76846. get charSize(): number;
  76847. /**
  76848. * Create a new instance of the Digital Rain FontTexture class
  76849. * @param name the name of the texture
  76850. * @param font the font to use, use the W3C CSS notation
  76851. * @param text the caracter set to use in the rendering.
  76852. * @param scene the scene that owns the texture
  76853. */
  76854. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  76855. /**
  76856. * Gets the max char width of a font.
  76857. * @param font the font to use, use the W3C CSS notation
  76858. * @return the max char width
  76859. */
  76860. private getFontWidth;
  76861. /**
  76862. * Gets the max char height of a font.
  76863. * @param font the font to use, use the W3C CSS notation
  76864. * @return the max char height
  76865. */
  76866. private getFontHeight;
  76867. /**
  76868. * Clones the current DigitalRainFontTexture.
  76869. * @return the clone of the texture.
  76870. */
  76871. clone(): DigitalRainFontTexture;
  76872. /**
  76873. * Parses a json object representing the texture and returns an instance of it.
  76874. * @param source the source JSON representation
  76875. * @param scene the scene to create the texture for
  76876. * @return the parsed texture
  76877. */
  76878. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  76879. }
  76880. /**
  76881. * Option available in the Digital Rain Post Process.
  76882. */
  76883. export interface IDigitalRainPostProcessOptions {
  76884. /**
  76885. * The font to use following the w3c font definition.
  76886. */
  76887. font?: string;
  76888. /**
  76889. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  76890. * This number is defined between 0 and 1;
  76891. */
  76892. mixToTile?: number;
  76893. /**
  76894. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  76895. * This number is defined between 0 and 1;
  76896. */
  76897. mixToNormal?: number;
  76898. }
  76899. /**
  76900. * DigitalRainPostProcess helps rendering everithing in digital rain.
  76901. *
  76902. * Simmply add it to your scene and let the nerd that lives in you have fun.
  76903. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  76904. */
  76905. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  76906. /**
  76907. * The font texture used to render the char in the post process.
  76908. */
  76909. private _digitalRainFontTexture;
  76910. /**
  76911. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  76912. * This number is defined between 0 and 1;
  76913. */
  76914. mixToTile: number;
  76915. /**
  76916. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  76917. * This number is defined between 0 and 1;
  76918. */
  76919. mixToNormal: number;
  76920. /**
  76921. * Instantiates a new Digital Rain Post Process.
  76922. * @param name the name to give to the postprocess
  76923. * @camera the camera to apply the post process to.
  76924. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  76925. */
  76926. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  76927. }
  76928. }
  76929. declare module BABYLON {
  76930. /** @hidden */
  76931. export var oceanPostProcessPixelShader: {
  76932. name: string;
  76933. shader: string;
  76934. };
  76935. }
  76936. declare module BABYLON {
  76937. /**
  76938. * Option available in the Ocean Post Process.
  76939. */
  76940. export interface IOceanPostProcessOptions {
  76941. /**
  76942. * The size of the reflection RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  76943. */
  76944. reflectionSize?: number | {
  76945. width: number;
  76946. height: number;
  76947. } | {
  76948. ratio: number;
  76949. };
  76950. /**
  76951. * The size of the refraction RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  76952. */
  76953. refractionSize?: number | {
  76954. width: number;
  76955. height: number;
  76956. } | {
  76957. ratio: number;
  76958. };
  76959. }
  76960. /**
  76961. * OceanPostProcess helps rendering an infinite ocean surface that can reflect and refract environment.
  76962. *
  76963. * Simmply add it to your scene and let the nerd that lives in you have fun.
  76964. * Example usage:
  76965. * var pp = new OceanPostProcess("myOcean", camera);
  76966. * pp.reflectionEnabled = true;
  76967. * pp.refractionEnabled = true;
  76968. */
  76969. export class OceanPostProcess extends BABYLON.PostProcess {
  76970. /**
  76971. * Gets a boolean indicating if the real-time reflection is enabled on the ocean.
  76972. */
  76973. get reflectionEnabled(): boolean;
  76974. /**
  76975. * Sets weither or not the real-time reflection is enabled on the ocean.
  76976. * Is set to true, the reflection mirror texture will be used as reflection texture.
  76977. */
  76978. set reflectionEnabled(enabled: boolean);
  76979. /**
  76980. * Gets a boolean indicating if the real-time refraction is enabled on the ocean.
  76981. */
  76982. get refractionEnabled(): boolean;
  76983. /**
  76984. * Sets weither or not the real-time refraction is enabled on the ocean.
  76985. * Is set to true, the refraction render target texture will be used as refraction texture.
  76986. */
  76987. set refractionEnabled(enabled: boolean);
  76988. /**
  76989. * Gets wether or not the post-processes is supported by the running hardware.
  76990. * This requires draw buffer supports.
  76991. */
  76992. get isSupported(): boolean;
  76993. /**
  76994. * This is the reflection mirror texture used to display reflections on the ocean.
  76995. * By default, render list is empty.
  76996. */
  76997. reflectionTexture: BABYLON.MirrorTexture;
  76998. /**
  76999. * This is the refraction render target texture used to display refraction on the ocean.
  77000. * By default, render list is empty.
  77001. */
  77002. refractionTexture: BABYLON.RenderTargetTexture;
  77003. private _time;
  77004. private _cameraRotation;
  77005. private _cameraViewMatrix;
  77006. private _reflectionEnabled;
  77007. private _refractionEnabled;
  77008. private _geometryRenderer;
  77009. /**
  77010. * Instantiates a new Ocean Post Process.
  77011. * @param name the name to give to the postprocess.
  77012. * @camera the camera to apply the post process to.
  77013. * @param options optional object following the IOceanPostProcessOptions format used to customize reflection and refraction render targets sizes.
  77014. */
  77015. constructor(name: string, camera: BABYLON.TargetCamera, options?: IOceanPostProcessOptions);
  77016. /**
  77017. * Returns the appropriate defines according to the current configuration.
  77018. */
  77019. private _getDefines;
  77020. /**
  77021. * Computes the current camera rotation as the shader requires a camera rotation.
  77022. */
  77023. private _computeCameraRotation;
  77024. }
  77025. }
  77026. declare module BABYLON {
  77027. /** @hidden */
  77028. export var brickProceduralTexturePixelShader: {
  77029. name: string;
  77030. shader: string;
  77031. };
  77032. }
  77033. declare module BABYLON {
  77034. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  77035. private _numberOfBricksHeight;
  77036. private _numberOfBricksWidth;
  77037. private _jointColor;
  77038. private _brickColor;
  77039. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  77040. updateShaderUniforms(): void;
  77041. get numberOfBricksHeight(): number;
  77042. set numberOfBricksHeight(value: number);
  77043. get numberOfBricksWidth(): number;
  77044. set numberOfBricksWidth(value: number);
  77045. get jointColor(): BABYLON.Color3;
  77046. set jointColor(value: BABYLON.Color3);
  77047. get brickColor(): BABYLON.Color3;
  77048. set brickColor(value: BABYLON.Color3);
  77049. /**
  77050. * Serializes this brick procedural texture
  77051. * @returns a serialized brick procedural texture object
  77052. */
  77053. serialize(): any;
  77054. /**
  77055. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  77056. * @param parsedTexture defines parsed texture data
  77057. * @param scene defines the current scene
  77058. * @param rootUrl defines the root URL containing brick procedural texture information
  77059. * @returns a parsed Brick Procedural BABYLON.Texture
  77060. */
  77061. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  77062. }
  77063. }
  77064. declare module BABYLON {
  77065. /** @hidden */
  77066. export var cloudProceduralTexturePixelShader: {
  77067. name: string;
  77068. shader: string;
  77069. };
  77070. }
  77071. declare module BABYLON {
  77072. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  77073. private _skyColor;
  77074. private _cloudColor;
  77075. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  77076. updateShaderUniforms(): void;
  77077. get skyColor(): BABYLON.Color4;
  77078. set skyColor(value: BABYLON.Color4);
  77079. get cloudColor(): BABYLON.Color4;
  77080. set cloudColor(value: BABYLON.Color4);
  77081. /**
  77082. * Serializes this cloud procedural texture
  77083. * @returns a serialized cloud procedural texture object
  77084. */
  77085. serialize(): any;
  77086. /**
  77087. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  77088. * @param parsedTexture defines parsed texture data
  77089. * @param scene defines the current scene
  77090. * @param rootUrl defines the root URL containing cloud procedural texture information
  77091. * @returns a parsed Cloud Procedural BABYLON.Texture
  77092. */
  77093. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  77094. }
  77095. }
  77096. declare module BABYLON {
  77097. /** @hidden */
  77098. export var fireProceduralTexturePixelShader: {
  77099. name: string;
  77100. shader: string;
  77101. };
  77102. }
  77103. declare module BABYLON {
  77104. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  77105. private _time;
  77106. private _speed;
  77107. private _autoGenerateTime;
  77108. private _fireColors;
  77109. private _alphaThreshold;
  77110. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  77111. updateShaderUniforms(): void;
  77112. render(useCameraPostProcess?: boolean): void;
  77113. static get PurpleFireColors(): BABYLON.Color3[];
  77114. static get GreenFireColors(): BABYLON.Color3[];
  77115. static get RedFireColors(): BABYLON.Color3[];
  77116. static get BlueFireColors(): BABYLON.Color3[];
  77117. get autoGenerateTime(): boolean;
  77118. set autoGenerateTime(value: boolean);
  77119. get fireColors(): BABYLON.Color3[];
  77120. set fireColors(value: BABYLON.Color3[]);
  77121. get time(): number;
  77122. set time(value: number);
  77123. get speed(): BABYLON.Vector2;
  77124. set speed(value: BABYLON.Vector2);
  77125. get alphaThreshold(): number;
  77126. set alphaThreshold(value: number);
  77127. /**
  77128. * Serializes this fire procedural texture
  77129. * @returns a serialized fire procedural texture object
  77130. */
  77131. serialize(): any;
  77132. /**
  77133. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  77134. * @param parsedTexture defines parsed texture data
  77135. * @param scene defines the current scene
  77136. * @param rootUrl defines the root URL containing fire procedural texture information
  77137. * @returns a parsed Fire Procedural BABYLON.Texture
  77138. */
  77139. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  77140. }
  77141. }
  77142. declare module BABYLON {
  77143. /** @hidden */
  77144. export var grassProceduralTexturePixelShader: {
  77145. name: string;
  77146. shader: string;
  77147. };
  77148. }
  77149. declare module BABYLON {
  77150. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  77151. private _grassColors;
  77152. private _groundColor;
  77153. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  77154. updateShaderUniforms(): void;
  77155. get grassColors(): BABYLON.Color3[];
  77156. set grassColors(value: BABYLON.Color3[]);
  77157. get groundColor(): BABYLON.Color3;
  77158. set groundColor(value: BABYLON.Color3);
  77159. /**
  77160. * Serializes this grass procedural texture
  77161. * @returns a serialized grass procedural texture object
  77162. */
  77163. serialize(): any;
  77164. /**
  77165. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  77166. * @param parsedTexture defines parsed texture data
  77167. * @param scene defines the current scene
  77168. * @param rootUrl defines the root URL containing grass procedural texture information
  77169. * @returns a parsed Grass Procedural BABYLON.Texture
  77170. */
  77171. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  77172. }
  77173. }
  77174. declare module BABYLON {
  77175. /** @hidden */
  77176. export var marbleProceduralTexturePixelShader: {
  77177. name: string;
  77178. shader: string;
  77179. };
  77180. }
  77181. declare module BABYLON {
  77182. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  77183. private _numberOfTilesHeight;
  77184. private _numberOfTilesWidth;
  77185. private _amplitude;
  77186. private _jointColor;
  77187. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  77188. updateShaderUniforms(): void;
  77189. get numberOfTilesHeight(): number;
  77190. set numberOfTilesHeight(value: number);
  77191. get amplitude(): number;
  77192. set amplitude(value: number);
  77193. get numberOfTilesWidth(): number;
  77194. set numberOfTilesWidth(value: number);
  77195. get jointColor(): BABYLON.Color3;
  77196. set jointColor(value: BABYLON.Color3);
  77197. /**
  77198. * Serializes this marble procedural texture
  77199. * @returns a serialized marble procedural texture object
  77200. */
  77201. serialize(): any;
  77202. /**
  77203. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  77204. * @param parsedTexture defines parsed texture data
  77205. * @param scene defines the current scene
  77206. * @param rootUrl defines the root URL containing marble procedural texture information
  77207. * @returns a parsed Marble Procedural BABYLON.Texture
  77208. */
  77209. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  77210. }
  77211. }
  77212. declare module BABYLON {
  77213. /** @hidden */
  77214. export var normalMapProceduralTexturePixelShader: {
  77215. name: string;
  77216. shader: string;
  77217. };
  77218. }
  77219. declare module BABYLON {
  77220. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  77221. private _baseTexture;
  77222. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  77223. updateShaderUniforms(): void;
  77224. render(useCameraPostProcess?: boolean): void;
  77225. resize(size: any, generateMipMaps: any): void;
  77226. get baseTexture(): BABYLON.Texture;
  77227. set baseTexture(texture: BABYLON.Texture);
  77228. /**
  77229. * Serializes this normal map procedural texture
  77230. * @returns a serialized normal map procedural texture object
  77231. */
  77232. serialize(): any;
  77233. /**
  77234. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  77235. * @param parsedTexture defines parsed texture data
  77236. * @param scene defines the current scene
  77237. * @param rootUrl defines the root URL containing normal map procedural texture information
  77238. * @returns a parsed Normal Map Procedural BABYLON.Texture
  77239. */
  77240. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  77241. }
  77242. }
  77243. declare module BABYLON {
  77244. /** @hidden */
  77245. export var perlinNoiseProceduralTexturePixelShader: {
  77246. name: string;
  77247. shader: string;
  77248. };
  77249. }
  77250. declare module BABYLON {
  77251. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  77252. time: number;
  77253. timeScale: number;
  77254. translationSpeed: number;
  77255. private _currentTranslation;
  77256. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  77257. updateShaderUniforms(): void;
  77258. render(useCameraPostProcess?: boolean): void;
  77259. resize(size: any, generateMipMaps: any): void;
  77260. /**
  77261. * Serializes this perlin noise procedural texture
  77262. * @returns a serialized perlin noise procedural texture object
  77263. */
  77264. serialize(): any;
  77265. /**
  77266. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  77267. * @param parsedTexture defines parsed texture data
  77268. * @param scene defines the current scene
  77269. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  77270. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  77271. */
  77272. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  77273. }
  77274. }
  77275. declare module BABYLON {
  77276. /** @hidden */
  77277. export var roadProceduralTexturePixelShader: {
  77278. name: string;
  77279. shader: string;
  77280. };
  77281. }
  77282. declare module BABYLON {
  77283. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  77284. private _roadColor;
  77285. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  77286. updateShaderUniforms(): void;
  77287. get roadColor(): BABYLON.Color3;
  77288. set roadColor(value: BABYLON.Color3);
  77289. /**
  77290. * Serializes this road procedural texture
  77291. * @returns a serialized road procedural texture object
  77292. */
  77293. serialize(): any;
  77294. /**
  77295. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  77296. * @param parsedTexture defines parsed texture data
  77297. * @param scene defines the current scene
  77298. * @param rootUrl defines the root URL containing road procedural texture information
  77299. * @returns a parsed Road Procedural BABYLON.Texture
  77300. */
  77301. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  77302. }
  77303. }
  77304. declare module BABYLON {
  77305. /** @hidden */
  77306. export var starfieldProceduralTexturePixelShader: {
  77307. name: string;
  77308. shader: string;
  77309. };
  77310. }
  77311. declare module BABYLON {
  77312. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  77313. private _time;
  77314. private _alpha;
  77315. private _beta;
  77316. private _zoom;
  77317. private _formuparam;
  77318. private _stepsize;
  77319. private _tile;
  77320. private _brightness;
  77321. private _darkmatter;
  77322. private _distfading;
  77323. private _saturation;
  77324. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  77325. updateShaderUniforms(): void;
  77326. get time(): number;
  77327. set time(value: number);
  77328. get alpha(): number;
  77329. set alpha(value: number);
  77330. get beta(): number;
  77331. set beta(value: number);
  77332. get formuparam(): number;
  77333. set formuparam(value: number);
  77334. get stepsize(): number;
  77335. set stepsize(value: number);
  77336. get zoom(): number;
  77337. set zoom(value: number);
  77338. get tile(): number;
  77339. set tile(value: number);
  77340. get brightness(): number;
  77341. set brightness(value: number);
  77342. get darkmatter(): number;
  77343. set darkmatter(value: number);
  77344. get distfading(): number;
  77345. set distfading(value: number);
  77346. get saturation(): number;
  77347. set saturation(value: number);
  77348. /**
  77349. * Serializes this starfield procedural texture
  77350. * @returns a serialized starfield procedural texture object
  77351. */
  77352. serialize(): any;
  77353. /**
  77354. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  77355. * @param parsedTexture defines parsed texture data
  77356. * @param scene defines the current scene
  77357. * @param rootUrl defines the root URL containing startfield procedural texture information
  77358. * @returns a parsed Starfield Procedural BABYLON.Texture
  77359. */
  77360. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  77361. }
  77362. }
  77363. declare module BABYLON {
  77364. /** @hidden */
  77365. export var woodProceduralTexturePixelShader: {
  77366. name: string;
  77367. shader: string;
  77368. };
  77369. }
  77370. declare module BABYLON {
  77371. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  77372. private _ampScale;
  77373. private _woodColor;
  77374. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  77375. updateShaderUniforms(): void;
  77376. get ampScale(): number;
  77377. set ampScale(value: number);
  77378. get woodColor(): BABYLON.Color3;
  77379. set woodColor(value: BABYLON.Color3);
  77380. /**
  77381. * Serializes this wood procedural texture
  77382. * @returns a serialized wood procedural texture object
  77383. */
  77384. serialize(): any;
  77385. /**
  77386. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  77387. * @param parsedTexture defines parsed texture data
  77388. * @param scene defines the current scene
  77389. * @param rootUrl defines the root URL containing wood procedural texture information
  77390. * @returns a parsed Wood Procedural BABYLON.Texture
  77391. */
  77392. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  77393. }
  77394. }